From 7aa0f65aa602eb15f1dae5e5048883c5117f187b Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Mon, 8 Aug 2022 12:27:59 +0200 Subject: [PATCH] Fix transaction propagation Default transaction's kadcast height cannot be 0. If so, tx will not be repropagated --- pkg/core/mempool/mempool.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/core/mempool/mempool.go b/pkg/core/mempool/mempool.go index 1d167b09a..e682f3358 100644 --- a/pkg/core/mempool/mempool.go +++ b/pkg/core/mempool/mempool.go @@ -214,7 +214,10 @@ func (m *Mempool) ProcessTx(srcPeerID string, msg message.Message) ([]bytes.Buff return nil, errors.New("mempool is full, dropping transaction") } - var h byte + // Initializing with MaxUint8 as KadcastInitialHeight will not work. + // This because `h` will be decremented by the kadcast writer as per + // it's interpreted as "the kadcast height at which it's been received" + var h byte = math.MaxUint8 if msg.Metadata() != nil { h = msg.Metadata().KadcastHeight } @@ -495,10 +498,6 @@ func (m Mempool) processGetMempoolTxsBySizeRequest(r rpcbus.Request) (interface{ // kadcastTx (re)propagates transaction in kadcast network. func (m *Mempool) kadcastTx(t TxDesc) error { - if t.kadHeight > config.KadcastInitialHeight { - return errors.New("invalid kadcast height") - } - /// repropagate buf := new(bytes.Buffer) if err := transactions.Marshal(buf, t.tx); err != nil {