Lock around validateBeaconBlockPubSub (#3567)

This commit is contained in:
terence tsao
2019-09-23 18:43:07 -07:00
committed by GitHub
parent ad47817bcd
commit cbcbb487ac
2 changed files with 3 additions and 0 deletions

View File

@@ -66,6 +66,7 @@ type RegularSync struct {
pendingQueueLock sync.RWMutex
chainStarted bool
initialSync Checker
validateBlockLock sync.RWMutex
}
// Start the regular sync service.

View File

@@ -19,6 +19,8 @@ var recentlySeenRoots = ccache.New(ccache.Configure().MaxSize(100000))
// Blocks that have already been seen are ignored. If the BLS signature is any valid signature,
// this method rebroadcasts the message.
func (r *RegularSync) validateBeaconBlockPubSub(ctx context.Context, msg proto.Message, p p2p.Broadcaster, fromSelf bool) bool {
r.validateBlockLock.Lock()
defer r.validateBlockLock.Unlock()
m := msg.(*ethpb.BeaconBlock)
blockRoot, err := ssz.SigningRoot(m)