Documentation
¶
Index ¶
- Constants
- Variables
- func CheckGenesisConfig(conf *corepb.Genesis, consensus Consensus, block *Block) bool
- func InjectTxMapper(mapper TxMapper)
- func LoadGenesisConf(filePath string) (*corepb.Genesis, error)
- type AccountFrom
- type AccountPayer
- type AccountPoint
- type Block
- func (b *Block) AcceptTransaction(tx *Transaction) error
- func (b *Block) Atomic(batch func(block *Block) error) (execErr error, err error)
- func (b *Block) BeginBatch() error
- func (b *Block) CalcChildPrice() (common.Price, error)
- func (b *Block) Commit() error
- func (b *Block) CreateChildWithBlockData(bd *BlockData, consensus Consensus) (child *Block, err error)
- func (b *Block) ExecuteTransaction(tx *Transaction) (*Receipt, error)
- func (b *Block) Flush() error
- func (b *Block) FromBlockData(bd *BlockData, consensus Consensus, storage storage.Storage) error
- func (b *Block) GetBlockData() *BlockData
- func (b *Block) InitChild(coinbase common.Address) (*Block, error)
- func (b *Block) PayReward(parentSupply *util.Uint128) error
- func (b *Block) Prepare() error
- func (b *Block) RollBack() error
- func (b *Block) Seal() error
- func (b *Block) Sealed() bool
- func (b *Block) SetMintDynasty(parent *Block, consensus Consensus) error
- func (b *Block) SignThis(signer signature.Signature) error
- func (b *Block) State() *BlockState
- type BlockChain
- func (bc *BlockChain) BlockByHash(hash []byte) *Block
- func (bc *BlockChain) BlockByHeight(height uint64) (*Block, error)
- func (bc *BlockChain) BlockHashByHeight(height uint64) ([]byte, error)
- func (bc *BlockChain) ChainID() uint32
- func (bc *BlockChain) FindAncestorOnCanonical(block *Block, breakAtLIB bool) (*Block, error)
- func (bc *BlockChain) ForkChoice() (newTail *Block)
- func (bc *BlockChain) IsForkedBeforeLIB(block *Block) bool
- func (bc *BlockChain) LIB() *Block
- func (bc *BlockChain) MainTailBlock() *Block
- func (bc *BlockChain) PutVerifiedNewBlock(parent, child *Block) error
- func (bc *BlockChain) SetEventEmitter(emitter *event.Emitter)
- func (bc *BlockChain) SetLIB(newLIB *Block) error
- func (bc *BlockChain) SetTailBlock(newTail *Block) ([]*Block, []*Block, error)
- func (bc *BlockChain) Setup(genesis *corepb.Genesis, consensus Consensus, stor storage.Storage) error
- type BlockData
- func (bd *BlockData) AppendTransaction(tx *Transaction)
- func (bd *BlockData) CalcHash() ([]byte, error)
- func (bd *BlockData) Clone() (*BlockData, error)
- func (bd *BlockData) EmitBlockEvent(emitter *event.Emitter, eTopic string)
- func (bd *BlockData) EmitTxExecutionEvent(emitter *event.Emitter)
- func (bd *BlockData) FromBytes(bytes []byte) error
- func (bd *BlockData) FromProto(msg proto.Message) error
- func (bd *BlockData) Height() uint64
- func (bd *BlockData) SignThis(signer signature.Signature) error
- func (bd *BlockData) String() string
- func (bd *BlockData) ToBytes() ([]byte, error)
- func (bd *BlockData) ToProto() (proto.Message, error)
- func (bd *BlockData) Transactions() []*Transaction
- func (bd *BlockData) VerifyIntegrity() error
- type BlockHeader
- func (b *BlockHeader) AccStateRoot() []byte
- func (b *BlockHeader) CPUPrice() *util.Uint128
- func (b *BlockHeader) CPUUsage() uint64
- func (b *BlockHeader) ChainID() uint32
- func (b *BlockHeader) Coinbase() common.Address
- func (b *BlockHeader) DposRoot() []byte
- func (b *BlockHeader) Hash() []byte
- func (b *BlockHeader) HexHash() string
- func (b *BlockHeader) NetPrice() *util.Uint128
- func (b *BlockHeader) NetUsage() uint64
- func (b *BlockHeader) ParentHash() []byte
- func (b *BlockHeader) Proposer() (common.Address, error)
- func (b *BlockHeader) Reward() *util.Uint128
- func (b *BlockHeader) Sign() []byte
- func (b *BlockHeader) Supply() *util.Uint128
- func (b *BlockHeader) Timestamp() int64
- func (b *BlockHeader) TxStateRoot() []byte
- type BlockManager
- func (bm *BlockManager) BlockByHash(hash []byte) *Block
- func (bm *BlockManager) BlockByHeight(height uint64) (*Block, error)
- func (bm *BlockManager) BlockHashByHeight(height uint64) ([]byte, error)
- func (bm *BlockManager) BroadCast(bd *BlockData) error
- func (bm *BlockManager) ChainID() uint32
- func (bm *BlockManager) Consensus() Consensus
- func (bm *BlockManager) ForceLIB(b *Block) error
- func (bm *BlockManager) InjectEmitter(emitter *event.Emitter)
- func (bm *BlockManager) InjectSyncService(syncService SyncService)
- func (bm *BlockManager) InjectTransactionManager(tm *TransactionManager)
- func (bm *BlockManager) LIB() *Block
- func (bm *BlockManager) PushBlockData(bd *BlockData) error
- func (bm *BlockManager) PushBlockDataSync(bd *BlockData, timeLimit time.Duration) error
- func (bm *BlockManager) PushBlockDataSync2(ctx context.Context, bd *BlockData) error
- func (bm *BlockManager) PushCreatedBlock(b *Block) error
- func (bm *BlockManager) Setup(genesis *corepb.Genesis, stor storage.Storage, ns net.Service, ...) error
- func (bm *BlockManager) Start()
- func (bm *BlockManager) Stop()
- func (bm *BlockManager) TailBlock() *Block
- type BlockPool
- func (bp *BlockPool) FindChildren(block HashableBlock) (childBlocks []HashableBlock)
- func (bp *BlockPool) FindParent(block HashableBlock) HashableBlock
- func (bp *BlockPool) FindUnlinkedAncestor(block HashableBlock) HashableBlock
- func (bp *BlockPool) Has(block HashableBlock) bool
- func (bp *BlockPool) Push(block HashableBlock) error
- func (bp *BlockPool) Remove(block HashableBlock)
- type BlockState
- func (bs *BlockState) AccountsRoot() ([]byte, error)
- func (bs *BlockState) AddVotePowerToCandidate(candidateID []byte, amount *util.Uint128) error
- func (bs *BlockState) CPUPrice() *util.Uint128
- func (bs *BlockState) CPUUsage() uint64
- func (bs *BlockState) Clone() (*BlockState, error)
- func (bs *BlockState) DelAccountAlias(alias string, addr common.Address) error
- func (bs *BlockState) DposRoot() ([]byte, error)
- func (bs *BlockState) DposState() *dState.State
- func (bs *BlockState) GetAccount(addr common.Address) (*coreState.Account, error)
- func (bs *BlockState) GetAccountByAlias(alias string) (*coreState.Account, error)
- func (bs *BlockState) GetTx(txHash []byte) (*Transaction, error)
- func (bs *BlockState) NetPrice() *util.Uint128
- func (bs *BlockState) NetUsage() uint64
- func (bs *BlockState) Price() common.Price
- func (bs *BlockState) PutAccount(acc *coreState.Account) error
- func (bs *BlockState) PutAccountAlias(alias string, addr common.Address) error
- func (bs *BlockState) PutTx(tx *Transaction) error
- func (bs *BlockState) Reward() *util.Uint128
- func (bs *BlockState) SetReward(reward *util.Uint128)
- func (bs *BlockState) SetSupply(supply *util.Uint128)
- func (bs *BlockState) SetTimestamp(timestamp int64)
- func (bs *BlockState) String() string
- func (bs *BlockState) SubVotePowerToCandidate(candidateID []byte, amount *util.Uint128) error
- func (bs *BlockState) Supply() *util.Uint128
- func (bs *BlockState) Timestamp() int64
- func (bs *BlockState) TxsRoot() ([]byte, error)
- type BlockTestWrap
- func (b *BlockTestWrap) Clone() (*BlockTestWrap, error)
- func (b *BlockTestWrap) InitChild(coinbase common.Address) (*BlockTestWrap, error)
- func (b *BlockTestWrap) SetAccStateRoot(accStateRoot []byte)
- func (b *BlockTestWrap) SetCPUPrice(cpuPrice *util.Uint128)
- func (b *BlockTestWrap) SetChainID(chainID uint32)
- func (b *BlockTestWrap) SetCoinbase(coinbase common.Address)
- func (b *BlockTestWrap) SetDposRoot(dposRoot []byte)
- func (b *BlockTestWrap) SetHash(hash []byte)
- func (b *BlockTestWrap) SetHeight(height uint64)
- func (b *BlockTestWrap) SetNetPrice(netPrice *util.Uint128)
- func (b *BlockTestWrap) SetParentHash(parentHash []byte)
- func (b *BlockTestWrap) SetReward(reward *util.Uint128)
- func (b *BlockTestWrap) SetSealed(sealed bool)
- func (b *BlockTestWrap) SetSign(sign []byte)
- func (b *BlockTestWrap) SetSupply(supply *util.Uint128)
- func (b *BlockTestWrap) SetTimestamp(timestamp int64)
- func (b *BlockTestWrap) SetTransactions(txs []*Transaction) error
- func (b *BlockTestWrap) SetTxStateRoot(txStateRoot []byte)
- type Canonical
- type Consensus
- type ExecutableTx
- type FutureTransactionPool
- func (pool *FutureTransactionPool) Del(tx *TxContext) (deleted bool)
- func (pool *FutureTransactionPool) Get(hash []byte) *TxContext
- func (pool *FutureTransactionPool) Len() int
- func (pool *FutureTransactionPool) PeekLowerNonce(addr common.Address) *TxContext
- func (pool *FutureTransactionPool) PopWithNonceUpperLimit(addr common.Address, nonceUpperLimit uint64) *TxContext
- func (pool *FutureTransactionPool) Prune(addr common.Address, nonceLowerLimit uint64, ...)
- func (pool *FutureTransactionPool) Set(tx *TxContext) (evicted *TxContext)
- type HashableBlock
- type PendingTransactionPool
- func (pool *PendingTransactionPool) Get(hash []byte) *Transaction
- func (pool *PendingTransactionPool) Len() int
- func (pool *PendingTransactionPool) Next() *Transaction
- func (pool *PendingTransactionPool) NonceUpperLimit(acc *corestate.Account) uint64
- func (pool *PendingTransactionPool) Prune(addr common.Address, nonceLowerLimit uint64)
- func (pool *PendingTransactionPool) PushOrReplace(tx *TxContext, accState *corestate.Account, payerState *corestate.Account, ...) error
- func (pool *PendingTransactionPool) ResetSelector()
- func (pool *PendingTransactionPool) SetRequiredNonce(addr common.Address, nonce uint64)
- type Receipt
- func (r *Receipt) Bandwidth() *common.Bandwidth
- func (r *Receipt) CPUUsage() uint64
- func (r *Receipt) Equal(obj *Receipt) bool
- func (r *Receipt) Error() []byte
- func (r *Receipt) Executed() bool
- func (r *Receipt) FromProto(msg proto.Message) error
- func (r *Receipt) Height() uint64
- func (r *Receipt) NetUsage() uint64
- func (r *Receipt) Points() *util.Uint128
- func (r *Receipt) SetCPUUsage(cpuUsage uint64)
- func (r *Receipt) SetError(error []byte)
- func (r *Receipt) SetExecuted(executed bool)
- func (r *Receipt) SetHeight(height uint64)
- func (r *Receipt) SetNetUsage(netUsage uint64)
- func (r *Receipt) SetPoints(points *util.Uint128)
- func (r *Receipt) SetTimestamp(timestamp int64)
- func (r *Receipt) String() string
- func (r *Receipt) Timestamp() int64
- func (r *Receipt) ToProto() (proto.Message, error)
- type SyncService
- type Transaction
- func (t *Transaction) CalcHash() ([]byte, error)
- func (t *Transaction) ChainID() uint32
- func (t *Transaction) From() common.Address
- func (t *Transaction) FromProto(msg proto.Message) error
- func (t *Transaction) HasPayer() bool
- func (t *Transaction) Hash() []byte
- func (t *Transaction) HexHash() string
- func (t *Transaction) Nonce() uint64
- func (t *Transaction) Payer() common.Address
- func (t *Transaction) PayerOrFrom() common.Address
- func (t *Transaction) PayerSign() []byte
- func (t *Transaction) Payload() []byte
- func (t *Transaction) Receipt() *Receipt
- func (t *Transaction) SetReceipt(receipt *Receipt)
- func (t *Transaction) Sign() []byte
- func (t *Transaction) SignByPayer(signer signature.Signature) error
- func (t *Transaction) SignGenesis() error
- func (t *Transaction) SignThis(key signature.PrivateKey) error
- func (t *Transaction) Size() (int, error)
- func (t *Transaction) String() string
- func (t *Transaction) To() common.Address
- func (t *Transaction) ToBytes() ([]byte, error)
- func (t *Transaction) ToProto() (proto.Message, error)
- func (t *Transaction) TriggerAccEvent(e *event.Emitter, eType string)
- func (t *Transaction) TriggerEvent(e *event.Emitter, eTopic string)
- func (t *Transaction) TxType() string
- func (t *Transaction) Value() *util.Uint128
- func (t *Transaction) VerifyIntegrity(chainID uint32) error
- type TransactionManager
- func (tm *TransactionManager) Broadcast(tx *Transaction) error
- func (tm *TransactionManager) DelByAddressNonce(addr common.Address, nonce uint64) error
- func (tm *TransactionManager) Get(hash []byte) *Transaction
- func (tm *TransactionManager) InjectEmitter(emitter *event.Emitter)
- func (tm *TransactionManager) Len() int
- func (tm *TransactionManager) Next() *Transaction
- func (tm *TransactionManager) Push(tx *Transaction) error
- func (tm *TransactionManager) PushAndBroadcast(tx *Transaction) error
- func (tm *TransactionManager) ResetTransactionSelector()
- func (tm *TransactionManager) SetRequiredNonce(addr common.Address, nonce uint64)
- func (tm *TransactionManager) Setup(canon Canonical, ns net.Service)
- func (tm *TransactionManager) Start()
- func (tm *TransactionManager) Stop()
- type TransactionState
- type TransactionTemplateParam
- type TransactionTestWrap
- func (t *TransactionTestWrap) Clone() *TransactionTestWrap
- func (t *TransactionTestWrap) SetChainID(chainID uint32)
- func (t *TransactionTestWrap) SetFrom(from common.Address)
- func (t *TransactionTestWrap) SetHash(hash []byte)
- func (t *TransactionTestWrap) SetNonce(nonce uint64)
- func (t *TransactionTestWrap) SetPayer(payer common.Address)
- func (t *TransactionTestWrap) SetPayerSign(payerSign []byte)
- func (t *TransactionTestWrap) SetPayload(payload []byte)
- func (t *TransactionTestWrap) SetReceipt(receipt *Receipt)
- func (t *TransactionTestWrap) SetSign(sign []byte)
- func (t *TransactionTestWrap) SetTo(to common.Address)
- func (t *TransactionTestWrap) SetTxType(txType string)
- func (t *TransactionTestWrap) SetValue(value *util.Uint128)
- type TxContext
- type TxMapper
Constants ¶
const ( MessageTypeNewBlock = "newblock" MessageTypeRequestBlock = "rqstblock" MessageTypeResponseBlock = "respblock" )
Block's message types.
const ( NumberOfBlocksInSingleTimeWindow = 201600 // 7 * 86400 / 3 (time window: 7days, block interval: 3 sec) CPULimit = 3000000 // 1000 TPS (block interval: 3 sec, transfer tx: 1000 ) NetLimit = 3000000 // 3MB )
Points limit per block
const ( ThresholdRatioNum = 5 ThresholdRatioDenom = 10 )
Points Price related defaults
const InflationRoundDown = 10000000000 // 1e10
InflationRoundDown is constant for round down reward
const (
// MaxPendingByAccount is the max number of pending transactions per account
MaxPendingByAccount = 4096
)
const (
MessageTypeNewTx = "newtx"
)
Transaction's message types.
Variables ¶
var ( // GenesisParentHash is hash of genesis block's parent hash GenesisParentHash = make([]byte, common.HashLength) // GenesisTimestamp is timestamp of genesis block GenesisTimestamp = int64(0) // GenesisCoinbase coinbase address of genesis block GenesisCoinbase, _ = common.HexToAddress("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") // GenesisHeight is height of genesis block GenesisHeight = uint64(1) )
var ( PriceMinimumRate = big.NewRat(1, 100) PriceIncreaseRate = big.NewRat(105, 100) PriceDecreaseRate = big.NewRat(95, 100) )
Points Price related defaults
var ( ErrNotFound = storage.ErrKeyNotFound ErrFailedValidateHeightAndHeight = errors.New("failed to verify height and timestamp by lib") ErrCannotRemoveBlockOnCanonical = errors.New("cannot remove block on canonical chain") ErrDuplicatedBlock = errors.New("duplicated block") ErrDuplicatedTransaction = errors.New("duplicated transaction") ErrGenesisNotMatch = errors.New("genesis block does not match") ErrInvalidProtoToBlock = errors.New("protobuf message cannot be converted into Block") ErrInvalidProtoToBlockHeader = errors.New("protobuf message cannot be converted into BlockHeader") ErrInvalidBlockChainID = errors.New("invalid block chainID") ErrInvalidBlockToProto = errors.New("block cannot be converted into proto") ErrInvalidBlockHash = errors.New("invalid block hash") ErrInvalidTimestamp = errors.New("child block's timestamp is smaller than parent block's") ErrBlockAlreadySealed = errors.New("cannot seal an already sealed block") ErrNilArgument = errors.New("argument(s) is nil") ErrMissingParentBlock = errors.New("cannot find the block's parent block in storage") ErrBlockNotExist = errors.New("block not exist") ErrBlockNotSealed = errors.New("block should be sealed first to be signed") ErrInvalidBlockHeight = errors.New("block height should be one block higher than the parent") ErrInvalidBlockReward = errors.New("invalid reward") ErrInvalidBlockSupply = errors.New("invalid supply") ErrInvalidBlockAccountsRoot = errors.New("invalid account state root hash") ErrInvalidBlockTxsRoot = errors.New("invalid transactions state root hash") ErrInvalidBlockDposRoot = errors.New("invalid block dpos root hash") ErrTooOldTransaction = errors.New("transaction timestamp is too old") ErrBlockSignatureNotExist = errors.New("block signature does not exist in the blockheader") ErrFailedToDirectPush = errors.New("cannot direct push to chain") ErrExceedBlockMaxCPUUsage = errors.New("transaction exceeds block's max cpu usage") ErrExceedBlockMaxNetUsage = errors.New("transaction exceeds block's max net usage") ErrNoTransactionReceipt = errors.New("failed to load transaction receipt") ErrWrongReceipt = errors.New("transaction receipt is wrong in block data") ErrInvalidCPUPrice = errors.New("invalid cpu price") ErrInvalidNetPrice = errors.New("invalid Net price") ErrInvalidCPUUsage = errors.New("block uses too much cpu bandwidth") ErrInvalidNetUsage = errors.New("block ueses too much net bandwidth") ErrWrongCPUUsage = errors.New("block cpu usage is not matched with sum of tx cpu usage") ErrWrongNetUsage = errors.New("block net usage is not matched with sum of tx net usage") ErrInvalidAlias = errors.New("invalid alias") ErrInvalidHash = errors.New("invalid hash") ErrFailedToReplacePendingTx = errors.New("cannot replace pending transaction in 10 minute") ErrBlockExecutionTimeout = errors.New("block is not executed on time") ErrAlreadyOnTheChain = errors.New("block is already on the chain") ErrCannotFindParentBlockOnTheChain = errors.New("cannot find parent block on the chain") ErrForkedBeforeLIB = errors.New("block is forked before LIB") ErrInvalidBlock = errors.New("invalid block") ErrSameDynasty = errors.New("new block is in same dynasty with parent block") ErrStakingNotEnough = errors.New("staking is not enough") ErrPointNotEnough = errors.New("points are not enough") ErrCannotConvertReceipt = errors.New("proto message cannot be converted into Receipt") ErrInvalidReceiptToProto = errors.New("receipt cannot be converted into proto") ErrCannotConvertTransaction = errors.New("proto message cannot be converted into Transaction") ErrTransactionSignatureNotExist = errors.New("signature does not exist in the tx") ErrPayerSignatureNotExist = errors.New("payer signature does not exist in the tx") ErrInvalidTransactionHash = errors.New("invalid transaction hash") ErrInvalidTransactionType = errors.New("invalid transaction type") ErrCannotRecoverPayer = errors.New("failed to recover payer from payer sign") ErrInvalidTxChainID = errors.New("invalid transaction chainID") ErrGenesisSignShouldNotExist = errors.New("genesis sign should not exist") ErrNotGenesisBlock = errors.New("block is not genesis") ErrGenesisDistributionAllowedOnce = errors.New("genesis Distribution is allowed once per account") ErrAtomicError = errors.New("failed to process atomic operation") ErrNonceNotExecutable = errors.New("transaction nonce not executable") ErrCoinbaseNotSet = errors.New("coinbase is not set") )
Error types of core package.
var (
AllowReplacePendingDuration = 10 * time.Minute
)
Parameters for transaction manager
var (
ErrNonceNotAcceptable = errors.New("nonce not acceptable")
)
TODO move error code
var InflationRate = big.NewRat(464, 100000000000) // 4.64e-09
InflationRate is rate for reward
Functions ¶
func CheckGenesisConfig ¶
CheckGenesisConfig checks if block and genesis configuration match
func InjectTxMapper ¶
func InjectTxMapper(mapper TxMapper)
InjectTxMapper injects TxMapper dependencies.
Types ¶
type AccountFrom ¶
type AccountFrom struct {
// contains filtered or unexported fields
}
AccountFrom manages account's pending transactions.
type AccountPayer ¶
type AccountPayer struct {
// contains filtered or unexported fields
}
AccountPayer manages payers bandwidth.
type AccountPoint ¶
type AccountPoint struct {
// contains filtered or unexported fields
}
AccountPoint manages point of accounts.
type Block ¶
type Block struct { *BlockData // contains filtered or unexported fields }
Block represents block with actual state tries
func NewGenesisBlock ¶
func NewGenesisBlock(conf *corepb.Genesis, consensus Consensus, stor storage.Storage) (*Block, error)
NewGenesisBlock generates genesis block TODO config verification, tx.verifyIntegrity, height, timestamp, chainid, ...
func (*Block) AcceptTransaction ¶
func (b *Block) AcceptTransaction(tx *Transaction) error
AcceptTransaction accepts a transaction.
func (*Block) Atomic ¶
Atomic executes a given function in atomic way. execErr is an return error of a given function. err is an error of atomic processing.
func (*Block) BeginBatch ¶
BeginBatch makes block state update possible
func (*Block) CalcChildPrice ¶
CalcChildPrice calculate child block's price
func (*Block) CreateChildWithBlockData ¶
func (b *Block) CreateChildWithBlockData(bd *BlockData, consensus Consensus) (child *Block, err error)
CreateChildWithBlockData returns child block by executing block data on parent block.
func (*Block) ExecuteTransaction ¶
func (b *Block) ExecuteTransaction(tx *Transaction) (*Receipt, error)
ExecuteTransaction on given block state
func (*Block) FromBlockData ¶
FromBlockData converts block data to block.
func (*Block) GetBlockData ¶
GetBlockData returns data part of block
func (*Block) SetMintDynasty ¶
SetMintDynasty sets mint dynasty of block's timestamp.
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
BlockChain manages blockchain structure.
func NewBlockChain ¶
func NewBlockChain(cfg *medletpb.Config) (*BlockChain, error)
NewBlockChain return new BlockChain instance
func (*BlockChain) BlockByHash ¶
func (bc *BlockChain) BlockByHash(hash []byte) *Block
BlockByHash returns a block of given hash.
func (*BlockChain) BlockByHeight ¶
func (bc *BlockChain) BlockByHeight(height uint64) (*Block, error)
BlockByHeight returns a block of given height.
func (*BlockChain) BlockHashByHeight ¶
func (bc *BlockChain) BlockHashByHeight(height uint64) ([]byte, error)
BlockHashByHeight returns a block hash of given height.
func (*BlockChain) FindAncestorOnCanonical ¶
func (bc *BlockChain) FindAncestorOnCanonical(block *Block, breakAtLIB bool) (*Block, error)
FindAncestorOnCanonical finds most recent ancestor block in canonical chain.
func (*BlockChain) ForkChoice ¶
func (bc *BlockChain) ForkChoice() (newTail *Block)
ForkChoice chooses new tail of canonical chain.
func (*BlockChain) IsForkedBeforeLIB ¶
func (bc *BlockChain) IsForkedBeforeLIB(block *Block) bool
IsForkedBeforeLIB checks if the block is forked before LIB.
func (*BlockChain) MainTailBlock ¶
func (bc *BlockChain) MainTailBlock() *Block
MainTailBlock returns MainTailBlock.
func (*BlockChain) PutVerifiedNewBlock ¶
func (bc *BlockChain) PutVerifiedNewBlock(parent, child *Block) error
PutVerifiedNewBlock put verified block on the chain
func (*BlockChain) SetEventEmitter ¶
func (bc *BlockChain) SetEventEmitter(emitter *event.Emitter)
SetEventEmitter set emitter to blockchian
func (*BlockChain) SetTailBlock ¶
func (bc *BlockChain) SetTailBlock(newTail *Block) ([]*Block, []*Block, error)
SetTailBlock sets tail block.
type BlockData ¶
type BlockData struct { *BlockHeader // contains filtered or unexported fields }
BlockData represents a block
func (*BlockData) AppendTransaction ¶
func (bd *BlockData) AppendTransaction(tx *Transaction)
AppendTransaction append transaction to block data (only use on making block)
func (*BlockData) EmitBlockEvent ¶
EmitBlockEvent emits block related event
func (*BlockData) EmitTxExecutionEvent ¶
EmitTxExecutionEvent emits events of txs in the block
func (*BlockData) Transactions ¶
func (bd *BlockData) Transactions() []*Transaction
Transactions returns txs in block
func (*BlockData) VerifyIntegrity ¶
VerifyIntegrity verifies block integrity.
type BlockHeader ¶
type BlockHeader struct {
// contains filtered or unexported fields
}
BlockHeader is block header
func (*BlockHeader) AccStateRoot ¶
func (b *BlockHeader) AccStateRoot() []byte
AccStateRoot returns block header's accStateRoot
func (*BlockHeader) CPUPrice ¶
func (b *BlockHeader) CPUPrice() *util.Uint128
CPUPrice returns cpuPrice
func (*BlockHeader) Coinbase ¶
func (b *BlockHeader) Coinbase() common.Address
Coinbase returns coinbase
func (*BlockHeader) DposRoot ¶
func (b *BlockHeader) DposRoot() []byte
DposRoot returns block header's dposRoot
func (*BlockHeader) HexHash ¶
func (b *BlockHeader) HexHash() string
HexHash returns block hex encoded header's hash
func (*BlockHeader) NetPrice ¶
func (b *BlockHeader) NetPrice() *util.Uint128
NetPrice returns netPrice
func (*BlockHeader) ParentHash ¶
func (b *BlockHeader) ParentHash() []byte
ParentHash returns block header's parent hash
func (*BlockHeader) Proposer ¶
func (b *BlockHeader) Proposer() (common.Address, error)
Proposer returns proposer address from block sign
func (*BlockHeader) Timestamp ¶
func (b *BlockHeader) Timestamp() int64
Timestamp returns timestamp of block
func (*BlockHeader) TxStateRoot ¶
func (b *BlockHeader) TxStateRoot() []byte
TxStateRoot returns block header's txsRoot
type BlockManager ¶
type BlockManager struct {
// contains filtered or unexported fields
}
BlockManager handles all logic related to BlockChain and BlockPool.
func NewBlockManager ¶
func NewBlockManager(cfg *medletpb.Config) (*BlockManager, error)
NewBlockManager returns BlockManager.
func (*BlockManager) BlockByHash ¶
func (bm *BlockManager) BlockByHash(hash []byte) *Block
BlockByHash returns the block contained in the chain by hash.
func (*BlockManager) BlockByHeight ¶
func (bm *BlockManager) BlockByHeight(height uint64) (*Block, error)
BlockByHeight returns the block contained in the chain by height.
func (*BlockManager) BlockHashByHeight ¶
func (bm *BlockManager) BlockHashByHeight(height uint64) ([]byte, error)
BlockHashByHeight returns the hash of the block contaied in the chain by height.
func (*BlockManager) BroadCast ¶
func (bm *BlockManager) BroadCast(bd *BlockData) error
BroadCast broadcasts BlockData to network.
func (*BlockManager) ChainID ¶
func (bm *BlockManager) ChainID() uint32
ChainID return BlockChain.ChainID
func (*BlockManager) Consensus ¶
func (bm *BlockManager) Consensus() Consensus
Consensus returns consensus
func (*BlockManager) ForceLIB ¶
func (bm *BlockManager) ForceLIB(b *Block) error
ForceLIB set LIB force
func (*BlockManager) InjectEmitter ¶
func (bm *BlockManager) InjectEmitter(emitter *event.Emitter)
InjectEmitter inject emitter generated from medlet to block manager
func (*BlockManager) InjectSyncService ¶
func (bm *BlockManager) InjectSyncService(syncService SyncService)
InjectSyncService inject sync service generated from medlet to block manager
func (*BlockManager) InjectTransactionManager ¶
func (bm *BlockManager) InjectTransactionManager(tm *TransactionManager)
InjectTransactionManager inject transaction manager from medlet to block manager
func (*BlockManager) LIB ¶
func (bm *BlockManager) LIB() *Block
LIB returns latest irreversible block of the chain.
func (*BlockManager) PushBlockData ¶
func (bm *BlockManager) PushBlockData(bd *BlockData) error
PushBlockData pushes block data.
func (*BlockManager) PushBlockDataSync ¶
func (bm *BlockManager) PushBlockDataSync(bd *BlockData, timeLimit time.Duration) error
PushBlockDataSync pushes block to distributor and wait for execution Warning! - Use this method only for test for time efficiency.
func (*BlockManager) PushBlockDataSync2 ¶
func (bm *BlockManager) PushBlockDataSync2(ctx context.Context, bd *BlockData) error
PushBlockDataSync2 pushes block to distributor and wait for execution Warning! - Use this method only for test for time efficiency.
func (*BlockManager) PushCreatedBlock ¶
func (bm *BlockManager) PushCreatedBlock(b *Block) error
PushCreatedBlock push block to block chain without execution and verification (only used for self made block)
func (*BlockManager) Setup ¶
func (bm *BlockManager) Setup(genesis *corepb.Genesis, stor storage.Storage, ns net.Service, consensus Consensus) error
Setup sets up BlockManager.
func (*BlockManager) TailBlock ¶
func (bm *BlockManager) TailBlock() *Block
TailBlock getter for mainTailBlock
type BlockPool ¶
type BlockPool struct {
// contains filtered or unexported fields
}
BlockPool is a pool of all received blocks from network.
func NewBlockPool ¶
NewBlockPool returns BlockPool.
func (*BlockPool) FindChildren ¶
func (bp *BlockPool) FindChildren(block HashableBlock) (childBlocks []HashableBlock)
FindChildren finds children blocks.
func (*BlockPool) FindParent ¶
func (bp *BlockPool) FindParent(block HashableBlock) HashableBlock
FindParent finds parent block.
func (*BlockPool) FindUnlinkedAncestor ¶
func (bp *BlockPool) FindUnlinkedAncestor(block HashableBlock) HashableBlock
FindUnlinkedAncestor finds block's unlinked ancestor in BlockPool.
func (*BlockPool) Has ¶
func (bp *BlockPool) Has(block HashableBlock) bool
Has returns true if BlockPool contains block.
func (*BlockPool) Push ¶
func (bp *BlockPool) Push(block HashableBlock) error
Push links the block with parent and children blocks and push to the BlockPool.
func (*BlockPool) Remove ¶
func (bp *BlockPool) Remove(block HashableBlock)
Remove removes block in BlockPool.
type BlockState ¶
type BlockState struct {
// contains filtered or unexported fields
}
BlockState is block state
func NewBlockState ¶
NewBlockState creates new block state.
func (*BlockState) AccountsRoot ¶
func (bs *BlockState) AccountsRoot() ([]byte, error)
AccountsRoot returns account state root
func (*BlockState) AddVotePowerToCandidate ¶
func (bs *BlockState) AddVotePowerToCandidate(candidateID []byte, amount *util.Uint128) error
AddVotePowerToCandidate add vote power to candidate
func (*BlockState) CPUPrice ¶
func (bs *BlockState) CPUPrice() *util.Uint128
CPUPrice returns cpuPrice
func (*BlockState) DelAccountAlias ¶
func (bs *BlockState) DelAccountAlias(alias string, addr common.Address) error
DelAccountAlias delete alias information from account state
func (*BlockState) DposRoot ¶
func (bs *BlockState) DposRoot() ([]byte, error)
DposRoot returns dpos state root
func (*BlockState) DposState ¶
func (bs *BlockState) DposState() *dState.State
DposState returns dpos state in state
func (*BlockState) GetAccount ¶
GetAccount returns account in state
func (*BlockState) GetAccountByAlias ¶
func (bs *BlockState) GetAccountByAlias(alias string) (*coreState.Account, error)
GetAccountByAlias returns account by alias name
func (*BlockState) GetTx ¶
func (bs *BlockState) GetTx(txHash []byte) (*Transaction, error)
GetTx get tx from transaction state
func (*BlockState) NetPrice ¶
func (bs *BlockState) NetPrice() *util.Uint128
NetPrice returns netPrice
func (*BlockState) Price ¶
func (bs *BlockState) Price() common.Price
Price returns cpu price and net price
func (*BlockState) PutAccount ¶
func (bs *BlockState) PutAccount(acc *coreState.Account) error
PutAccount put account to state
func (*BlockState) PutAccountAlias ¶
func (bs *BlockState) PutAccountAlias(alias string, addr common.Address) error
PutAccountAlias set alias name for account
func (*BlockState) Reward ¶
func (bs *BlockState) Reward() *util.Uint128
Reward returns reward in state
func (*BlockState) SetReward ¶
func (bs *BlockState) SetReward(reward *util.Uint128)
SetReward sets reward.
func (*BlockState) SetSupply ¶
func (bs *BlockState) SetSupply(supply *util.Uint128)
SetSupply sets supply.
func (*BlockState) SetTimestamp ¶
func (bs *BlockState) SetTimestamp(timestamp int64)
SetTimestamp sets timestamp
func (*BlockState) String ¶
func (bs *BlockState) String() string
String returns stringified blocks state
func (*BlockState) SubVotePowerToCandidate ¶
func (bs *BlockState) SubVotePowerToCandidate(candidateID []byte, amount *util.Uint128) error
SubVotePowerToCandidate subtract vote power from candidate
func (*BlockState) Supply ¶
func (bs *BlockState) Supply() *util.Uint128
Supply returns supply in state
func (*BlockState) TxsRoot ¶
func (bs *BlockState) TxsRoot() ([]byte, error)
TxsRoot returns transaction state root
type BlockTestWrap ¶
type BlockTestWrap struct {
*Block
}
BlockTestWrap wraps Block and exports setters.
func (*BlockTestWrap) Clone ¶
func (b *BlockTestWrap) Clone() (*BlockTestWrap, error)
Clone copies block.
func (*BlockTestWrap) InitChild ¶
func (b *BlockTestWrap) InitChild(coinbase common.Address) (*BlockTestWrap, error)
InitChild wraps block's InitChild.
func (*BlockTestWrap) SetAccStateRoot ¶
func (b *BlockTestWrap) SetAccStateRoot(accStateRoot []byte)
SetAccStateRoot set block header's accStateRoot
func (*BlockTestWrap) SetCPUPrice ¶
func (b *BlockTestWrap) SetCPUPrice(cpuPrice *util.Uint128)
SetCPUPrice sets cpuPrice
func (*BlockTestWrap) SetChainID ¶
func (b *BlockTestWrap) SetChainID(chainID uint32)
SetChainID sets chainID
func (*BlockTestWrap) SetCoinbase ¶
func (b *BlockTestWrap) SetCoinbase(coinbase common.Address)
SetCoinbase set coinbase
func (*BlockTestWrap) SetDposRoot ¶
func (b *BlockTestWrap) SetDposRoot(dposRoot []byte)
SetDposRoot set block header's dposRoot
func (*BlockTestWrap) SetHash ¶
func (b *BlockTestWrap) SetHash(hash []byte)
SetHash set block header's hash
func (*BlockTestWrap) SetHeight ¶
func (b *BlockTestWrap) SetHeight(height uint64)
SetHeight sets height.
func (*BlockTestWrap) SetNetPrice ¶
func (b *BlockTestWrap) SetNetPrice(netPrice *util.Uint128)
SetNetPrice sets netPrice
func (*BlockTestWrap) SetParentHash ¶
func (b *BlockTestWrap) SetParentHash(parentHash []byte)
SetParentHash set block header's parent hash
func (*BlockTestWrap) SetReward ¶
func (b *BlockTestWrap) SetReward(reward *util.Uint128)
SetReward sets reward
func (*BlockTestWrap) SetSealed ¶
func (b *BlockTestWrap) SetSealed(sealed bool)
SetSealed set sealed
func (*BlockTestWrap) SetSupply ¶
func (b *BlockTestWrap) SetSupply(supply *util.Uint128)
SetSupply sets supply
func (*BlockTestWrap) SetTimestamp ¶
func (b *BlockTestWrap) SetTimestamp(timestamp int64)
SetTimestamp sets timestamp of block
func (*BlockTestWrap) SetTransactions ¶
func (b *BlockTestWrap) SetTransactions(txs []*Transaction) error
SetTransactions sets transactions TO BE REMOVED: For test without block pool
func (*BlockTestWrap) SetTxStateRoot ¶
func (b *BlockTestWrap) SetTxStateRoot(txStateRoot []byte)
SetTxStateRoot set block header's txsRoot
type Canonical ¶
type Canonical interface {
TailBlock() *Block
}
Canonical is an interface of tail block in canonical chain.
type Consensus ¶
type Consensus interface { NewConsensusState(dposRootBytes []byte, stor storage.Storage) (*dState.State, error) DynastySize() int MakeMintDynasty(ts int64, parentState *BlockState) ([]common.Address, error) VerifyHeightAndTimestamp(lib, bd *BlockData) error MissingBlocks(lib, bd *BlockData) uint64 VerifyInterval(bd *BlockData, parent *Block) error VerifyProposer(b *Block) error FindLIB(bc *BlockChain) (newLIB *Block) FindMintProposer(ts int64, parent *Block) (common.Address, error) }
Consensus is an interface of consensus model
type ExecutableTx ¶
type ExecutableTx interface { Execute(b *Block) error Bandwidth() *common.Bandwidth PointChange() (neg bool, abs *util.Uint128) RecoverFrom() (common.Address, error) }
ExecutableTx interface for execute transaction on state
type FutureTransactionPool ¶
type FutureTransactionPool struct {
// contains filtered or unexported fields
}
FutureTransactionPool is a pool of all future transactions.
func NewFutureTransactionPool ¶
func NewFutureTransactionPool(size int) *FutureTransactionPool
NewFutureTransactionPool returns FutureTransactionPool.
func (*FutureTransactionPool) Del ¶
func (pool *FutureTransactionPool) Del(tx *TxContext) (deleted bool)
Del deletes a transaction
func (*FutureTransactionPool) Get ¶
func (pool *FutureTransactionPool) Get(hash []byte) *TxContext
Get returns a transaction by hash.
func (*FutureTransactionPool) Len ¶
func (pool *FutureTransactionPool) Len() int
Len returns size of pool.
func (*FutureTransactionPool) PeekLowerNonce ¶
func (pool *FutureTransactionPool) PeekLowerNonce(addr common.Address) *TxContext
PeekLowerNonce returns a transaction with lowest nonce for given address.
func (*FutureTransactionPool) PopWithNonceUpperLimit ¶
func (pool *FutureTransactionPool) PopWithNonceUpperLimit(addr common.Address, nonceUpperLimit uint64) *TxContext
PopWithNonceUpperLimit pop a transaction if there is a transaction whose nonce is lower than given limit.
func (*FutureTransactionPool) Prune ¶
func (pool *FutureTransactionPool) Prune(addr common.Address, nonceLowerLimit uint64, deleteCallback func(tx *TxContext))
Prune prunes pool by given nonce of lower limit.
func (*FutureTransactionPool) Set ¶
func (pool *FutureTransactionPool) Set(tx *TxContext) (evicted *TxContext)
Set sets a transaction and returns an evicted transaction if there is any.
type HashableBlock ¶
HashableBlock is an interface that can get its own or parent's hash.
type PendingTransactionPool ¶
type PendingTransactionPool struct {
// contains filtered or unexported fields
}
PendingTransactionPool struct manages pending transactions by account.
func NewPendingTransactionPool ¶
func NewPendingTransactionPool() *PendingTransactionPool
NewPendingTransactionPool creates PendingTransactionPool.
func (*PendingTransactionPool) Get ¶
func (pool *PendingTransactionPool) Get(hash []byte) *Transaction
Get gets a transaction.
func (*PendingTransactionPool) Len ¶
func (pool *PendingTransactionPool) Len() int
Len returns size of pool.
func (*PendingTransactionPool) Next ¶
func (pool *PendingTransactionPool) Next() *Transaction
Next returns a transaction to process in round-robin order
func (*PendingTransactionPool) NonceUpperLimit ¶
func (pool *PendingTransactionPool) NonceUpperLimit(acc *corestate.Account) uint64
NonceUpperLimit returns the maximum nonce of transactions that can be accepted in the pool.
func (*PendingTransactionPool) Prune ¶
func (pool *PendingTransactionPool) Prune(addr common.Address, nonceLowerLimit uint64)
Prune prunes transactions by account's current nonce. TODO double check nonceLowerLimit
func (*PendingTransactionPool) PushOrReplace ¶
func (pool *PendingTransactionPool) PushOrReplace(tx *TxContext, accState *corestate.Account, payerState *corestate.Account, price common.Price) error
PushOrReplace pushes or replaces a transaction.
func (*PendingTransactionPool) ResetSelector ¶
func (pool *PendingTransactionPool) ResetSelector()
ResetSelector resets transaction selector.
func (*PendingTransactionPool) SetRequiredNonce ¶
func (pool *PendingTransactionPool) SetRequiredNonce(addr common.Address, nonce uint64)
SetRequiredNonce sets the transaction's nonce for the next execution by address.
type Receipt ¶
type Receipt struct {
// contains filtered or unexported fields
}
Receipt struct represents transaction receipt
func (*Receipt) SetCPUUsage ¶
SetCPUUsage sets cpu usage
func (*Receipt) SetExecuted ¶
SetExecuted sets transaction execution status
func (*Receipt) SetNetUsage ¶
SetNetUsage sets net usage
func (*Receipt) SetTimestamp ¶
SetTimestamp sets timestamp
type SyncService ¶
SyncService interface for sync
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction struct represents transaction
func NewTransactionTemplate ¶
func NewTransactionTemplate(param *TransactionTemplateParam) *Transaction
NewTransactionTemplate creates a partially filled transaction template.
func (*Transaction) CalcHash ¶
func (t *Transaction) CalcHash() ([]byte, error)
CalcHash calculates transaction's hash.
func (*Transaction) FromProto ¶
func (t *Transaction) FromProto(msg proto.Message) error
FromProto converts corepb.Transaction to Transaction
func (*Transaction) HasPayer ¶
func (t *Transaction) HasPayer() bool
HasPayer checks if the payer is set in the transaction.
func (*Transaction) HexHash ¶
func (t *Transaction) HexHash() string
HexHash returns hex converted hash
func (*Transaction) PayerOrFrom ¶
func (t *Transaction) PayerOrFrom() common.Address
PayerOrFrom returns payer if there is a payer, or from if it is not.
func (*Transaction) PayerSign ¶
func (t *Transaction) PayerSign() []byte
PayerSign returns payerSign
func (*Transaction) SetReceipt ¶
func (t *Transaction) SetReceipt(receipt *Receipt)
SetReceipt sets receipt
func (*Transaction) SignByPayer ¶
func (t *Transaction) SignByPayer(signer signature.Signature) error
SignByPayer puts payer's sign in tx
func (*Transaction) SignGenesis ¶
func (t *Transaction) SignGenesis() error
SignGenesis will leave the sign empty.
func (*Transaction) SignThis ¶
func (t *Transaction) SignThis(key signature.PrivateKey) error
SignThis signs tx with given signature interface
func (*Transaction) Size ¶
func (t *Transaction) Size() (int, error)
Size returns bytes size of transaction
func (*Transaction) String ¶
func (t *Transaction) String() string
String returns string representation of tx
func (*Transaction) ToBytes ¶
func (t *Transaction) ToBytes() ([]byte, error)
ToBytes convert transaction to
func (*Transaction) ToProto ¶
func (t *Transaction) ToProto() (proto.Message, error)
ToProto converts Transaction to corepb.Transaction
func (*Transaction) TriggerAccEvent ¶
func (t *Transaction) TriggerAccEvent(e *event.Emitter, eType string)
TriggerAccEvent triggers account type event
func (*Transaction) TriggerEvent ¶
func (t *Transaction) TriggerEvent(e *event.Emitter, eTopic string)
TriggerEvent triggers non account type event
func (*Transaction) VerifyIntegrity ¶
func (t *Transaction) VerifyIntegrity(chainID uint32) error
VerifyIntegrity returns transaction verify result, including Hash and Signature.
type TransactionManager ¶
type TransactionManager struct {
// contains filtered or unexported fields
}
TransactionManager manages transactions' pool and network service.
func NewTransactionManager ¶
func NewTransactionManager(cfg *medletpb.Config) *TransactionManager
NewTransactionManager create a new TransactionManager.
func (*TransactionManager) Broadcast ¶
func (tm *TransactionManager) Broadcast(tx *Transaction) error
Broadcast broadcasts transaction to network.
func (*TransactionManager) DelByAddressNonce ¶
func (tm *TransactionManager) DelByAddressNonce(addr common.Address, nonce uint64) error
DelByAddressNonce del transaction specific addr-nonce transaction TODO Refactoring (addr, nonce) => Account
func (*TransactionManager) Get ¶
func (tm *TransactionManager) Get(hash []byte) *Transaction
Get transaction from transaction pool.
func (*TransactionManager) InjectEmitter ¶
func (tm *TransactionManager) InjectEmitter(emitter *event.Emitter)
InjectEmitter inject emitter generated from medlet to transaction manager
func (*TransactionManager) Len ¶
func (tm *TransactionManager) Len() int
Len returns the number of transactions kept in the transaction manager.
func (*TransactionManager) Next ¶
func (tm *TransactionManager) Next() *Transaction
Next returns next transaction from transaction selector.
func (*TransactionManager) Push ¶
func (tm *TransactionManager) Push(tx *Transaction) error
Push pushes a transaction.
func (*TransactionManager) PushAndBroadcast ¶
func (tm *TransactionManager) PushAndBroadcast(tx *Transaction) error
PushAndBroadcast pushes a transaction and broadcast when transaction transits to pending pool.
func (*TransactionManager) ResetTransactionSelector ¶
func (tm *TransactionManager) ResetTransactionSelector()
ResetTransactionSelector resets transaction selector.
func (*TransactionManager) SetRequiredNonce ¶
func (tm *TransactionManager) SetRequiredNonce(addr common.Address, nonce uint64)
SetRequiredNonce sets required nonce for given address to transaction selector.
func (*TransactionManager) Setup ¶
func (tm *TransactionManager) Setup(canon Canonical, ns net.Service)
Setup sets up TransactionManager.
func (*TransactionManager) Start ¶
func (tm *TransactionManager) Start()
Start starts TransactionManager.
func (*TransactionManager) Stop ¶
func (tm *TransactionManager) Stop()
Stop stops TransactionManager.
type TransactionState ¶
TransactionState is a structure for save transaction
func NewTransactionState ¶
func NewTransactionState(rootHash []byte, stor storage.Storage) (*TransactionState, error)
NewTransactionState returns transaction state
func (*TransactionState) Clone ¶
func (ts *TransactionState) Clone() (*TransactionState, error)
Clone clones state
func (*TransactionState) GetTx ¶
func (ts *TransactionState) GetTx(hash []byte) (*Transaction, error)
GetTx returns transaction from transaction state
func (*TransactionState) Put ¶
func (ts *TransactionState) Put(tx *Transaction) error
Put put transaction to transaction state
type TransactionTemplateParam ¶
type TransactionTemplateParam struct { TxType string To common.Address Value *util.Uint128 Nonce uint64 ChainID uint32 Payload []byte }
TransactionTemplateParam represents parameters for creating transaction template.
type TransactionTestWrap ¶
type TransactionTestWrap struct {
*Transaction
}
TransactionTestWrap wraps Transaction and exports setters.
func (*TransactionTestWrap) Clone ¶
func (t *TransactionTestWrap) Clone() *TransactionTestWrap
Clone clone transaction
func (*TransactionTestWrap) SetChainID ¶
func (t *TransactionTestWrap) SetChainID(chainID uint32)
SetChainID sets chainID
func (*TransactionTestWrap) SetFrom ¶
func (t *TransactionTestWrap) SetFrom(from common.Address)
SetFrom sets from
func (*TransactionTestWrap) SetHash ¶
func (t *TransactionTestWrap) SetHash(hash []byte)
SetHash sets hash
func (*TransactionTestWrap) SetNonce ¶
func (t *TransactionTestWrap) SetNonce(nonce uint64)
SetNonce sets nonce
func (*TransactionTestWrap) SetPayer ¶
func (t *TransactionTestWrap) SetPayer(payer common.Address)
SetPayer sets payer
func (*TransactionTestWrap) SetPayerSign ¶
func (t *TransactionTestWrap) SetPayerSign(payerSign []byte)
SetPayerSign sets payerSign
func (*TransactionTestWrap) SetPayload ¶
func (t *TransactionTestWrap) SetPayload(payload []byte)
SetPayload sets payload
func (*TransactionTestWrap) SetReceipt ¶
func (t *TransactionTestWrap) SetReceipt(receipt *Receipt)
SetReceipt sets receipt
func (*TransactionTestWrap) SetSign ¶
func (t *TransactionTestWrap) SetSign(sign []byte)
SetSign sets sign
func (*TransactionTestWrap) SetTo ¶
func (t *TransactionTestWrap) SetTo(to common.Address)
SetTo sets set
func (*TransactionTestWrap) SetTxType ¶
func (t *TransactionTestWrap) SetTxType(txType string)
SetTxType sets type
func (*TransactionTestWrap) SetValue ¶
func (t *TransactionTestWrap) SetValue(value *util.Uint128)
SetValue sets value
type TxContext ¶
type TxContext struct { *Transaction // contains filtered or unexported fields }
TxContext struct represents a transaction with it's context.
func NewTxContext ¶
func NewTxContext(tx *Transaction) (*TxContext, error)
NewTxContext returns TxContext.
func NewTxContextWithBroadcast ¶
func NewTxContextWithBroadcast(tx *Transaction) (*TxContext, error)
NewTxContextWithBroadcast set broadcast flag and returns TxContext.
type TxMapper ¶
type TxMapper map[string]func(tx *Transaction) (ExecutableTx, error)
TxMapper is a map for transaction to executable tx.
func (TxMapper) Executable ¶
func (m TxMapper) Executable(tx *Transaction) (ExecutableTx, error)
Executable converts transaction to executable tx.
Source Files
¶
- block.go
- block_data.go
- block_header.go
- block_manager.go
- block_state.go
- block_test_wrap.go
- blockchain.go
- blockpool.go
- genesis.go
- receipt.go
- transaction.go
- transaction_context.go
- transaction_future.go
- transaction_manager.go
- transaction_pending.go
- transaction_state.go
- transaction_test_wrap.go
- txconv.go
- types.go