From 170db02ba1dcd709fcf616ae3f4117533782044e Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Mon, 27 Mar 2023 14:38:41 +0200 Subject: [PATCH] Remove chainTipBlockRequest from p2p client, use ZeroHash on expectedBlockId instead --- p2pool/p2p/client.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/p2pool/p2p/client.go b/p2pool/p2p/client.go index 3915ddf..179cadb 100644 --- a/p2pool/p2p/client.go +++ b/p2pool/p2p/client.go @@ -60,7 +60,6 @@ type Client struct { RequestedHashes *utils.CircularBuffer[types.Hash] blockPendingRequests chan types.Hash - chainTipBlockRequest atomic.Bool expectedMessage MessageId @@ -177,9 +176,6 @@ func (c *Client) SendBlockRequest(id types.Hash) { }) c.blockPendingRequests <- id - if id == types.ZeroHash { - c.chainTipBlockRequest.Store(true) - } } func (c *Client) SendBlockResponse(block *sidechain.PoolBlock) { @@ -402,17 +398,9 @@ func (c *Client) OnConnection() { c.Ban(DefaultBanTime, err) return } else { - isChainTipBlockRequest := false - if c.chainTipBlockRequest.Swap(false) { - isChainTipBlockRequest = true - //TODO: stale block - + isChainTipBlockRequest := expectedBlockId == types.ZeroHash + if isChainTipBlockRequest { log.Printf("[P2PClient] Peer %s tip is at id = %s, height = %d, main height = %d", c.AddressPort.String(), types.HashFromBytes(block.CoinbaseExtra(sidechain.SideTemplateId)), block.Side.Height, block.Main.Coinbase.GenHeight) - - if expectedBlockId != types.ZeroHash { - c.Ban(DefaultBanTime, fmt.Errorf("expected block id = %s, got %s", expectedBlockId, types.ZeroHash.String())) - return - } peerHeight := block.Main.Coinbase.GenHeight ourHeight := c.Owner.MainChain().GetMinerDataTip().Height