batch

package module
v0.0.0-...-fc70a76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 19 Imported by: 7

README

txpool-batch

介绍

hercules 链批量交易池模块

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const (
	DefaultBatchMaxSize       = 100
	DefaultBatchCreateTimeout = 1000 * time.Millisecond
	DefaultPoolSize           = 10000
	TxPoolType                = "BATCH"
)
View Source
const (
	DefaultMaxTxCount          = 1000         // Maximum number of transactions in a block
	DefaultMaxTxPoolSize       = 5120         // Maximum number of common transaction in the pool
	DefaultMaxConfigTxPoolSize = 100          // Maximum number of config transaction in the pool
	DefaultMaxTxTimeTimeout    = float64(600) // The unit is in seconds
)

Variables

View Source
var (
	TxPoolConfig   *txPoolConfig
	MonitorEnabled bool
)

Functions

func IsMetrics

func IsMetrics() bool

IsMetrics Whether to log operation time

func IsTxTimeVerify

func IsTxTimeVerify(chainConf protocol.ChainConf) bool

IsTxTimeVerify Whether transactions require validation

func MaxCommonTxPoolSize

func MaxCommonTxPoolSize() int

MaxCommonTxPoolSize Maximum number of common transaction in the pool

func MaxConfigTxPoolSize

func MaxConfigTxPoolSize() int

MaxConfigTxPoolSize The maximum number of configure transaction in the pool

func MaxTxCount

func MaxTxCount(chainConf protocol.ChainConf) int

MaxTxCount Maximum number of transactions in a block

func MaxTxTimeTimeout

func MaxTxTimeTimeout(chainConf protocol.ChainConf) float64

MaxTxTimeTimeout The maximum timeout for a transaction

func NewBatchTxPool

func NewBatchTxPool(
	nodeId string,
	chainId string,
	txFilter protocol.TxFilter,
	chainStore protocol.BlockchainStore,
	msgBus msgbus.MessageBus,
	chainConf protocol.ChainConf,
	ac protocol.AccessControlProvider,
	log protocol.Logger,
	monitorEnabled bool,
	poolConfig map[string]interface{}) (protocol.TxPool, error)

NewBatchTxPool creates BatchTxPool

Types

type BatchTxPool

type BatchTxPool struct {
	// contains filtered or unexported fields
}

BatchTxPool Another implementation of tx pool, which can only be used in non-Hotstuff consensus algorithms

func (*BatchTxPool) AddTx

AddTx add tx to pool

func (*BatchTxPool) AddTxsToPendingCache

func (p *BatchTxPool) AddTxsToPendingCache(txs []*commonPb.Transaction, blockHeight uint64)

AddTxsToPendingCache These transactions will be added to the cache to avoid the transactions are fetched again and re-filled into the new block. Because Because of the chain confirmation rule in the HotStuff consensus algorithm.

func (*BatchTxPool) Apply

func (p *BatchTxPool) Apply(opts ...Option) error

Apply apply txPool config

func (*BatchTxPool) FetchTxBatch

func (p *BatchTxPool) FetchTxBatch(blockHeight uint64) []*commonPb.Transaction

FetchTxBatch Get the batch of transactions from the tx pool to generate new block

func (*BatchTxPool) GetTxByTxId

func (p *BatchTxPool) GetTxByTxId(txId string) (tx *commonPb.Transaction, inBlockHeight uint64)

GetTxByTxId Retrieve the transaction by the txId from the txPool

func (*BatchTxPool) GetTxsByTxIds

func (p *BatchTxPool) GetTxsByTxIds(txIds []string) (map[string]*commonPb.Transaction, map[string]uint64)

GetTxsByTxIds Retrieves the tx by the txIds from the tx pool. txsRet if the transaction is in the tx pool, it will be returned in txsRet. txsHeightRet if the transaction is in the pending queue of the tx pool, the corresponding block height when the transaction entered the block is returned, if the transaction is in the normal queue of the tx pool, the tx height is 0, if the transaction is not in the transaction pool, the tx height is math.MaxUint64.

func (*BatchTxPool) OnMessage

func (p *BatchTxPool) OnMessage(message *msgbus.Message)

OnMessage receive msg from msgBus

func (*BatchTxPool) OnQuit

func (p *BatchTxPool) OnQuit()

func (*BatchTxPool) RetryAndRemoveTxs

func (p *BatchTxPool) RetryAndRemoveTxs(retryTxs []*commonPb.Transaction, removeTxs []*commonPb.Transaction)

RetryAndRemoveTxs Process transactions within multiple proposed blocks at the same height to ensure that these transactions are not lost, re-add valid txs which that are not on local node. remove txs in the commit block.

func (*BatchTxPool) SetBatchCreateTimeout

func (p *BatchTxPool) SetBatchCreateTimeout(timeout time.Duration)

SetBatchCreateTimeout set batchCreateTimeout

func (*BatchTxPool) SetBatchMaxSize

func (p *BatchTxPool) SetBatchMaxSize(size int)

SetBatchMaxSize set batchMaxSize

func (*BatchTxPool) SetMsgBus

func (p *BatchTxPool) SetMsgBus(msgBus msgbus.MessageBus)

SetMsgBus set msgBus

func (*BatchTxPool) SetPoolSize

func (p *BatchTxPool) SetPoolSize(size int)

SetPoolSize set poolSize

func (*BatchTxPool) Start

func (p *BatchTxPool) Start() error

Start start up txPool service

func (*BatchTxPool) Stop

func (p *BatchTxPool) Stop() error

Stop stop txPool service

func (*BatchTxPool) TxExists

func (p *BatchTxPool) TxExists(tx *commonPb.Transaction) bool

TxExists verifies whether the transaction exists in the tx_pool

type Option

type Option func(p *BatchTxPool) error

Option is txPool config Options

func WithBatchCreateTimeout

func WithBatchCreateTimeout(timeout time.Duration) Option

WithBatchCreateTimeout set batchCreateTimeout

func WithBatchMaxSize

func WithBatchMaxSize(maxSize int) Option

WithBatchMaxSize set batchMaxSize

func WithMsgBus

func WithMsgBus(msgBus msgbus.MessageBus) Option

WithMsgBus set msgBus

func WithPoolSize

func WithPoolSize(size int) Option

WithPoolSize set poolSize

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL