Skip to content

Commit

Permalink
Read broadcast tx's once included in block
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopeereboom committed Oct 23, 2024
1 parent 7164ae8 commit 61f7c64
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion service/tbc/tbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1221,9 +1221,19 @@ func (s *Server) handleBlock(ctx context.Context, p *peer, msg *wire.MsgBlock, r
len(msg.Transactions), msg.Header.Timestamp)
}

// Reap broadcast messages.
txHashes, _ := block.MsgBlock().TxHashes()
s.mtx.Lock()
for _, v := range txHashes {
if _, ok := s.broadcast[v]; ok {
delete(s.broadcast, v)
log.Infof("broadcast tx %v included in %v %v", v, bhs, height)
}
}
s.mtx.Unlock()

// Reap txs from mempool, no need to log error.
if s.cfg.MempoolEnabled {
txHashes, _ := block.MsgBlock().TxHashes()
_ = s.mempool.txsRemove(ctx, txHashes)
}

Expand Down

0 comments on commit 61f7c64

Please sign in to comment.