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 c6688ac
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/core/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ func (m *Mempool) ProcessTx(srcPeerID string, msg message.Message) ([]bytes.Buff
return nil, errors.New("mempool is full, dropping transaction")
}

var h byte
// Initializing `h=0` or `h=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"
// Hence, `h=0` will not be broadcasted at all and
// `h=KadcastInitialHeight` will miss the broadcast to the first bucket
var h byte = math.MaxUint8
if msg.Metadata() != nil {
h = msg.Metadata().KadcastHeight
}
Expand Down Expand Up @@ -495,10 +500,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 c6688ac

Please sign in to comment.