From aea11d53a8066fed2a1302394645d1a2a20d1a4e Mon Sep 17 00:00:00 2001 From: Jitendra Bhurat Date: Thu, 13 Dec 2018 12:31:50 -0500 Subject: [PATCH] calling unlock using defer, preventing deadlock when miner.setEtherbase() returns an error --- eth/backend.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eth/backend.go b/eth/backend.go index 44ebc6e2d..e401242a2 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -356,12 +356,13 @@ func (s *Ethereum) Etherbase() (eb common.Address, err error) { // set in js console via admin interface or wrapper from cli flags func (s *Ethereum) SetEtherbase(etherbase common.Address) { s.lock.Lock() + defer s.lock.Unlock() if _, ok := s.engine.(consensus.Istanbul); ok { log.Error("Cannot set etherbase in Istanbul consensus") return } s.etherbase = etherbase - s.lock.Unlock() + s.miner.SetEtherbase(etherbase) }