From 79ed4537ee0001ff06b3e748817c4d0a72a25adf Mon Sep 17 00:00:00 2001 From: msutton Date: Fri, 8 Jul 2022 17:30:01 +0300 Subject: [PATCH 1/2] bump to version 0.12.4 --- version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/version.go b/version/version.go index 6a434d25d..61ee5cc3a 100644 --- a/version/version.go +++ b/version/version.go @@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs const ( appMajor uint = 0 appMinor uint = 12 - appPatch uint = 3 + appPatch uint = 4 ) // appBuild is defined as a variable so it can be overridden during the build From 716efbc718b2b1c318fbec3216d918bdb3170e89 Mon Sep 17 00:00:00 2001 From: msutton Date: Sat, 9 Jul 2022 22:08:31 +0300 Subject: [PATCH 2/2] Avoid locking consensus twice in the common case of adding block with updateVirtual=true --- domain/consensus/consensus.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/domain/consensus/consensus.go b/domain/consensus/consensus.go index ef45183ed..f1591a551 100644 --- a/domain/consensus/consensus.go +++ b/domain/consensus/consensus.go @@ -196,11 +196,26 @@ func (s *consensus) BuildBlockTemplate(coinbaseData *externalapi.DomainCoinbaseD func (s *consensus) ValidateAndInsertBlock(block *externalapi.DomainBlock, updateVirtual bool) error { if updateVirtual { - // Make sure virtual is resolved before adding the new block - err := s.ResolveVirtual(nil) + s.lock.Lock() + // Make sure virtual is resolved correctly before adding the new block + isCompletelyResolved, err := s.resolveVirtualNoLock(100) if err != nil { + s.lock.Unlock() return err } + if isCompletelyResolved { + defer s.lock.Unlock() + _, err := s.validateAndInsertBlockNoLock(block, updateVirtual) + if err != nil { + return err + } + return nil + } + s.lock.Unlock() + + for !isCompletelyResolved { + isCompletelyResolved, err = s.resolveVirtualChunkWithLock(100) + } } return s.validateAndInsertBlockWithLock(block, updateVirtual)