diff --git a/core/bodydb.go b/core/bodydb.go index 40262944c1..ff49b08d7b 100644 --- a/core/bodydb.go +++ b/core/bodydb.go @@ -43,7 +43,8 @@ type BodyDb struct { woCache *lru.Cache processor *StateProcessor - slicesRunning []common.Location + slicesRunning []common.Location + processingState bool logger *log.Logger } diff --git a/core/headerchain.go b/core/headerchain.go index 35dbcbc775..bf566d7533 100644 --- a/core/headerchain.go +++ b/core/headerchain.go @@ -72,9 +72,10 @@ type HeaderChain struct { running int32 // 0 if chain is running, 1 when stopped procInterrupt int32 // interrupt signaler for block processing - headermu sync.RWMutex - heads []*types.WorkObject - slicesRunning []common.Location + headermu sync.RWMutex + heads []*types.WorkObject + slicesRunning []common.Location + processingState bool logger *log.Logger @@ -124,6 +125,9 @@ func NewHeaderChain(db ethdb.Database, engine consensus.Engine, pEtxsRollupFetch return nil, err } + // Record if the chain is processing state + hc.processingState = hc.setStateProcessing() + pendingEtxsRollup, _ := lru.New(c_maxPendingEtxsRollup) hc.pendingEtxsRollup = pendingEtxsRollup @@ -314,7 +318,26 @@ func (hc *HeaderChain) AppendHeader(header *types.WorkObject) error { return nil } func (hc *HeaderChain) ProcessingState() bool { - return hc.bc.ProcessingState() + return hc.processingState +} + +func (hc *HeaderChain) setStateProcessing() bool { + nodeCtx := hc.NodeCtx() + for _, slice := range hc.slicesRunning { + switch nodeCtx { + case common.PRIME_CTX: + return true + case common.REGION_CTX: + if slice.Region() == hc.NodeLocation().Region() { + return true + } + case common.ZONE_CTX: + if slice.Equal(hc.NodeLocation()) { + return true + } + } + } + return false } // Append