涉及的bip
- bip68 交易输出会锁定一段时间不允许消费
- bip125 如果mempool已经有相同交易输入的交易,具备更高手续费(小费)的新加入交易会替换掉旧的交易。
ctxmempoolentry
存储一个交易的相关信息和其他在mempool中与这个交易有关的祖先、后裔交易的数据。
每当有新的交易添加到mempool,都需要更新这个新交易的所有祖先交易的相关状态。
ctxmempool
存储那些对于the-current-best-chain有效且准备存储到下一个区块的交易。
网络上被见到(seen on the network)的交易(包括在本地节点创建的交易)都会添加到该mempool。除了:
- 交易手续费不满足最低要求
- mempool中已有相同交易输入的交易
- 非标准交易
ctxmempool::mapTx 和 ctxmempoolentry
mapTx是一个 boost::multi_index,并会以四个标准去整理mempool(中的交易):
- 交易hash
- 后裔交易的税率,max(feerate of tx,feerate of tx with all descendants(in-mempool transactions that depend on this one))
- 在mempool中的时间
- 祖先交易的税率,min(feerate of tx, feerate of tx with all unconfirmed ancestors(in-mempool transactions that a given transaction depends