@@ -17,9 +17,10 @@ type handler struct {
1717// Dispatcher executes UCAN invocations by dispatching them to registered
1818// handlers.
1919type Dispatcher struct {
20- authority principal.Signer
21- handlers map [ucan.Command ]handler
22- validationOpts []validator.Option
20+ authority principal.Signer
21+ handlers map [ucan.Command ]handler
22+ validationOpts []validator.Option
23+ receiptTimestamps bool
2324}
2425
2526// New creates an invocation executor that executes UCAN invocations by
@@ -33,9 +34,10 @@ func New(authority principal.Signer, options ...Option) *Dispatcher {
3334 opt (& cfg )
3435 }
3536 return & Dispatcher {
36- authority : authority ,
37- handlers : map [ucan.Command ]handler {},
38- validationOpts : cfg .validationOpts ,
37+ authority : authority ,
38+ handlers : map [ucan.Command ]handler {},
39+ validationOpts : cfg .validationOpts ,
40+ receiptTimestamps : cfg .receiptTimestamps ,
3941 }
4042}
4143
@@ -52,6 +54,7 @@ func (d *Dispatcher) Execute(req execution.Request) (execution.Response, error)
5254 return execution .NewResponse (
5355 req .Invocation ().Task ().Link (),
5456 execution .WithSigner (d .authority ),
57+ execution .WithReceiptTimestamp (d .receiptTimestamps ),
5558 execution .WithFailure (execution .NewInvalidAudienceError (d .authority , aud )),
5659 )
5760 }
@@ -62,6 +65,7 @@ func (d *Dispatcher) Execute(req execution.Request) (execution.Response, error)
6265 return execution .NewResponse (
6366 req .Invocation ().Task ().Link (),
6467 execution .WithSigner (d .authority ),
68+ execution .WithReceiptTimestamp (d .receiptTimestamps ),
6569 execution .WithFailure (NewHandlerNotFoundError (cmd )),
6670 )
6771 }
@@ -82,11 +86,16 @@ func (d *Dispatcher) Execute(req execution.Request) (execution.Response, error)
8286 return execution .NewResponse (
8387 req .Invocation ().Task ().Link (),
8488 execution .WithSigner (d .authority ),
89+ execution .WithReceiptTimestamp (d .receiptTimestamps ),
8590 execution .WithFailure (err ),
8691 )
8792 }
8893
89- res , err := execution .NewResponse (req .Invocation ().Task ().Link (), execution .WithSigner (d .authority ))
94+ res , err := execution .NewResponse (
95+ req .Invocation ().Task ().Link (),
96+ execution .WithSigner (d .authority ),
97+ execution .WithReceiptTimestamp (d .receiptTimestamps ),
98+ )
9099 if err != nil {
91100 return nil , fmt .Errorf ("failed to create response: %w" , err )
92101 }
@@ -96,6 +105,7 @@ func (d *Dispatcher) Execute(req execution.Request) (execution.Response, error)
96105 return execution .NewResponse (
97106 req .Invocation ().Task ().Link (),
98107 execution .WithSigner (d .authority ),
108+ execution .WithReceiptTimestamp (d .receiptTimestamps ),
99109 execution .WithFailure (execution .NewHandlerExecutionError (cmd , err )),
100110 )
101111 }
0 commit comments