node: Simplify WrapWithScissors and make AlgorandWatcher use it
This commit is contained in:
parent
72e3a103b8
commit
04ed27cb3f
|
@ -1127,7 +1127,7 @@ func runNode(cmd *cobra.Command, args []string) {
|
|||
readiness.RegisterComponent(common.ReadinessAlgorandSyncing)
|
||||
chainObsvReqC[vaa.ChainIDAlgorand] = make(chan *gossipv1.ObservationRequest, observationRequestBufferSize)
|
||||
if err := supervisor.Run(ctx, "algorandwatch",
|
||||
algorand.NewWatcher(*algorandIndexerRPC, *algorandIndexerToken, *algorandAlgodRPC, *algorandAlgodToken, *algorandAppID, lockC, chainObsvReqC[vaa.ChainIDAlgorand]).Run); err != nil {
|
||||
common.WrapWithScissors(algorand.NewWatcher(*algorandIndexerRPC, *algorandIndexerToken, *algorandAlgodRPC, *algorandAlgodToken, *algorandAppID, lockC, chainObsvReqC[vaa.ChainIDAlgorand]).Run)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,18 +38,8 @@ func RunWithScissors(ctx context.Context, errC chan error, name string, runnable
|
|||
}()
|
||||
}
|
||||
|
||||
type (
|
||||
Scissors struct {
|
||||
runnable supervisor.Runnable
|
||||
}
|
||||
)
|
||||
|
||||
func WrapWithScissors(runnable supervisor.Runnable) supervisor.Runnable {
|
||||
s := Scissors{runnable: runnable}
|
||||
return s.Run
|
||||
}
|
||||
|
||||
func (e *Scissors) Run(ctx context.Context) (result error) {
|
||||
return func(ctx context.Context) (result error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
switch x := r.(type) {
|
||||
|
@ -62,5 +52,6 @@ func (e *Scissors) Run(ctx context.Context) (result error) {
|
|||
}
|
||||
}()
|
||||
|
||||
return e.runnable(ctx)
|
||||
return runnable(ctx)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue