Documentation ¶
Overview ¶
Package common provides constants, common types for other packages
Index ¶
- Constants
- func GetOngBalance(account common.Address) (*big.Int, error)
- func ShowTraceLog(format string, a ...interface{})
- type CheckBlkResult
- type CheckingStatus
- type GetTxnPoolReq
- type GetTxnPoolRsp
- type OrderByNetWorkFee
- type SenderType
- type TXAttr
- type TXEntry
- type TXPool
- func (tp *TXPool) AddTxList(txEntry *VerifiedTx) errors.ErrCode
- func (tp *TXPool) CleanCompletedTransactionList(txs []*types.Transaction, height uint32)
- func (s *TXPool) CleanStaledEIPTx(height uint32)
- func (tp *TXPool) GetTransaction(hash common.Uint256) *types.Transaction
- func (tp *TXPool) GetTransactionCount() int
- func (tp *TXPool) GetTransactionHashList() []common.Uint256
- func (tp *TXPool) GetTxPool(byCount bool, height uint32) ([]*VerifiedTx, []*types.Transaction)
- func (tp *TXPool) GetTxStatus(hash common.Uint256) *TxStatus
- func (tp *TXPool) GetUnverifiedTxs(txs []*types.Transaction, height uint32) *CheckBlkResult
- func (s *TXPool) NextNonce(addr common.Address) uint64
- func (tp *TXPool) Remain() []*types.Transaction
- func (tp *TXPool) RemoveTxsBelowGasPrice(gasPrice uint64)
- type Transactions
- type TxPoolService
- type TxResult
- type TxStatus
- type UserNonceInfo
- type VerifiedTx
- type VerifyBlockReq
- type VerifyBlockRsp
- type VerifyTxResult
Constants ¶
const ( MAX_CAPACITY = 100140 // The tx pool's capacity that holds the verified txs MAX_PENDING_TXN = 4096 * 10 // The max length of pending txs MAX_LIMITATION = 10000 // The length of pending tx from net and http UPDATE_FREQUENCY = 100 // The frequency to update gas price from global params MAX_TX_SIZE = 1024 * 1024 // The max size of a transaction to prevent DOS attacks EIPTX_EXPIRATION_BLOCKS = 50 // eip pending nonce tx expire block count EIPTX_NONCE_MAX_GAP = 1000 // max nonce gap from new tx to tx pool )
Variables ¶
This section is empty.
Functions ¶
func ShowTraceLog ¶ added in v1.14.1
func ShowTraceLog(format string, a ...interface{})
Types ¶
type CheckBlkResult ¶
type CheckBlkResult struct { VerifiedTxs []*VerifyTxResult UnverifiedTxs []*types.Transaction OldTxs []*types.Transaction }
CheckBlkResult contains a verifed tx list, an unverified tx list and an old tx list to be re-verifed
type CheckingStatus ¶ added in v1.14.1
type CheckingStatus struct { PassedStateless uint32 // actually bool, use uint32 for atomic operation PassedStateful uint32 // actually bool, use uint32 for atomic operation CheckHeight uint32 Nonce uint64 }
func (*CheckingStatus) GetStateful ¶ added in v1.14.1
func (s *CheckingStatus) GetStateful() bool
func (*CheckingStatus) GetStateless ¶ added in v1.14.1
func (s *CheckingStatus) GetStateless() bool
func (*CheckingStatus) GetTxAttr ¶ added in v1.14.1
func (self *CheckingStatus) GetTxAttr() []*TXAttr
func (*CheckingStatus) SetStateful ¶ added in v1.14.1
func (s *CheckingStatus) SetStateful(height uint32, nonce uint64)
func (*CheckingStatus) SetStateless ¶ added in v1.14.1
func (s *CheckingStatus) SetStateless()
type GetTxnPoolReq ¶
consensus messages GetTxnPoolReq specifies the api that how to get the valid transaction list.
type GetTxnPoolRsp ¶
type GetTxnPoolRsp struct {
TxnPool []*VerifiedTx
}
GetTxnPoolRsp returns a transaction list for GetTxnPoolReq.
type OrderByNetWorkFee ¶
type OrderByNetWorkFee []*VerifiedTx
func (OrderByNetWorkFee) Len ¶
func (n OrderByNetWorkFee) Len() int
func (OrderByNetWorkFee) Less ¶
func (n OrderByNetWorkFee) Less(i, j int) bool
func (OrderByNetWorkFee) Swap ¶
func (n OrderByNetWorkFee) Swap(i, j int)
type SenderType ¶
type SenderType uint8
SenderType enumerates the kind of tx submitter
const ( NilSender SenderType = iota NetSender // Net sends tx req HttpSender // Http sends tx req )
type TXAttr ¶
type TXAttr struct { Height uint32 // The height in which tx was verified Type vt.VerifyType // The validator flag: stateless/stateful ErrCode errors.ErrCode // Verified result }
type TXEntry ¶
type TXEntry struct { Tx *types.Transaction // transaction which has been verified Attrs []*TXAttr // the result from each validator }
type TXPool ¶
TXPool contains all currently valid transactions. Transactions enter the pool when they are valid from the network, consensus or submitted. They exit the pool when they are included in the ledger.
func (*TXPool) AddTxList ¶
func (tp *TXPool) AddTxList(txEntry *VerifiedTx) errors.ErrCode
AddTxList adds a valid transaction to the transaction pool. If the transaction is already in the pool, just return false. Parameter txEntry includes transaction, fee, and verified information(height, validator, error code).
func (*TXPool) CleanCompletedTransactionList ¶ added in v1.14.1
func (tp *TXPool) CleanCompletedTransactionList(txs []*types.Transaction, height uint32)
cleans the transaction list included in the ledger.
func (*TXPool) CleanStaledEIPTx ¶ added in v1.14.1
func (*TXPool) GetTransaction ¶
func (tp *TXPool) GetTransaction(hash common.Uint256) *types.Transaction
GetTransaction returns a transaction if it is contained in the pool and nil otherwise.
func (*TXPool) GetTransactionCount ¶
GetTransactionCount returns the tx number of the pool.
func (*TXPool) GetTransactionHashList ¶ added in v1.11.0
GetTransactionCount returns the tx number of the pool.
func (*TXPool) GetTxPool ¶
func (tp *TXPool) GetTxPool(byCount bool, height uint32) ([]*VerifiedTx, []*types.Transaction)
gets the transaction lists from the pool for the consensus, if the byCount is marked, return the configured number at most; if the the byCount is not marked, return all of the current transaction pool.
func (*TXPool) GetTxStatus ¶
GetTxStatus returns a transaction status if it is contained in the pool and nil otherwise.
func (*TXPool) GetUnverifiedTxs ¶
func (tp *TXPool) GetUnverifiedTxs(txs []*types.Transaction, height uint32) *CheckBlkResult
checks the tx list in the block from consensus, and returns verified tx list, unverified tx list, and the tx list to be re-verified
func (*TXPool) Remain ¶ added in v1.0.1
func (tp *TXPool) Remain() []*types.Transaction
returns the remaining tx list to cleanup
func (*TXPool) RemoveTxsBelowGasPrice ¶
RemoveTxsBelowGasPrice drops all transactions below the gas price
type Transactions ¶ added in v1.14.1
type Transactions []*types.Transaction
type TxPoolService ¶ added in v1.14.1
type TxPoolService interface { GetTransaction(hash common.Uint256) *types.Transaction GetTransactionStatus(hash common.Uint256) *TxStatus GetTxAmount() []uint32 GetTxList() []common.Uint256 GetGasPrice() uint64 AppendTransaction(sender SenderType, txn *types.Transaction) *TxResult AppendTransactionAsync(sender SenderType, txn *types.Transaction) }
type TxStatus ¶
type TxStatus struct { Hash common.Uint256 // transaction hash Attrs []*TXAttr // transaction's status }
TxStatus contains the attributes of a transaction
type UserNonceInfo ¶ added in v1.14.1
type VerifiedTx ¶ added in v1.14.1
type VerifiedTx struct { Tx *types.Transaction // transaction which has been verified VerifiedHeight uint32 Nonce uint64 }
func (*VerifiedTx) GetAttrs ¶ added in v1.14.1
func (self *VerifiedTx) GetAttrs() []*TXAttr
func (*VerifiedTx) IsVerfiyExpired ¶ added in v1.14.1
func (self *VerifiedTx) IsVerfiyExpired(height uint32) bool
type VerifyBlockReq ¶
type VerifyBlockReq struct { Height uint32 Txs []*types.Transaction }
VerifyBlockReq specifies that api that how to verify a block from consensus.
type VerifyBlockRsp ¶
type VerifyBlockRsp struct {
TxnPool []*VerifyTxResult
}
VerifyBlockRsp returns a verified result for VerifyBlockReq.
type VerifyTxResult ¶
type VerifyTxResult struct { Height uint32 Tx *types.Transaction ErrCode errors.ErrCode }
VerifyTxResult returns a single transaction's verified result.