common

package
v2.0.1-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

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_WORKER_NUM   = 2                                // The max concurrent workers
	MAX_RCV_TXN_LEN  = MAX_WORKER_NUM * MAX_PENDING_TXN // The max length of the queue that server can hold
	MAX_RETRIES      = 0                                // The retry times to verify tx
	EXPIRE_INTERVAL  = 9                                // The timeout that verify tx
	STATELESS_MASK   = 0x1                              // The mask of stateless validator
	STATEFUL_MASK    = 0x2                              // The mask of stateful validator
	VERIFY_MASK      = STATELESS_MASK | STATEFUL_MASK   // The mask that indicates tx valid
	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
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorType

type ActorType uint8

ActorType enumerates the kind of actor

const (
	TxActor        ActorType // Actor that handles new transaction
	TxPoolActor              // Actor that handles consensus msg
	VerifyRspActor           // Actor that handles the response from valdiators
	NetActor                 // Actor to send msg to the net actor
	MaxActor
)

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 CheckTxnReq

type CheckTxnReq struct {
	Hash common.Uint256
}

CheckTxnReq specifies the api that how to check whether a transaction in the pool. Input: a transaction hash

type CheckTxnRsp

type CheckTxnRsp struct {
	Ok bool
}

CheckTxnRsp returns a value for the CheckTxnReq, if the transaction in the pool, value is true, or false.

type GetPendingTxnReq

type GetPendingTxnReq struct {
	ByCount bool
}

GetPendingTxnReq specifies the api that how to get a pending tx list in the pool.

type GetPendingTxnRsp

type GetPendingTxnRsp struct {
	Txs []*types.Transaction
}

GetPendingTxnRsp returns a transaction list for GetPendingTxnReq.

type GetTxnCountReq

type GetTxnCountReq struct {
}

GetTxnCountReq specifies the api that how to get the tx count

type GetTxnCountRsp

type GetTxnCountRsp struct {
	Count []uint32
}

GetTxnCountRsp returns current tx count, including pending, and verified

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 []*TXEntry
}

GetTxnPoolRsp returns a transaction list for GetTxnPoolReq.

type GetTxnReq

type GetTxnReq struct {
	Hash common.Uint256
}

GetTxnReq specifies the api that how to get the transaction. Input: a transaction hash

type GetTxnRsp

type GetTxnRsp struct {
	Txn *types.Transaction
}

GetTxnRsp returns a transaction for the specified tx hash.

type GetTxnStats

type GetTxnStats struct {
}

GetTxnStats specifies the api that how to get the tx statistics.

type GetTxnStatsRsp

type GetTxnStatsRsp struct {
	Count []uint64
}

GetTxnStatsRso returns the tx statistics.

type GetTxnStatusReq

type GetTxnStatusReq struct {
	Hash common.Uint256
}

GetTxnStatusReq specifies the api that how to get a transaction status. Input: a transaction hash.

type GetTxnStatusRsp

type GetTxnStatusRsp struct {
	Hash     common.Uint256
	TxStatus []*TXAttr
}

GetTxnStatusRsp returns a transaction status for GetTxnStatusReq. Output: a transaction hash and it's verified result.

type LB

type LB struct {
	Size     int
	WorkerID uint8
}

* Implement sort.Interface

type LBSlice

type LBSlice []LB

func (LBSlice) Len

func (this LBSlice) Len() int

func (LBSlice) Less

func (this LBSlice) Less(i, j int) bool

func (LBSlice) Swap

func (this LBSlice) Swap(i, j int)

type OrderByNetWorkFee

type OrderByNetWorkFee []*TXEntry

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
)

func (SenderType) Sender

func (sender SenderType) Sender() string

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 (*TXPool) AddTxList

func (tp *TXPool) AddTxList(txEntry *TXEntry) bool

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) CleanTransactionList

func (tp *TXPool) CleanTransactionList(txs []*types.Transaction) error

CleanTransactionList cleans the transaction list included in the ledger.

func (*TXPool) DelTxList

func (tp *TXPool) DelTxList(tx *types.Transaction) bool

DelTxList removes a single transaction from the pool.

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) GetTxPool

func (tp *TXPool) GetTxPool(byCount bool, height uint32) ([]*TXEntry,
	[]*types.Transaction)

GetTxPool 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

GetUnverifiedTxs 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) Init

func (tp *TXPool) Init()

Init creates a new transaction pool to gather.

func (*TXPool) Remain

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

Remain 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 TxReq

type TxReq struct {
	Tx         *types.Transaction
	Sender     SenderType
	TxResultCh chan *TxResult
}

TxReq specifies the api that how to submit a new transaction. Input: transacton and submitter type

type TxResult

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

type TxRsp

type TxRsp struct {
	Hash    common.Uint256
	ErrCode errors.ErrCode
}

TxRsp returns the result of submitting tx, including a transaction hash and error code.

type TxStatus

type TxStatus struct {
	Hash  common.Uint256 // transaction hash
	Attrs []*TXAttr      // transaction's status
}

TxStatus contains the attributes of a transaction

type TxnStatsType

type TxnStatsType uint8

TxnStatsType enumerates the kind of tx statistics

const (
	RcvStats       TxnStatsType // The count that the tx pool receive from the actor bus
	SuccessStats                // The count that the transactions are verified successfully
	FailureStats                // The count that the transactions are invalid
	DuplicateStats              // The count that the transactions are duplicated input
	SigErrStats                 // The count that the transactions' signature error
	StateErrStats               // The count that the transactions are invalid in database

	MaxStats
)

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