@@ -5,6 +5,7 @@ package tss
55
66import (
77 "context"
8+ "errors"
89 "fmt"
910 "sync"
1011 "time"
@@ -132,40 +133,37 @@ func (c *Coordinator) handleError(ctx context.Context, err error, tssProcesses [
132133 return c .watchExecution (ctx , tssProcesses [0 ], peer .ID ("" ))
133134 })
134135 sessionID := tssProcesses [0 ].SessionID ()
135- switch err := err .(type ) {
136- case * CoordinatorError :
137- {
138- log .Warn ().Str ("SessionID" , sessionID ).Msgf ("Tss process failed with error %+v" , err )
139136
140- excludedPeers := []peer.ID {err .Peer }
141- rp .Go (func (ctx context.Context ) error { return c .retry (ctx , tssProcesses , resultChn , excludedPeers ) })
142- }
143- case * comm.CommunicationError :
144- {
145- log .Err (err ).Str ("SessionID" , sessionID ).Msgf ("Tss process failed with error %+v" , err )
146- rp .Go (func (ctx context.Context ) error { return c .retry (ctx , tssProcesses , resultChn , []peer.ID {}) })
147- }
148- case * tss.Error :
149- {
150- log .Err (err ).Str ("SessionID" , sessionID ).Msgf ("Tss process failed with error %+v" , err )
151- excludedPeers , err := common .PeersFromParties (err .Culprits ())
152- if err != nil {
153- return err
154- }
155- rp .Go (func (ctx context.Context ) error { return c .retry (ctx , tssProcesses , resultChn , excludedPeers ) })
156- }
157- case * SubsetError :
158- {
159- // wait for start message if existing singing process fails
160- rp .Go (func (ctx context.Context ) error {
161- return c .waitForStart (ctx , tssProcesses , resultChn , peer .ID ("" ), c .TssTimeout )
162- })
163- }
164- default :
165- {
137+ var coordinatorError * CoordinatorError
138+ var commError * comm.CommunicationError
139+ var subsetError * SubsetError
140+ var tssError * tss.Error
141+ if errors .As (err , & coordinatorError ) {
142+ coordinatorError = err .(* CoordinatorError )
143+ log .Warn ().Str ("SessionID" , sessionID ).Msgf ("Tss process failed with error %+v" , err )
144+
145+ excludedPeers := []peer.ID {coordinatorError .Peer }
146+ rp .Go (func (ctx context.Context ) error { return c .retry (ctx , tssProcesses , resultChn , excludedPeers ) })
147+ } else if errors .Is (err , commError ) {
148+ log .Err (err ).Str ("SessionID" , sessionID ).Msgf ("Tss process failed with error %+v" , err )
149+ rp .Go (func (ctx context.Context ) error { return c .retry (ctx , tssProcesses , resultChn , []peer.ID {}) })
150+ } else if errors .Is (err , & tss.Error {}) {
151+ tssError = err .(* tss.Error )
152+ log .Err (err ).Str ("SessionID" , sessionID ).Msgf ("Tss process failed with error %+v" , err )
153+ excludedPeers , err := common .PeersFromParties (tssError .Culprits ())
154+ if err != nil {
166155 return err
167156 }
157+ rp .Go (func (ctx context.Context ) error { return c .retry (ctx , tssProcesses , resultChn , excludedPeers ) })
158+ } else if errors .As (err , & subsetError ) {
159+ // wait for start message if existing singing process fails
160+ rp .Go (func (ctx context.Context ) error {
161+ return c .waitForStart (ctx , tssProcesses , resultChn , peer .ID ("" ), c .TssTimeout )
162+ })
163+ } else {
164+ return err
168165 }
166+
169167 return rp .Wait ()
170168}
171169
0 commit comments