From fc0414d16528088aaf79df43c7530e6ff8ade852 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Thu, 3 Aug 2023 22:44:33 +0800 Subject: [PATCH] sync indexer publishing --- service.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/service.go b/service.go index 45e5e09..f86382f 100644 --- a/service.go +++ b/service.go @@ -820,12 +820,17 @@ func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, p return err } + var nodeMtx, ipldMtx sync.Mutex nodeSink := func(node types2.StateLeafNode) error { defer metrics.UpdateDuration(time.Now(), metrics.IndexerMetrics.OutputTimer) + nodeMtx.Lock() + defer nodeMtx.Unlock() return sds.indexer.PushStateNode(tx, node, block.Hash().String()) } ipldSink := func(c types2.IPLD) error { defer metrics.UpdateDuration(time.Now(), metrics.IndexerMetrics.IPLDOutputTimer) + ipldMtx.Lock() + defer ipldMtx.Unlock() return sds.indexer.PushIPLD(tx, c) }