From 1aa61d3287f63222a6cac8a49be0080a37cad8d6 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Fri, 26 Oct 2018 09:57:08 +0800 Subject: core: Lock entire lattice.ProcessBlock (#259) * Lock entire ProcessBlock * Lock Consensus.processBlock --- core/lattice.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core/lattice.go') diff --git a/core/lattice.go b/core/lattice.go index 69ad51c..06005c1 100644 --- a/core/lattice.go +++ b/core/lattice.go @@ -161,8 +161,6 @@ func (s *Lattice) SanityCheck(b *types.Block) (err error) { // NOTE: assume the block passed sanity check. func (s *Lattice) addBlockToLattice( input *types.Block) (outputBlocks []*types.Block, err error) { - s.lock.Lock() - defer s.lock.Unlock() if tip := s.data.chains[input.Position.ChainID].tip; tip != nil { if !input.Position.Newer(&tip.Position) { return @@ -226,6 +224,9 @@ func (s *Lattice) ProcessBlock( deliveredMode uint32 ) + s.lock.Lock() + defer s.lock.Unlock() + if inLattice, err = s.addBlockToLattice(input); err != nil { return } -- cgit v1.2.3