Browse Source

initial logic to remove txs from the mempool

wb/txrset
William Banfield 3 years ago
parent
commit
914c555ff5
No known key found for this signature in database GPG Key ID: EFAD3442BF29E3AC
2 changed files with 17 additions and 1 deletions
  1. +12
    -0
      abci/types/types.go
  2. +5
    -1
      internal/state/execution.go

+ 12
- 0
abci/types/types.go 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
internal/state/execution.go 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)
}


Loading…
Cancel
Save