@@ -26,7 +26,7 @@ import (
2626
2727type EventListener interface {
2828 FetchKeygenEvents (ctx context.Context , address common.Address , startBlock * big.Int , endBlock * big.Int ) ([]types.Log , error )
29- FetchRefreshEvents (ctx context.Context , address common.Address , startBlock * big.Int , endBlock * big.Int ) ([] * events.Refresh , error )
29+ FetchRefreshEvents (ctx context.Context , address common.Address , startBlock * big.Int , endBlock * big.Int ) (* events.Refresh , types. Log , error )
3030}
3131
3232type KeygenEventHandler struct {
@@ -143,22 +143,17 @@ func (eh *RefreshEventHandler) HandleEvents(
143143 startBlock * big.Int ,
144144 endBlock * big.Int ,
145145) error {
146- refreshEvents , err := eh .eventListener .FetchRefreshEvents (
146+ refreshEvent , l , err := eh .eventListener .FetchRefreshEvents (
147147 context .Background (), eh .bridgeAddress , startBlock , endBlock ,
148148 )
149149 if err != nil {
150150 return fmt .Errorf ("unable to fetch keygen events because of: %+v" , err )
151151 }
152- if len ( refreshEvents ) == 0 {
152+ if refreshEvent == nil {
153153 return nil
154154 }
155155
156- hash := refreshEvents [len (refreshEvents )- 1 ].Hash
157- if hash == "" {
158- log .Error ().Msgf ("Hash cannot be empty string" )
159- return nil
160- }
161- topology , err := eh .topologyProvider .NetworkTopology (hash )
156+ topology , err := eh .topologyProvider .NetworkTopology (refreshEvent .Hash )
162157 if err != nil {
163158 log .Error ().Err (err ).Msgf ("Failed fetching network topology" )
164159 return nil
@@ -177,7 +172,7 @@ func (eh *RefreshEventHandler) HandleEvents(
177172 )
178173
179174 resharing := resharing .NewResharing (
180- eh .sessionID (startBlock ), topology .Threshold , eh .host , eh .communication , eh .ecdsaStorer ,
175+ eh .sessionID (new (big. Int ). SetUint64 ( l . BlockNumber ) ), topology .Threshold , eh .host , eh .communication , eh .ecdsaStorer ,
181176 )
182177 err = eh .coordinator .Execute (context .Background (), []tss.TssProcess {resharing }, make (chan interface {}, 1 ), peer .ID ("" ))
183178 if err != nil {
0 commit comments