@@ -22,7 +22,8 @@ type triggerID = uint64
22
22
type msgH = abi.ChainEpoch
23
23
24
24
// triggerH is the block height at which the listener will be notified about the
25
- // message (msgH+confidence)
25
+ //
26
+ // message (msgH+confidence)
26
27
type triggerH = abi.ChainEpoch
27
28
28
29
type eventData interface {}
@@ -38,7 +39,8 @@ type EventHandler func(ctx context.Context, data eventData, prevTs, ts *types.Ti
38
39
//
39
40
// If `done` is true, timeout won't be triggered
40
41
// If `more` is false, no messages will be sent to EventHandler (RevertHandler
41
- // may still be called)
42
+ //
43
+ // may still be called)
42
44
type CheckFunc func (ctx context.Context , ts * types.TipSet ) (done bool , more bool , err error )
43
45
44
46
// Keep track of information for an event handler
@@ -374,31 +376,31 @@ type StateMatchFunc func(oldTs, newTs *types.TipSet) (bool, StateChange, error)
374
376
// StateChanged registers a callback which is triggered when a specified state
375
377
// change occurs or a timeout is reached.
376
378
//
377
- // * `CheckFunc` callback is invoked immediately with a recent tipset, it
378
- // returns two booleans - `done`, and `more`.
379
+ // - `CheckFunc` callback is invoked immediately with a recent tipset, it
380
+ // returns two booleans - `done`, and `more`.
379
381
//
380
- // * `done` should be true when some on-chain state change we are waiting
382
+ // - `done` should be true when some on-chain state change we are waiting
381
383
// for has happened. When `done` is set to true, timeout trigger is disabled.
382
384
//
383
- // * `more` should be false when we don't want to receive new notifications
385
+ // - `more` should be false when we don't want to receive new notifications
384
386
// through StateChangeHandler. Note that notifications may still be delivered to
385
387
// RevertHandler
386
388
//
387
- // * `StateChangeHandler` is called when the specified state change was observed
388
- // on-chain, and a confidence threshold was reached, or the specified `timeout`
389
- // height was reached with no state change observed. When this callback is
390
- // invoked on a timeout, `oldTs` and `states are set to nil.
391
- // This callback returns a boolean specifying whether further notifications
392
- // should be sent, like `more` return param from `CheckFunc` above.
389
+ // - `StateChangeHandler` is called when the specified state change was observed
390
+ // on-chain, and a confidence threshold was reached, or the specified `timeout`
391
+ // height was reached with no state change observed. When this callback is
392
+ // invoked on a timeout, `oldTs` and `states are set to nil.
393
+ // This callback returns a boolean specifying whether further notifications
394
+ // should be sent, like `more` return param from `CheckFunc` above.
393
395
//
394
- // * `RevertHandler` is called after apply handler, when we drop the tipset
395
- // containing the message. The tipset passed as the argument is the tipset
396
- // that is being dropped. Note that the event dropped may be re-applied
397
- // in a different tipset in small amount of time.
396
+ // - `RevertHandler` is called after apply handler, when we drop the tipset
397
+ // containing the message. The tipset passed as the argument is the tipset
398
+ // that is being dropped. Note that the event dropped may be re-applied
399
+ // in a different tipset in small amount of time.
398
400
//
399
- // * `StateMatchFunc` is called against each tipset state. If there is a match,
400
- // the state change is queued up until the confidence interval has elapsed (and
401
- // `StateChangeHandler` is called)
401
+ // - `StateMatchFunc` is called against each tipset state. If there is a match,
402
+ // the state change is queued up until the confidence interval has elapsed (and
403
+ // `StateChangeHandler` is called)
402
404
func (we * watcherEvents ) StateChanged (check CheckFunc , scHnd StateChangeHandler , rev RevertHandler , confidence int , timeout abi.ChainEpoch , mf StateMatchFunc ) error {
403
405
hnd := func (ctx context.Context , data eventData , prevTs , ts * types.TipSet , height abi.ChainEpoch ) (bool , error ) {
404
406
states , ok := data .(StateChange )
@@ -502,33 +504,34 @@ type MsgHandler func(msg *types.Message, rec *types.MessageReceipt, ts *types.Ti
502
504
type MsgMatchFunc func (msg * types.Message ) (matched bool , err error )
503
505
504
506
// Called registers a callback which is triggered when a specified method is
505
- // called on an actor, or a timeout is reached.
506
507
//
507
- // * `CheckFunc` callback is invoked immediately with a recent tipset, it
508
- // returns two booleans - `done`, and `more`.
508
+ // called on an actor, or a timeout is reached.
509
509
//
510
- // * `done` should be true when some on-chain action we are waiting for has
511
- // happened. When `done` is set to true, timeout trigger is disabled .
510
+ // - `CheckFunc` callback is invoked immediately with a recent tipset, it
511
+ // returns two booleans - `done`, and `more` .
512
512
//
513
- // * `more` should be false when we don't want to receive new notifications
514
- // through MsgHandler. Note that notifications may still be delivered to
515
- // RevertHandler
513
+ // - `done` should be true when some on-chain action we are waiting for has
514
+ // happened. When `done` is set to true, timeout trigger is disabled.
516
515
//
517
- // * `MsgHandler` is called when the specified event was observed on-chain,
518
- // and a confidence threshold was reached, or the specified `timeout` height
519
- // was reached with no events observed. When this callback is invoked on a
520
- // timeout, `msg` is set to nil. This callback returns a boolean specifying
521
- // whether further notifications should be sent, like `more` return param
522
- // from `CheckFunc` above.
516
+ // - `more` should be false when we don't want to receive new notifications
517
+ // through MsgHandler. Note that notifications may still be delivered to
518
+ // RevertHandler
523
519
//
524
- // * `RevertHandler` is called after apply handler, when we drop the tipset
525
- // containing the message. The tipset passed as the argument is the tipset
526
- // that is being dropped. Note that the message dropped may be re-applied
527
- // in a different tipset in small amount of time.
520
+ // - `MsgHandler` is called when the specified event was observed on-chain,
521
+ // and a confidence threshold was reached, or the specified `timeout` height
522
+ // was reached with no events observed. When this callback is invoked on a
523
+ // timeout, `msg` is set to nil. This callback returns a boolean specifying
524
+ // whether further notifications should be sent, like `more` return param
525
+ // from `CheckFunc` above.
528
526
//
529
- // * `MsgMatchFunc` is called against each message. If there is a match, the
530
- // message is queued up until the confidence interval has elapsed (and
531
- // `MsgHandler` is called)
527
+ // - `RevertHandler` is called after apply handler, when we drop the tipset
528
+ // containing the message. The tipset passed as the argument is the tipset
529
+ // that is being dropped. Note that the message dropped may be re-applied
530
+ // in a different tipset in small amount of time.
531
+ //
532
+ // - `MsgMatchFunc` is called against each message. If there is a match, the
533
+ // message is queued up until the confidence interval has elapsed (and
534
+ // `MsgHandler` is called)
532
535
func (me * messageEvents ) Called (ctx context.Context , check CheckFunc , msgHnd MsgHandler , rev RevertHandler , confidence int , timeout abi.ChainEpoch , mf MsgMatchFunc ) error {
533
536
hnd := func (ctx context.Context , data eventData , prevTs , ts * types.TipSet , height abi.ChainEpoch ) (bool , error ) {
534
537
msg , ok := data .(* types.Message )
@@ -550,7 +553,7 @@ func (me *messageEvents) Called(ctx context.Context, check CheckFunc, msgHnd Msg
550
553
551
554
id , err := me .hcAPI .onHeadChanged (ctx , check , hnd , rev , confidence , timeout )
552
555
if err != nil {
553
- return err
556
+ return fmt . Errorf ( "on head changed error: %w" , err )
554
557
}
555
558
556
559
me .lk .Lock ()
0 commit comments