From 00f368c82841069204aba8da826e95e536634853 Mon Sep 17 00:00:00 2001 From: gop Date: Tue, 14 Feb 2023 14:42:57 -0600 Subject: [PATCH] bugfix: Accept Transactions when at the Fray --- eth/fetcher/block_fetcher.go | 7 ++----- eth/handler.go | 6 ++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/eth/fetcher/block_fetcher.go b/eth/fetcher/block_fetcher.go index b08be9ad58..bcfa041e8d 100644 --- a/eth/fetcher/block_fetcher.go +++ b/eth/fetcher/block_fetcher.go @@ -25,7 +25,6 @@ import ( "github.com/dominant-strategies/go-quai/common" "github.com/dominant-strategies/go-quai/common/prque" "github.com/dominant-strategies/go-quai/consensus" - "github.com/dominant-strategies/go-quai/core" "github.com/dominant-strategies/go-quai/core/types" "github.com/dominant-strategies/go-quai/log" "github.com/dominant-strategies/go-quai/metrics" @@ -823,10 +822,8 @@ func (f *BlockFetcher) importBlocks(peer string, block *types.Block) { } // Run the actual import and log any issues if _, err := f.insertChain(types.Blocks{block}); err != nil { - if err.Error() != core.ErrAddedFutureCache.Error() { - log.Debug("Propagated block import failed", "peer", peer, "number", block.Number(), "hash", hash, "err", err) - return - } + log.Debug("Propagated block import failed", "peer", peer, "number", block.Number(), "hash", hash, "err", err) + return } // If import succeeded, broadcast the block blockAnnounceOutTimer.UpdateSince(block.ReceivedAt) diff --git a/eth/handler.go b/eth/handler.go index 9dc6a90a25..b3535ae3b9 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -164,6 +164,12 @@ func newHandler(config *handlerConfig) (*handler, error) { if err == nil { atomic.StoreUint32(&h.acceptTxs, 1) // Mark initial sync done on any fetcher import } + // If the error is related to synchronization of sub, we can still accept the transactions + // This is a good approximation on reaching the fray + if err != nil && err.Error() == core.ErrAddedFutureCache.Error() { + atomic.StoreUint32(&h.acceptTxs, 1) // Mark initial sync done on any fetcher import + return n, nil + } return n, err } h.blockFetcher = fetcher.NewBlockFetcher(false, nil, h.core.GetBlockByHash, validator, h.BroadcastBlock, heighter, nil, inserter, h.removePeer)