initial logic to remove txs from the mempool

This commit is contained in:
William Banfield
2022-03-08 17:28:00 -05:00
parent 9fbbdecb65
commit 914c555ff5
2 changed files with 17 additions and 1 deletions
+12
View File
@@ -221,6 +221,18 @@ func (rpp *ResponsePrepareProposal) IncludedTxs() []*TxRecord {
return trs
}
// RemovedTxs returns all of the TxRecords that are marked for removal from the
// mempool.
func (rpp *ResponsePrepareProposal) RemovedTxs() []*TxRecord {
trs := []*TxRecord{}
for _, tr := range rpp.TxRecords {
if tr.Action == TxRecord_REMOVED {
trs = append(trs, tr)
}
}
return trs
}
// Validate checks that the fields of the ResponsePrepareProposal are properly
// constructed. Validate returns an error if any of the validation checks fail.
func (rpp *ResponsePrepareProposal) Validate(maxSizeBytes int64, otxs [][]byte) error {
+5 -1
View File
@@ -144,7 +144,11 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
if err := rpp.Validate(maxDataBytes, txs.ToSliceOfBytes()); err != nil {
return nil, err
}
for _, rtx := range rpp.RemovedTxs() {
if err := blockExec.mempool.RemoveTxByKey(types.Tx(rtx.Tx).Key()); err != nil {
blockExec.logger.Debug("error removing transaction from the mempool", "error", err)
}
}
return state.MakeBlock(height, types.TxRecordsToTxs(rpp.IncludedTxs()), commit, evidence, proposerAddr)
}