Skip to content

Commit

Permalink
Fix transaction propagation
Browse files Browse the repository at this point in the history
Default transaction's kadcast height cannot be 0.
If so, tx will not be repropagated
  • Loading branch information
herr-seppia committed Aug 8, 2022
1 parent 3fca5b5 commit 7aa0f65
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/core/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 7aa0f65

Please sign in to comment.