Remove unneeded #:capture-projection argument to term->skeleton-interest

This commit is contained in:
Tony Garnock-Jones 2019-05-03 20:29:40 +01:00
parent 40ee3b4ca7
commit a86478b7b9
2 changed files with 34 additions and 36 deletions

View File

@ -74,38 +74,39 @@
;; (log-info "~a (asserted (observe (inbound ~v)))" inner-actor x)
(with-current-facet [outer-facet]
(with-non-script-context
(define outer-capture-proj (term->capture-proj x))
(define inner-capture-proj (map (lambda (p) (cons 0 p)) outer-capture-proj))
;; ^ inner-capture-proj accounts for the extra (inbound ...) layer around assertions
(define i
(term->skeleton-interest
x
#:capture-projection outer-capture-proj
(lambda (op . captured-values)
(define assertion
(instantiate-term->value (inbound x) captured-values
#:visibility-restriction-proj inner-capture-proj))
;; (log-info "~a => ~a ~a ~v"
;; outer-facet
;; inner-facet
;; op
;; assertion)
(match op
['+ (apply-patch! inner-ds inner-actor (bag assertion +1))]
['- (apply-patch! inner-ds inner-actor (bag assertion -1))]
['! (send-assertion! (dataspace-routing-table inner-ds) assertion)])
(schedule-inner!))
#:cleanup
(lambda (cache)
(apply-patch!
inner-ds
inner-actor
(for/bag/count [(captured-values (in-bag cache))]
;; (log-info "~a (cleanup) ~v" inner-actor term)
(values (instantiate-term->value (inbound x) captured-values
#:visibility-restriction-proj inner-capture-proj)
-1)))
(schedule-inner!))))
(let ((inner-capture-proj
;; inner-capture-proj accounts for the extra (inbound ...) layer around
;; assertions
(let ((outer-capture-proj (term->capture-proj x)))
(map (lambda (p) (cons 0 p)) outer-capture-proj))))
(term->skeleton-interest
x
(lambda (op . captured-values)
(define assertion
(instantiate-term->value (inbound x) captured-values
#:visibility-restriction-proj inner-capture-proj))
;; (log-info "~a => ~a ~a ~v"
;; outer-facet
;; inner-facet
;; op
;; assertion)
(match op
['+ (apply-patch! inner-ds inner-actor (bag assertion +1))]
['- (apply-patch! inner-ds inner-actor (bag assertion -1))]
['! (send-assertion! (dataspace-routing-table inner-ds) assertion)])
(schedule-inner!))
#:cleanup
(lambda (cache)
(apply-patch!
inner-ds
inner-actor
(for/bag/count [(captured-values (in-bag cache))]
;; (log-info "~a (cleanup) ~v" inner-actor term)
(values (instantiate-term->value (inbound x) captured-values
#:visibility-restriction-proj inner-capture-proj)
-1)))
(schedule-inner!)))))
(add-endpoint-if-live! outer-facet
inbound-endpoints
x

View File

@ -15,14 +15,11 @@
(require "pattern.rkt")
(require "skeleton.rkt")
(define (term->skeleton-interest x
#:capture-projection [capture-proj (term->capture-proj x)]
handler
#:cleanup [cleanup #f])
(define (term->skeleton-interest x handler #:cleanup [cleanup #f])
(skeleton-interest (term->skeleton x)
(term->skeleton-proj x)
(term->key x)
capture-proj
(term->capture-proj x)
handler
cleanup))