common

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: LGPL-3.0 Imports: 14 Imported by: 37

Documentation

Overview

Package common provides constants, common types for other packages

Index

Constants

View Source
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 GetOngBalance added in v1.14.1

func GetOngBalance(account common.Address) (*big.Int, error)

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

type GetTxnPoolReq struct {
	ByCount bool
	Height  uint32
}

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

type TXPool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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 NewTxPool added in v1.14.1

func NewTxPool() *TXPool

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 (s *TXPool) CleanStaledEIPTx(height uint32)

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

func (tp *TXPool) GetTransactionCount() int

GetTransactionCount returns the tx number of the pool.

func (*TXPool) GetTransactionHashList added in v1.11.0

func (tp *TXPool) GetTransactionHashList() []common.Uint256

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

func (tp *TXPool) GetTxStatus(hash common.Uint256) *TxStatus

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) NextNonce added in v1.14.1

func (s *TXPool) NextNonce(addr common.Address) uint64

get next nonce from txpool

func (*TXPool) Remain added in v1.0.1

func (tp *TXPool) Remain() []*types.Transaction

returns the remaining tx list to cleanup

func (*TXPool) RemoveTxsBelowGasPrice

func (tp *TXPool) RemoveTxsBelowGasPrice(gasPrice uint64)

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 TxResult added in v1.0.1

type TxResult struct {
	Err  errors.ErrCode
	Hash common.Uint256
	Desc string
}

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 UserNonceInfo struct {
	Height uint32
	Nonce  uint64
}

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.

Jump to

Keyboard shortcuts

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