Documentation ¶
Index ¶
- func Reg(name string, create Create)
- type AccountTxIndex
- func (cache *AccountTxIndex) CanPush(tx *types.Transaction) bool
- func (cache *AccountTxIndex) GetAccTxs(addrs *types.ReqAddrs) *types.TransactionDetails
- func (cache *AccountTxIndex) Push(tx *types.Transaction) error
- func (cache *AccountTxIndex) Remove(tx *types.Transaction)
- func (cache *AccountTxIndex) TxNumOfAccount(addr string) int
- type Create
- type Item
- type LastTxCache
- type Mempool
- func (mem *Mempool) CheckExpireValid(msg *queue.Message) (bool, error)
- func (mem *Mempool) Close()
- func (mem *Mempool) GetAccTxs(addrs *types.ReqAddrs) *types.TransactionDetails
- func (mem *Mempool) GetHeader() *types.Header
- func (mem *Mempool) GetLastHeader() (interface{}, error)
- func (mem *Mempool) GetLatestTx() []*types.Transaction
- func (mem *Mempool) GetProperFeeRate(req *types.ReqProperFee) int64
- func (mem *Mempool) Height() int64
- func (mem *Mempool) PushTx(tx *types.Transaction) error
- func (mem *Mempool) RemoveTxs(hashList *types.TxHashList) error
- func (mem *Mempool) RemoveTxsOfBlock(block *types.Block) bool
- func (mem *Mempool) SetMinFee(fee int64)
- func (mem *Mempool) SetQueueCache(qcache QueueCache)
- func (mem *Mempool) SetQueueClient(client queue.Client)
- func (mem *Mempool) Size() int
- func (mem *Mempool) TxNumOfAccount(addr string) int64
- func (mem *Mempool) Wait()
- type QueueCache
- type SHashTxCache
- type SimpleQueue
- func (cache *SimpleQueue) Exist(hash string) bool
- func (cache *SimpleQueue) GetItem(hash string) (*Item, error)
- func (cache *SimpleQueue) GetProperFee() int64
- func (cache *SimpleQueue) Push(tx *Item) error
- func (cache *SimpleQueue) Remove(hash string) error
- func (cache *SimpleQueue) Size() int
- func (cache *SimpleQueue) Walk(count int, cb func(value *Item) bool)
- type SubConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountTxIndex ¶
type AccountTxIndex struct {
// contains filtered or unexported fields
}
AccountTxIndex 账户和交易索引
func NewAccountTxIndex ¶
func NewAccountTxIndex(maxperaccount int) *AccountTxIndex
NewAccountTxIndex 创建一个新的索引
func (*AccountTxIndex) CanPush ¶
func (cache *AccountTxIndex) CanPush(tx *types.Transaction) bool
CanPush 是否可以push 进 account index
func (*AccountTxIndex) GetAccTxs ¶
func (cache *AccountTxIndex) GetAccTxs(addrs *types.ReqAddrs) *types.TransactionDetails
GetAccTxs 用来获取对应账户地址(列表)中的全部交易详细信息
func (*AccountTxIndex) Push ¶
func (cache *AccountTxIndex) Push(tx *types.Transaction) error
Push push transaction to AccountTxIndex
func (*AccountTxIndex) Remove ¶
func (cache *AccountTxIndex) Remove(tx *types.Transaction)
Remove 根据交易哈希删除对应账户的对应交易
func (*AccountTxIndex) TxNumOfAccount ¶
func (cache *AccountTxIndex) TxNumOfAccount(addr string) int
TxNumOfAccount 返回账户在Mempool中交易数量
type Item ¶
type Item struct { Value *types.Transaction Priority int64 EnterTime int64 }
Item 为Mempool中包装交易的数据结构
type LastTxCache ¶
type LastTxCache struct {
// contains filtered or unexported fields
}
LastTxCache 最后放入cache的交易
func (*LastTxCache) GetLatestTx ¶
func (cache *LastTxCache) GetLatestTx() (txs []*types.Transaction)
GetLatestTx 返回最新十条加入到txCache的交易
func (*LastTxCache) Push ¶
func (cache *LastTxCache) Push(tx *types.Transaction)
Push tx into LastTxCache
func (*LastTxCache) Remove ¶
func (cache *LastTxCache) Remove(tx *types.Transaction)
Remove remove tx of last cache
type Mempool ¶
type Mempool struct {
// contains filtered or unexported fields
}
Mempool mempool 基础类
func (*Mempool) CheckExpireValid ¶
CheckExpireValid 检查交易过期有效性,过期返回false,未过期返回true
func (*Mempool) GetAccTxs ¶
func (mem *Mempool) GetAccTxs(addrs *types.ReqAddrs) *types.TransactionDetails
GetAccTxs 用来获取对应账户地址(列表)中的全部交易详细信息
func (*Mempool) GetLastHeader ¶
GetLastHeader 获取LastHeader的height和blockTime
func (*Mempool) GetLatestTx ¶
func (mem *Mempool) GetLatestTx() []*types.Transaction
GetLatestTx 返回最新十条加入到mempool的交易
func (*Mempool) GetProperFeeRate ¶
func (mem *Mempool) GetProperFeeRate(req *types.ReqProperFee) int64
GetProperFeeRate 获取合适的手续费率
func (*Mempool) PushTx ¶
func (mem *Mempool) PushTx(tx *types.Transaction) error
PushTx 将交易推入mempool,并返回结果(error)
func (*Mempool) RemoveTxs ¶
func (mem *Mempool) RemoveTxs(hashList *types.TxHashList) error
RemoveTxs 从mempool中删除给定Hash的txs
func (*Mempool) RemoveTxsOfBlock ¶
RemoveTxsOfBlock 移除mempool中已被Blockchain打包的tx
func (*Mempool) SetQueueCache ¶
func (mem *Mempool) SetQueueCache(qcache QueueCache)
SetQueueCache 设置排队策略
func (*Mempool) SetQueueClient ¶
SetQueueClient 初始化mempool模块
func (*Mempool) TxNumOfAccount ¶
TxNumOfAccount 返回账户在mempool中交易数量
type QueueCache ¶
type QueueCache interface { Exist(hash string) bool GetItem(hash string) (*Item, error) Push(tx *Item) error Remove(hash string) error Size() int Walk(count int, cb func(tx *Item) bool) GetProperFee() int64 }
QueueCache 排队交易处理
type SHashTxCache ¶
type SHashTxCache struct {
// contains filtered or unexported fields
}
SHashTxCache 通过shorthash缓存交易
func NewSHashTxCache ¶
func NewSHashTxCache(size int) *SHashTxCache
NewSHashTxCache 创建通过短hash交易的cache
func (*SHashTxCache) GetSHashTxCache ¶
func (cache *SHashTxCache) GetSHashTxCache(sHash string) *types.Transaction
GetSHashTxCache 返回shorthash对应的tx交易信息
func (*SHashTxCache) Push ¶
func (cache *SHashTxCache) Push(tx *types.Transaction)
Push tx into SHashTxCache
func (*SHashTxCache) Remove ¶
func (cache *SHashTxCache) Remove(tx *types.Transaction)
Remove remove tx of SHashTxCache
type SimpleQueue ¶
type SimpleQueue struct {
// contains filtered or unexported fields
}
SimpleQueue 简单队列模式(默认提供一个队列,便于测试)
func (*SimpleQueue) GetItem ¶
func (cache *SimpleQueue) GetItem(hash string) (*Item, error)
GetItem 获取数据通过 key
func (*SimpleQueue) GetProperFee ¶
func (cache *SimpleQueue) GetProperFee() int64
GetProperFee 获取合适的手续费
func (*SimpleQueue) Push ¶
func (cache *SimpleQueue) Push(tx *Item) error
Push 把给定tx添加到SimpleQueue;如果tx已经存在SimpleQueue中或Mempool已满则返回对应error