功能:

  • 自我管理(self,状态、生命周期等)

  • 交易相关管理(has_many,交易、KeyImage 等)

方法:

Init_Mempool

新创建一线程,在里面运行。

初始化

Init_Block_Mempool

HouseKeeping

自动移除的规则

主要根据高度、时间戳判断交易是否已过期。
根据 KeyImage 判断存在双花嫌疑的,也一并删除。
过期则从交易池删除。

清除算法:
高度判断
数据库判断重复交易
涉及到一些特定限制参数,如 1天、7天。

Shutdown

先把数据保存到 mempool.json 文件

Monitor

HasChanged

Mempool_Add_TX

添加

保存交易的 tx_hash 和 key_images 数据
其它数据可以自己生成

Mempool_TX_Exist

// check whether a tx exists in the pool

Mempool_Keyimage_Spent

// check whether a keyimage exists in the pool

Mempool_Delete_TX

移除

// delete specific tx from pool and return it
// if nil is returned Tx was not found in pool

Mempool_Get_TX

Mempool_List_TX

Mempool_List_TX_SortedInfo

Mempool_Print

Mempool_flush

// flush mempool
清洗、清空内存池。

sort_list

交易池里的排序算法!

根据每单位数据的手续费(FeesPerByte)大小进行排序。

// sorts the pool internally
// this function assummes lock is already taken
// ??? if we  selecting transactions randomly, why to keep them sorted

有意思的是:区块打包的时候,绝大多数交易是随机选择的,只有极少数(10%)是根据这里的排序(即手续费)进行选择。

Relayer_and_Cleaner

通过 P2P 网络,对外传播交易数据。

通过网络对外传播交易数据。

results matching ""

    No results matching ""