From e0e597c8d8b80cd78554a887941ecc1125c65848 Mon Sep 17 00:00:00 2001 From: drk Date: Thu, 16 May 2024 17:28:02 -0500 Subject: [PATCH] adjusted subscriptions as well as the handling of workObjectHeaderViews in handler --- cmd/utils/hierarchical_coordinator.go | 16 ++++++++++------ quai/handler.go | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/cmd/utils/hierarchical_coordinator.go b/cmd/utils/hierarchical_coordinator.go index 667c950396..7fcdb54b9d 100644 --- a/cmd/utils/hierarchical_coordinator.go +++ b/cmd/utils/hierarchical_coordinator.go @@ -134,15 +134,19 @@ func (hc *HierarchicalCoordinator) startNode(logPath string, quaiBackend quai.Co quaiBackend.SetApiBackend(&apiBackend, location) // Only subscribe to block and transaction data if processing state - if quaiBackend.ProcessingState(location) { - hc.p2p.Subscribe(location, &types.WorkObjectBlockView{}) - hc.p2p.Subscribe(location, &types.Transactions{}) + if !quaiBackend.ProcessingState(location) && location.Context() == common.ZONE_CTX { + hc.p2p.Subscribe(location, &types.WorkObjectHeaderView{}) + } + + if quaiBackend.ProcessingState(location) && location.Context() == common.ZONE_CTX { + // Subscribe to the new topics after setting the api backend hc.p2p.Subscribe(location, &types.WorkObjectHeader{}) + hc.p2p.Subscribe(location, &types.Transactions{}) } - // Subscribe to the new topics after setting the api backend - hc.p2p.Subscribe(location, &types.WorkObjectHeaderView{}) - hc.p2p.Subscribe(location, &types.WorkObjectHeader{}) + if location.Context() == common.PRIME_CTX || location.Context() == common.REGION_CTX || quaiBackend.ProcessingState(location) { + hc.p2p.Subscribe(location, &types.WorkObjectBlockView{}) + } StartNode(stack) diff --git a/quai/handler.go b/quai/handler.go index 25c4fd0ebf..83c94bdd03 100644 --- a/quai/handler.go +++ b/quai/handler.go @@ -122,10 +122,18 @@ func (h *handler) missingBlockLoop() { }).Fatal("Go-Quai Panicked") } }() - resultCh := h.p2pBackend.Request(h.nodeLocation, blockRequest.Hash, &types.WorkObjectBlockView{}) - block := <-resultCh - if block != nil { - h.core.WriteBlock(block.(*types.WorkObjectBlockView).WorkObject) + if !h.core.ProcessingState() && h.nodeLocation.Context() == common.ZONE_CTX { + resultCh := h.p2pBackend.Request(h.nodeLocation, blockRequest.Hash, &types.WorkObjectHeaderView{}) + block := <-resultCh + if block != nil { + h.core.WriteBlock(block.(*types.WorkObjectHeaderView).WorkObject) + } + } else { + resultCh := h.p2pBackend.Request(h.nodeLocation, blockRequest.Hash, &types.WorkObjectBlockView{}) + block := <-resultCh + if block != nil { + h.core.WriteBlock(block.(*types.WorkObjectBlockView).WorkObject) + } } h.recentBlockReqCache.Remove(blockRequest.Hash) }()