Documentation
¶
Overview ¶
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func DefaultGenesis(cryptoType crypto.CryptoType, genesisPath string) (*types.Sequencer, map[types.Address]*math.BigInt)
- func GetSampleAccounts(cryptoType crypto.CryptoType) []*account.SampleAccount
- type Accessor
- func (da *Accessor) AddBalance(addr types.Address, amount *math.BigInt) error
- func (da *Accessor) DeleteBalance(addr types.Address) error
- func (da *Accessor) DeleteTransaction(hash types.Hash) error
- func (da *Accessor) HasAddrLatestNonce(addr types.Address) (bool, error)
- func (da *Accessor) ReadAddrLatestNonce(addr types.Address) (uint64, error)
- func (da *Accessor) ReadBalance(addr types.Address) *math.BigInt
- func (da *Accessor) ReadGenesis() *types.Sequencer
- func (da *Accessor) ReadIndexedTxHashs(SeqHeight uint64) (*types.Hashes, error)
- func (da *Accessor) ReadLatestSequencer() *types.Sequencer
- func (da *Accessor) ReadReceipt(seqID uint64, hash types.Hash) *Receipt
- func (da *Accessor) ReadSequencerByHeight(SeqHeight uint64) (*types.Sequencer, error)
- func (da *Accessor) ReadTransaction(hash types.Hash) types.Txi
- func (da *Accessor) ReadTxByNonce(addr types.Address, nonce uint64) types.Txi
- func (da *Accessor) SetBalance(addr types.Address, value *math.BigInt) error
- func (da *Accessor) SubBalance(addr types.Address, amount *math.BigInt) error
- func (da *Accessor) WriteGenesis(genesis *types.Sequencer) error
- func (da *Accessor) WriteIndexedTxHashs(SeqHeight uint64, hashs *types.Hashes) error
- func (da *Accessor) WriteLatestSequencer(seq *types.Sequencer) error
- func (da *Accessor) WriteReceipts(seqID uint64, receipts ReceiptSet) error
- func (da *Accessor) WriteSequencerByHeight(seq *types.Sequencer) error
- func (da *Accessor) WriteTransaction(putter ogdb.Putter, tx types.Txi) error
- func (da *Accessor) WriteTxHashByNonce(addr types.Address, nonce uint64, hash types.Hash) error
- type Account
- type AccountFlow
- func (af *AccountFlow) Add(tx types.Txi) error
- func (af *AccountFlow) BalanceState() *BalanceState
- func (af *AccountFlow) GetTx(nonce uint64) types.Txi
- func (af *AccountFlow) LatestNonce() (uint64, error)
- func (af *AccountFlow) Len() int
- func (af *AccountFlow) Remove(nonce uint64) error
- func (af *AccountFlow) TxList() *TxList
- type AccountFlows
- func (a *AccountFlows) Add(tx types.Txi)
- func (a *AccountFlows) Get(addr types.Address) *AccountFlow
- func (a *AccountFlows) GetBalanceState(addr types.Address) *BalanceState
- func (a *AccountFlows) GetLatestNonce(addr types.Address) (uint64, error)
- func (a *AccountFlows) GetTxByNonce(addr types.Address, nonce uint64) types.Txi
- func (a *AccountFlows) Remove(tx types.Txi)
- func (a *AccountFlows) ResetFlow(addr types.Address, originBalance *math.BigInt)
- type BalanceState
- type BatchDetail
- type ConfirmBatch
- type Dag
- func (dag *Dag) Accessor() *Accessor
- func (dag *Dag) CallContract(addr types.Address, data []byte) ([]byte, error)
- func (dag *Dag) DeleteTransaction(hash types.Hash) error
- func (dag *Dag) Exist(addr types.Address) bool
- func (dag *Dag) Finalize() error
- func (dag *Dag) Genesis() *types.Sequencer
- func (dag *Dag) GetBalance(addr types.Address) *math.BigInt
- func (dag *Dag) GetConfirmTime(seqHeight uint64) *types.ConfirmTime
- func (dag *Dag) GetHeight() uint64
- func (dag *Dag) GetLatestNonce(addr types.Address) (uint64, error)
- func (dag *Dag) GetOldTx(addr types.Address, nonce uint64) types.Txi
- func (dag *Dag) GetReceipt(hash types.Hash) *Receipt
- func (dag *Dag) GetSequencer(hash types.Hash, seqHeight uint64) *types.Sequencer
- func (dag *Dag) GetSequencerByHash(hash types.Hash) *types.Sequencer
- func (dag *Dag) GetSequencerByHeight(height uint64) *types.Sequencer
- func (dag *Dag) GetSequencerHashByHeight(height uint64) *types.Hash
- func (dag *Dag) GetState(addr types.Address, key types.Hash) types.Hash
- func (dag *Dag) GetTx(hash types.Hash) types.Txi
- func (dag *Dag) GetTxByNonce(addr types.Address, nonce uint64) types.Txi
- func (dag *Dag) GetTxConfirmHeight(hash types.Hash) (uint64, error)
- func (dag *Dag) GetTxis(hashs types.Hashes) types.Txis
- func (dag *Dag) GetTxisByNumber(height uint64) types.Txis
- func (dag *Dag) GetTxsByAddress(addr types.Address) []types.Txi
- func (dag *Dag) GetTxsByNumberAndType(height uint64, txType types.TxBaseType) types.Txis
- func (dag *Dag) GetTxsHashesByNumber(Height uint64) *types.Hashes
- func (dag *Dag) Has(hash types.Hash) bool
- func (dag *Dag) Init(genesis *types.Sequencer, genesisBalance map[types.Address]*math.BigInt) error
- func (dag *Dag) LatestSequencer() *types.Sequencer
- func (dag *Dag) LoadLastState() (bool, types.Hash)
- func (dag *Dag) LoadStateRoot() types.Hash
- func (dag *Dag) ProcessTransaction(tx types.Txi) ([]byte, *Receipt, error)
- func (dag *Dag) Push(batch *ConfirmBatch) error
- func (dag *Dag) ReadConfirmTime(seqHeight uint64) *types.ConfirmTime
- func (dag *Dag) RollBack()
- func (dag *Dag) SaveStateRoot()
- func (dag *Dag) Start()
- func (dag *Dag) StateDatabase() *state.StateDB
- func (dag *Dag) Stop()
- func (dag *Dag) WriteTransaction(putter ogdb.Putter, tx types.Txi) error
- type DagConfig
- type GenesisAccounts
- type Receipt
- func (z *Receipt) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Receipt) EncodeMsg(en *msgp.Writer) (err error)
- func (z *Receipt) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Receipt) Msgsize() (s int)
- func (r *Receipt) ToJsonMap() map[string]string
- func (z *Receipt) UnmarshalMsg(bts []byte) (o []byte, err error)
- type ReceiptSet
- type ReceiptStatus
- func (z *ReceiptStatus) DecodeMsg(dc *msgp.Reader) (err error)
- func (z ReceiptStatus) EncodeMsg(en *msgp.Writer) (err error)
- func (z ReceiptStatus) MarshalMsg(b []byte) (o []byte, err error)
- func (z ReceiptStatus) Msgsize() (s int)
- func (z *ReceiptStatus) UnmarshalMsg(bts []byte) (o []byte, err error)
- type TxList
- type TxMap
- type TxPool
- func (pool *TxPool) AddLocalTx(tx types.Txi, noFeedBack bool) error
- func (pool *TxPool) AddLocalTxs(txs []types.Txi, noFeedBack bool) []error
- func (pool *TxPool) AddRemoteTx(tx types.Txi, noFeedBack bool) error
- func (pool *TxPool) AddRemoteTxs(txs []types.Txi, noFeedBack bool) []error
- func (pool *TxPool) ClearAll()
- func (pool *TxPool) Get(hash types.Hash) types.Txi
- func (pool *TxPool) GetAllTips() map[types.Hash]types.Txi
- func (pool *TxPool) GetBenchmarks() map[string]interface{}
- func (pool *TxPool) GetByNonce(addr types.Address, nonce uint64) types.Txi
- func (pool *TxPool) GetHashOrder() types.Hashes
- func (pool *TxPool) GetLatestNonce(addr types.Address) (uint64, error)
- func (pool *TxPool) GetMaxWeight() uint64
- func (pool *TxPool) GetRandomTips(n int) (v []types.Txi)
- func (pool *TxPool) GetStatus(hash types.Hash) TxStatus
- func (pool *TxPool) GetTxNum() uint32
- func (pool *TxPool) Has(hash types.Hash) bool
- func (pool *TxPool) Init(genesis *types.Sequencer)
- func (pool *TxPool) IsLocalHash(hash types.Hash) bool
- func (pool *TxPool) Name() string
- func (pool *TxPool) PoolStatus() (int, int, int)
- func (pool *TxPool) RegisterOnNewTxReceived(c chan types.Txi, chanName string, allTx bool)
- func (pool *TxPool) Remove(tx types.Txi, removeType hashOrderRemoveType)
- func (pool *TxPool) Start()
- func (pool *TxPool) Stop()
- type TxPoolConfig
- type TxQuality
- type TxStatus
- type TxType
Constants ¶
const MaxAccountCount = 255
Variables ¶
var ( DefaultGasLimit = uint64(10000000000) DefaultCoinbase = types.HexToAddress("0x1234567812345678AABBCCDDEEFF998877665544") )
Functions ¶
func DefaultGenesis ¶
func GetSampleAccounts ¶
func GetSampleAccounts(cryptoType crypto.CryptoType) []*account.SampleAccount
Types ¶
type Accessor ¶
type Accessor struct {
// contains filtered or unexported fields
}
func NewAccessor ¶
func (*Accessor) AddBalance ¶
AddBalance adds an amount of value to the address balance. Note that AddBalance doesn't hold any locks so upper level program must manage this.
func (*Accessor) DeleteBalance ¶
DeleteBalance delete the balance of an address.
func (*Accessor) DeleteTransaction ¶
DeleteTransaction delete the tx or sequencer.
func (*Accessor) HasAddrLatestNonce ¶
HasAddrLatestNonce returns true if addr already sent some txs.
func (*Accessor) ReadAddrLatestNonce ¶
ReadAddrLatestNonce get latest nonce of an address
func (*Accessor) ReadBalance ¶
ReadBalance get the balance of an address.
func (*Accessor) ReadGenesis ¶
ReadGenesis get genesis sequencer from db. return nil if there is no genesis.
func (*Accessor) ReadIndexedTxHashs ¶
ReadIndexedTxHashs get a list of txs that is confirmed by the sequencer that holds the id 'SeqHeight'.
func (*Accessor) ReadLatestSequencer ¶
ReadLatestSequencer get latest sequencer from db. return nil if there is no sequencer.
func (*Accessor) ReadReceipt ¶
ReadReceipt try get receipt by tx hash and seqID.
func (*Accessor) ReadSequencerByHeight ¶
ReadSequencerByHeight get sequencer from db by sequencer id.
func (*Accessor) ReadTransaction ¶
ReadTransaction get tx or sequencer from ogdb.
func (*Accessor) ReadTxByNonce ¶
ReadTxByNonce get tx from db by sender's address and nonce.
func (*Accessor) SetBalance ¶
SetBalance write the balance of an address into ogdb. Data will be overwritten if it already exist in db.
func (*Accessor) SubBalance ¶
SubBalance subs an amount of value to the address balance. Note that SubBalance doesn't hold any locks so upper level program must manage this.
func (*Accessor) WriteGenesis ¶
WriteGenesis writes geneis into db.
func (*Accessor) WriteIndexedTxHashs ¶
WriteIndexedTxHashs stores a list of tx hashs. These related hashs are all confirmed by sequencer that holds the id 'SeqHeight'.
func (*Accessor) WriteLatestSequencer ¶
WriteGenesis writes latest sequencer into db.
func (*Accessor) WriteReceipts ¶
func (da *Accessor) WriteReceipts(seqID uint64, receipts ReceiptSet) error
WriteReceipts write a receipt map into db.
func (*Accessor) WriteSequencerByHeight ¶
WriteSequencerByHeight stores the sequencer into db and indexed by its id.
func (*Accessor) WriteTransaction ¶
WriteTransaction write the tx or sequencer into ogdb.
type AccountFlow ¶
type AccountFlow struct {
// contains filtered or unexported fields
}
AccountFlow stores the information about an address. It includes the balance state of the account among the txpool,
func NewAccountFlow ¶
func NewAccountFlow(originBalance *math.BigInt) *AccountFlow
func (*AccountFlow) Add ¶
func (af *AccountFlow) Add(tx types.Txi) error
Add new tx into account flow. This function should 1. update account's balance state. 2. add tx into nonce sorted txlist.
func (*AccountFlow) BalanceState ¶
func (af *AccountFlow) BalanceState() *BalanceState
func (*AccountFlow) GetTx ¶
func (af *AccountFlow) GetTx(nonce uint64) types.Txi
GetTx get a tx from accountflow.
func (*AccountFlow) LatestNonce ¶
func (af *AccountFlow) LatestNonce() (uint64, error)
LatestNonce returns the largest nonce stored in txlist.
func (*AccountFlow) Len ¶
func (af *AccountFlow) Len() int
return the count of txs sent by this account.
func (*AccountFlow) Remove ¶
func (af *AccountFlow) Remove(nonce uint64) error
Remove a tx from account flow, find tx by nonce first, then rolls back the balance and remove tx from txlist.
func (*AccountFlow) TxList ¶
func (af *AccountFlow) TxList() *TxList
type AccountFlows ¶
type AccountFlows struct {
// contains filtered or unexported fields
}
func NewAccountFlows ¶
func NewAccountFlows() *AccountFlows
func (*AccountFlows) Add ¶
func (a *AccountFlows) Add(tx types.Txi)
func (*AccountFlows) Get ¶
func (a *AccountFlows) Get(addr types.Address) *AccountFlow
func (*AccountFlows) GetBalanceState ¶
func (a *AccountFlows) GetBalanceState(addr types.Address) *BalanceState
func (*AccountFlows) GetLatestNonce ¶
func (a *AccountFlows) GetLatestNonce(addr types.Address) (uint64, error)
func (*AccountFlows) GetTxByNonce ¶
func (*AccountFlows) Remove ¶
func (a *AccountFlows) Remove(tx types.Txi)
type BalanceState ¶
type BalanceState struct {
// contains filtered or unexported fields
}
func NewBalanceState ¶
func NewBalanceState(balance *math.BigInt) *BalanceState
func (*BalanceState) OriginBalance ¶
func (bs *BalanceState) OriginBalance() *math.BigInt
func (*BalanceState) Spent ¶
func (bs *BalanceState) Spent() *math.BigInt
func (*BalanceState) TryRemoveValue ¶
func (bs *BalanceState) TryRemoveValue(txValue *math.BigInt) error
TryRemoveValue is called when remove a tx from pool. It reduce the total spent by the value of removed tx.
func (*BalanceState) TrySubBalance ¶
func (bs *BalanceState) TrySubBalance(value *math.BigInt) error
TrySubBalance checks if origin balance is enough for total spent of txs in pool. It trys to add new spent "value" into total spent and compare total spent with origin balance.
type BatchDetail ¶
BatchDetail describes all the details of a specific address within a sequencer confirmation term. - TxList - represents the txs sent by this addrs, ordered by nonce. - Neg - means the amount this address should spent out. - Pos - means the amount this address get paid.
type Dag ¶
type Dag struct {
OnConsensusTXConfirmed chan []types.Txi
// contains filtered or unexported fields
}
func (*Dag) CallContract ¶
CallContract calls contract but disallow any modifications on statedb. This method will call ovm.StaticCall() to satisfy this.
func (*Dag) GetBalance ¶
GetBalance read the confirmed balance of an address from ogdb.
func (*Dag) GetConfirmTime ¶
func (dag *Dag) GetConfirmTime(seqHeight uint64) *types.ConfirmTime
func (*Dag) GetLatestNonce ¶
GetLatestNonce returns the latest tx of an addresss.
func (*Dag) GetSequencer ¶
func (*Dag) GetSequencerByHash ¶
func (*Dag) GetSequencerByHeight ¶
func (*Dag) GetSequencerHashByHeight ¶
func (*Dag) GetTx ¶
GetTx gets tx from dag network indexed by tx hash. This function querys ogdb only.
func (*Dag) GetTxByNonce ¶
GetTxByNonce gets tx from dag by sender's address and tx nonce
func (*Dag) GetTxConfirmHeight ¶
GetTxConfirmHeight returns the height of sequencer that confirm this tx.
func (*Dag) GetTxsByAddress ¶
GetTxsByAddress get all txs from this address
func (*Dag) GetTxsByNumberAndType ¶
func (*Dag) GetTxsHashesByNumber ¶
func (*Dag) LatestSequencer ¶
LatestSequencer returns the latest sequencer stored in dag
func (*Dag) LoadLastState ¶
LoadLastState load genesis and latestsequencer data from ogdb. return false if there is no genesis stored in the db.
func (*Dag) LoadStateRoot ¶
TODO This is a temp function to solve the not working problem when restart the node. The perfect solution is to load the root from latest sequencer every time restart the node.
func (*Dag) ProcessTransaction ¶
ProcessTransaction execute the tx and update the data in statedb.
Besides balance and nonce, if a tx is trying to create or call a contract, vm part will be initiated to handle this.
func (*Dag) Push ¶
func (dag *Dag) Push(batch *ConfirmBatch) error
Push trys to move a tx from tx pool to dag db.
func (*Dag) ReadConfirmTime ¶
func (dag *Dag) ReadConfirmTime(seqHeight uint64) *types.ConfirmTime
func (*Dag) SaveStateRoot ¶
func (dag *Dag) SaveStateRoot()
TODO This is a temp function to solve the not working problem when restart the node. The perfect solution is to load the root from latest sequencer every time restart the node.
func (*Dag) StateDatabase ¶
StateDatabase is for testing only
func (*Dag) WriteTransaction ¶
WriteTransaction write the tx or sequencer into ogdb. It first writes the latest nonce of the tx's sender, then write the ([address, nonce] -> hash) relation into db, finally write the tx itself. Data will be overwritten if it already exists in db.
type DagConfig ¶
type DagConfig struct {
GenesisPath string
}
func DefaultDagConfig ¶
func DefaultDagConfig() DagConfig
type GenesisAccounts ¶
type GenesisAccounts struct {
Accounts []Account `json:"accounts"`
}
func GetGenesisAccounts ¶
func GetGenesisAccounts(cryptoType crypto.CryptoType, genesisPath string) *GenesisAccounts
type Receipt ¶
type Receipt struct {
TxHash types.Hash
Status ReceiptStatus
ProcessResult string
ContractAddress types.Address
}
func NewReceipt ¶
func (*Receipt) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type ReceiptSet ¶
func (*ReceiptSet) DecodeMsg ¶
func (z *ReceiptSet) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (ReceiptSet) EncodeMsg ¶
func (z ReceiptSet) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (ReceiptSet) MarshalMsg ¶
func (z ReceiptSet) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (ReceiptSet) Msgsize ¶
func (z ReceiptSet) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*ReceiptSet) UnmarshalMsg ¶
func (z *ReceiptSet) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type ReceiptStatus ¶
type ReceiptStatus int
const ( ReceiptStatusSeqSuccess ReceiptStatus = iota ReceiptStatusTxSuccess ReceiptStatusOVMFailed ReceiptStatusCampaignSuccess ReceiptStatusTermChangeSuccess )
func (*ReceiptStatus) DecodeMsg ¶
func (z *ReceiptStatus) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (ReceiptStatus) EncodeMsg ¶
func (z ReceiptStatus) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (ReceiptStatus) MarshalMsg ¶
func (z ReceiptStatus) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (ReceiptStatus) Msgsize ¶
func (z ReceiptStatus) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*ReceiptStatus) UnmarshalMsg ¶
func (z *ReceiptStatus) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type TxMap ¶
type TxMap struct {
// contains filtered or unexported fields
}
func (*TxMap) GetAllKeys ¶
func (*TxMap) GetAllValues ¶
type TxPool ¶
type TxPool struct {
OnConsensusTXConfirmed []chan map[types.Hash]types.Txi // for notifications of consensus tx confirmation.
OnBatchConfirmed []chan map[types.Hash]types.Txi // for notifications of confirmation.
OnNewLatestSequencer []chan bool //for broadcasting new latest sequencer to record height
// contains filtered or unexported fields
}
func NewTxPool ¶
func NewTxPool(conf TxPoolConfig, d *Dag) *TxPool
func (*TxPool) AddLocalTx ¶
AddLocalTx adds a tx to txpool if it is valid, note that if success it returns nil. AddLocalTx only process tx that sent by local node.
func (*TxPool) AddLocalTxs ¶
AddLocalTxs adds a list of txs to txpool if they are valid. It returns the process result of each tx with an error list. AddLocalTxs only process txs that sent by local node.
func (*TxPool) AddRemoteTx ¶
AddRemoteTx adds a tx to txpool if it is valid. AddRemoteTx only process tx sent by remote nodes, and will hold extra functions to prevent from ddos (large amount of invalid tx sent from one node in a short time) attack.
func (*TxPool) AddRemoteTxs ¶
AddRemoteTxs works as same as AddRemoteTx but processes a list of txs
func (*TxPool) ClearAll ¶
func (pool *TxPool) ClearAll()
ClearAll removes all the txs in the pool.
Note that ClearAll should only be called when solving conflicts during a sequencer confirmation time.
func (*TxPool) Get ¶
Get get a transaction or sequencer according to input hash, if tx not exists return nil
func (*TxPool) GetAllTips ¶
GetAllTips returns all the tips in TxPool.
func (*TxPool) GetBenchmarks ¶
func (*TxPool) GetByNonce ¶
GetByNonce get a tx or sequencer from account flows by sender's address and tx's nonce.
func (*TxPool) GetHashOrder ¶
GetHashOrder returns a hash list of txs in pool, ordered by the time that txs added into pool.
func (*TxPool) GetLatestNonce ¶
GetLatestNonce get the latest nonce of an address
func (*TxPool) GetMaxWeight ¶
func (*TxPool) GetRandomTips ¶
GetRandomTips returns n tips randomly.
func (*TxPool) PoolStatus ¶
PoolStatus returns the current number of tips, bad txs and pending txs stored in pool.
func (*TxPool) RegisterOnNewTxReceived ¶
type TxPoolConfig ¶
type TxPoolConfig struct {
QueueSize int `mapstructure:"queue_size"`
TipsSize int `mapstructure:"tips_size"`
ResetDuration int `mapstructure:"reset_duration"`
TxVerifyTime int `mapstructure:"tx_verify_time"`
TxValidTime int `mapstructure:"tx_valid_time"`
TimeOutPoolQueue int `mapstructure:"timeout_pool_queue_ms"`
TimeoutSubscriber int `mapstructure:"timeout_subscriber_ms"`
TimeoutConfirmation int `mapstructure:"timeout_confirmation_ms"`
TimeoutLatestSequencer int `mapstructure:"timeout_latest_seq_ms"`
}
func DefaultTxPoolConfig ¶
func DefaultTxPoolConfig() TxPoolConfig