File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -320,7 +320,8 @@ func (sb *Backend) newChainHead(newBlock *types.Block) {
320
320
321
321
// If this is the last block of the epoch:
322
322
// * Print an easy to find log message giving our address and whether we're elected in next epoch.
323
- // * if this is a proxy or a non proxied validator, refresh the validator enode table.
323
+ // * If this is a node maintaining validator connections (e.g. a proxy or a standalone validator), refresh the validator enode table.
324
+ // * If this is a proxied validator, notify the proxied validator engine of a new epoch.
324
325
if istanbul .IsLastBlockOfEpoch (newBlock .Number ().Uint64 (), sb .config .Epoch ) {
325
326
326
327
sb .coreMu .RLock ()
@@ -337,6 +338,12 @@ func (sb *Backend) newChainHead(newBlock *types.Block) {
337
338
sb .logger .Warn ("Error refreshing validator peers" , "err" , err )
338
339
}
339
340
}
341
+
342
+ if sb .IsProxiedValidator () {
343
+ if err := sb .proxiedValidatorEngine .NewEpoch (); err != nil {
344
+ sb .logger .Warn ("Error while notifying proxied validator engine of new epoch" , "err" , err )
345
+ }
346
+ }
340
347
}
341
348
342
349
sb .blocksFinalizedTransactionsGauge .Update (int64 (len (newBlock .Transactions ())))
Original file line number Diff line number Diff line change @@ -356,6 +356,22 @@ func (pv *proxiedValidatorEngine) SendForwardMsgToAllProxies(finalDestAddresses
356
356
return nil
357
357
}
358
358
359
+ // NewEpoch will notify the proxied validator's thread that a new epoch started
360
+ func (pv * proxiedValidatorEngine ) NewEpoch () error {
361
+ if ! pv .Running () {
362
+ return istanbul .ErrStoppedProxiedValidatorEngine
363
+ }
364
+
365
+ select {
366
+ case pv .newBlockchainEpoch <- struct {}{}:
367
+
368
+ case <- pv .quit :
369
+ return istanbul .ErrStoppedProxiedValidatorEngine
370
+ }
371
+
372
+ return nil
373
+ }
374
+
359
375
// run handles changes to proxies and validator assignments
360
376
func (pv * proxiedValidatorEngine ) threadRun () {
361
377
var (
Original file line number Diff line number Diff line change @@ -123,6 +123,9 @@ type ProxiedValidatorEngine interface {
123
123
124
124
// IsProxyPeer will check if the peerID is a proxy.
125
125
IsProxyPeer (peerID enode.ID ) (bool , error )
126
+
127
+ // NewEpoch will notify the proxied validator's thread that a new epoch started
128
+ NewEpoch () error
126
129
}
127
130
128
131
// ==============================================
You can’t perform that action at this time.
0 commit comments