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.
Index ¶
- Constants
- Variables
- func DefaultGenesis(genesisPath string) (*types.Sequencer, map[ogTypes.AddressKey]*math.BigInt)
- type Accessor
- func (da *Accessor) AddBalance(putter *Putter, addr ogTypes.Address, amount *math.BigInt) error
- func (da *Accessor) DeleteBalance(addr ogTypes.Address) error
- func (da *Accessor) DeleteTransaction(hash ogTypes.Hash) error
- func (da *Accessor) HasAddrLatestNonce(addr ogTypes.Address) (bool, error)
- func (ac *Accessor) NewBatch() *Putter
- func (da *Accessor) ReadAddrLatestNonce(addr ogTypes.Address) (uint64, error)
- func (da *Accessor) ReadBalance(addr ogTypes.Address) *math.BigInt
- func (da *Accessor) ReadGenesis() *types.Sequencer
- func (da *Accessor) ReadIndexedTxHashs(SeqHeight uint64) ([]ogTypes.Hash, error)
- func (da *Accessor) ReadLastStateRoot() ogTypes.Hash
- func (da *Accessor) ReadLatestConfirmedSeq() *types.Sequencer
- func (da *Accessor) ReadReceipt(seqID uint64, hash ogTypes.Hash) *Receipt
- func (da *Accessor) ReadSequencerByHeight(SeqHeight uint64) (*types.Sequencer, error)
- func (da *Accessor) ReadTransaction(hash ogTypes.Hash) types.Txi
- func (da *Accessor) ReadTxByNonce(addr ogTypes.Address, nonce uint64) types.Txi
- func (da *Accessor) SetBalance(putter *Putter, addr ogTypes.Address, value *math.BigInt) error
- func (da *Accessor) SubBalance(putter *Putter, addr ogTypes.Address, amount *math.BigInt) error
- func (da *Accessor) WriteGenesis(genesis *types.Sequencer) error
- func (da *Accessor) WriteIndexedTxHashs(putter *Putter, SeqHeight uint64, hashs []ogTypes.Hash) error
- func (da *Accessor) WriteLastStateRoot(putter *Putter, root ogTypes.Hash) error
- func (da *Accessor) WriteLatestConfirmedSeq(putter *Putter, seq *types.Sequencer) error
- func (da *Accessor) WriteReceipts(putter *Putter, seqID uint64, receipts ReceiptSet) error
- func (da *Accessor) WriteSequencerByHeight(putter *Putter, seq *types.Sequencer) error
- func (da *Accessor) WriteTransaction(putter *Putter, tx types.Txi) error
- func (da *Accessor) WriteTxHashByNonce(putter *Putter, addr ogTypes.Address, nonce uint64, hash ogTypes.Hash) error
- type Account
- type AccountFlow
- func (af *AccountFlow) Add(tx types.Txi) error
- func (af *AccountFlow) BalanceState(tokenID int32) *BalanceState
- func (af *AccountFlow) GetTx(nonce uint64) types.Txi
- func (af *AccountFlow) LatestNonce() (uint64, error)
- func (af *AccountFlow) Len() int
- func (af *AccountFlow) MergeFlow(afToMerge *AccountFlow)
- func (af *AccountFlow) Remove(txToRemove types.Txi) error
- func (af *AccountFlow) TxList() *TxList
- type AccountFlowSet
- func (a *AccountFlowSet) Add(baseSeqHash ogTypes.Hash, tx types.Txi)
- func (a *AccountFlowSet) Get(addr ogTypes.Address) *AccountFlow
- func (a *AccountFlowSet) GetBalanceState(addr ogTypes.Address, tokenID int32) *BalanceState
- func (a *AccountFlowSet) GetLatestNonce(addr ogTypes.Address) (uint64, error)
- func (a *AccountFlowSet) GetTxByNonce(addr ogTypes.Address, nonce uint64) types.Txi
- func (a *AccountFlowSet) MergeFlow(addr ogTypes.Address, af *AccountFlow)
- func (a *AccountFlowSet) Remove(tx types.Txi)
- func (a *AccountFlowSet) ResetFlow(addr ogTypes.Address, originBalance state.BalanceSet)
- type BalanceState
- type CachedConfirms
- type ConfirmBatch
- type Dag
- func (dag *Dag) CallContract(addr ogTypes.Address20, data []byte) ([]byte, error)
- func (dag *Dag) Commit(seqHash ogTypes.Hash) error
- func (dag *Dag) ConfirmedSequencer() *types.Sequencer
- func (dag *Dag) ConfirmedSequencerHash() ogTypes.Hash
- func (dag *Dag) ExistTx(baseSeqHash ogTypes.Hash, hash ogTypes.Hash) bool
- func (dag *Dag) Genesis() *types.Sequencer
- func (dag *Dag) GetAllTokenBalance(baseSeqHash ogTypes.Hash, addr ogTypes.Address) state.BalanceSet
- func (dag *Dag) GetBalance(baseSeqHash ogTypes.Hash, addr ogTypes.Address, tokenID int32) *math.BigInt
- func (dag *Dag) GetConfirmedHeight() uint64
- func (dag *Dag) GetConfirmedTx(hash ogTypes.Hash) types.Txi
- func (dag *Dag) GetHeight() uint64
- func (dag *Dag) GetLatestNonce(baseSeqHash ogTypes.Hash, addr ogTypes.Address) (uint64, error)
- func (dag *Dag) GetLatestTokenId(baseSeqHash ogTypes.Hash) int32
- func (dag *Dag) GetReceipt(hash ogTypes.Hash) *Receipt
- func (dag *Dag) GetSequencer(hash ogTypes.Hash, seqHeight uint64) *types.Sequencer
- func (dag *Dag) GetSequencerByHash(hash ogTypes.Hash) *types.Sequencer
- func (dag *Dag) GetSequencerByHeight(height uint64) *types.Sequencer
- func (dag *Dag) GetState(baseSeqHash ogTypes.Hash, addr ogTypes.Address, key ogTypes.Hash) ogTypes.Hash
- func (dag *Dag) GetToken(baseSeqHash ogTypes.Hash, tokenId int32) *state.TokenObject
- func (dag *Dag) GetTokens(baseSeqHash ogTypes.Hash) []*state.TokenObject
- func (dag *Dag) GetTx(hash ogTypes.Hash) types.Txi
- func (dag *Dag) GetTxByNonce(baseSeqHash ogTypes.Hash, addr ogTypes.Address, nonce uint64) types.Txi
- func (dag *Dag) GetTxConfirmHeight(hash ogTypes.Hash) (uint64, error)
- func (dag *Dag) GetTxis(hashs []ogTypes.Hash) types.Txis
- func (dag *Dag) GetTxisByHeight(height uint64) types.Txis
- func (dag *Dag) Init(genesis *types.Sequencer, genesisBalance map[ogTypes.AddressKey]*math.BigInt) error
- func (dag *Dag) LatestSequencer() *types.Sequencer
- func (dag *Dag) LatestSequencerHash() ogTypes.Hash
- func (dag *Dag) LoadLatestConfirmedSeq() (*types.Sequencer, *types.Sequencer)
- func (dag *Dag) Push(batch *PushBatch) error
- func (dag *Dag) RollBack()
- func (dag *Dag) Speculate(pushBatch *PushBatch) (ogTypes.Hash, error)
- func (dag *Dag) Start()
- func (dag *Dag) Stop()
- type DagConfig
- type GenesisAccounts
- type Ledger
- type LedgerEngine
- type OgLedger
- func (ol *OgLedger) Commit(seqHash ogTypes.Hash) (err error)
- func (ol *OgLedger) CurrentCommittee()
- func (ol *OgLedger) CurrentHeight() int64
- func (ol *OgLedger) GetConsensusState()
- func (ol *OgLedger) Push(seq *types.Sequencer) (err error)
- func (ol *OgLedger) SetConsensusState()
- func (ol *OgLedger) Speculate(proposal Proposal) (stateRoot ogTypes.Hash, err error)
- type OgTxProcessor
- type OvmProcessor
- type Proposal
- type PushBatch
- type Putter
- type Receipt
- type ReceiptSet
- type ReceiptStatus
- type TxList
- type TxMap
- type TxPool
- func (pool *TxPool) ClearAll()
- func (pool *TxPool) Confirm(seqHash ogTypes.Hash) error
- func (pool *TxPool) Get(hash ogTypes.Hash) types.Txi
- func (pool *TxPool) GetAllTips() map[ogTypes.HashKey]types.Txi
- func (pool *TxPool) GetBenchmarks() map[string]interface{}
- func (pool *TxPool) GetByNonce(addr ogTypes.Address, nonce uint64) types.Txi
- func (pool *TxPool) GetHashOrder() []ogTypes.Hash
- func (pool *TxPool) GetLatestNonce(addr ogTypes.Address) (uint64, error)
- func (pool *TxPool) GetMaxWeight() uint64
- func (pool *TxPool) GetRandomTips(n int) (v []types.Txi)
- func (pool *TxPool) GetStatus(hash ogTypes.Hash) TxStatus
- func (pool *TxPool) GetTxNum() int
- func (pool *TxPool) Has(hash ogTypes.Hash) bool
- func (pool *TxPool) Init(genesis *types.Sequencer)
- func (pool *TxPool) IsBadSeq(seq *types.Sequencer) error
- func (pool *TxPool) IsLocalHash(hash ogTypes.Hash) bool
- func (pool *TxPool) Name() string
- func (pool *TxPool) PoolStatus() (int, int, int)
- func (pool *TxPool) PreConfirm(seq *types.Sequencer) ([]types.Txi, error)
- func (pool *TxPool) RegisterOnNewTxReceived(c chan types.Txi, chanName string, allTx bool)
- func (pool *TxPool) Remove(tx types.Txi, removeType hashOrderRemoveType)
- func (pool *TxPool) SeekElders(seq *types.Sequencer) ([]types.Txi, map[ogTypes.HashKey]types.Txi, error)
- func (pool *TxPool) Start()
- func (pool *TxPool) Stop()
- type TxPoolConfig
- type TxProcessor
- type TxQuality
- type TxStatus
- type TxType
- type VmProcessor
- type VmStateDB
Constants ¶
const MaxAccountCount = 255
const (
PoolRejudgeThreshold int = 10
)
Variables ¶
var ( DefaultGasLimit = uint64(10000000000) DefaultCoinbase, _ = ogTypes.HexToAddress20("0x1234567812345678AABBCCDDEEFF998877665544") )
Functions ¶
func DefaultGenesis ¶
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) ReadLastStateRoot ¶
ReadLastStateRoot read latest state root from db. TODO this is a temp function. The latest state root should be stored in latest sequencer.
func (*Accessor) ReadLatestConfirmedSeq ¶
ReadLatestConfirmedSeq 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 ¶
func (da *Accessor) WriteIndexedTxHashs(putter *Putter, SeqHeight uint64, hashs []ogTypes.Hash) error
WriteIndexedTxHashs stores a list of tx hashs. These related hashs are all confirmed by sequencer that holds the id 'SeqHeight'.
func (*Accessor) WriteLastStateRoot ¶
WriteLastStateRoot write latest state root into db. TODO this is a temp function. The latest state root should be stored in latest sequencer.
func (*Accessor) WriteLatestConfirmedSeq ¶
WriteLatestConfirmedSeq writes latest sequencer into db.
func (*Accessor) WriteReceipts ¶
func (da *Accessor) WriteReceipts(putter *Putter, 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 state.BalanceSet) *AccountFlow
func NewAccountFlowWithFullData ¶
func NewAccountFlowWithFullData(balanceStates map[int32]*BalanceState, txlist *TxList) *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(tokenID int32) *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) MergeFlow ¶
func (af *AccountFlow) MergeFlow(afToMerge *AccountFlow)
func (*AccountFlow) Remove ¶
func (af *AccountFlow) Remove(txToRemove types.Txi) 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 AccountFlowSet ¶
type AccountFlowSet struct {
// contains filtered or unexported fields
}
func NewAccountFlowSet ¶
func NewAccountFlowSet(ledger Ledger) *AccountFlowSet
func (*AccountFlowSet) Get ¶
func (a *AccountFlowSet) Get(addr ogTypes.Address) *AccountFlow
func (*AccountFlowSet) GetBalanceState ¶
func (a *AccountFlowSet) GetBalanceState(addr ogTypes.Address, tokenID int32) *BalanceState
func (*AccountFlowSet) GetLatestNonce ¶
func (a *AccountFlowSet) GetLatestNonce(addr ogTypes.Address) (uint64, error)
func (*AccountFlowSet) GetTxByNonce ¶
func (*AccountFlowSet) MergeFlow ¶
func (a *AccountFlowSet) MergeFlow(addr ogTypes.Address, af *AccountFlow)
func (*AccountFlowSet) Remove ¶
func (a *AccountFlowSet) Remove(tx types.Txi)
func (*AccountFlowSet) ResetFlow ¶
func (a *AccountFlowSet) ResetFlow(addr ogTypes.Address, originBalance state.BalanceSet)
type BalanceState ¶
type BalanceState struct {
// contains filtered or unexported fields
}
func NewBalanceState ¶
func NewBalanceState(balance *math.BigInt) *BalanceState
func NewBalanceStateWithFullData ¶
func NewBalanceStateWithFullData(balance *math.BigInt, spent *math.BigInt) *BalanceState
func (*BalanceState) OriginBalance ¶
func (bs *BalanceState) OriginBalance() *math.BigInt
func (*BalanceState) Spent ¶
func (bs *BalanceState) Spent() *math.BigInt
func (*BalanceState) TryProcessTx ¶
func (bs *BalanceState) TryProcessTx(value *math.BigInt) error
TryProcessTx 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.
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.
type CachedConfirms ¶
type CachedConfirms struct {
// contains filtered or unexported fields
}
type ConfirmBatch ¶
type ConfirmBatch struct {
// contains filtered or unexported fields
}
type Dag ¶
type Dag struct { OnConsensusTXConfirmed chan []types.Txi // contains filtered or unexported fields }
func NewDag ¶
func NewDag(conf DagConfig, stateDBConfig state.StateDBConfig, db ogdb.Database, txProcessor TxProcessor, vmProcessor VmProcessor) (*Dag, error)
func (*Dag) CallContract ¶
CallContract calls contract but disallow any modifications on statedb. This method will call ovm.StaticCall() to satisfy this.
func (*Dag) ConfirmedSequencer ¶
func (*Dag) ConfirmedSequencerHash ¶
func (*Dag) GetAllTokenBalance ¶
func (*Dag) GetBalance ¶
func (*Dag) GetConfirmedHeight ¶
func (*Dag) GetLatestNonce ¶
GetLatestNonce returns the latest tx of an address.
func (*Dag) GetSequencer ¶
func (*Dag) GetSequencerByHash ¶
func (*Dag) GetSequencerByHeight ¶
GetSequencerByHeight only support those confirmed sequencers
func (*Dag) GetState ¶
func (dag *Dag) GetState(baseSeqHash ogTypes.Hash, addr ogTypes.Address, key ogTypes.Hash) ogTypes.Hash
GetState get contract's state from statedb.
func (*Dag) GetTxByNonce ¶
func (dag *Dag) GetTxByNonce(baseSeqHash ogTypes.Hash, addr ogTypes.Address, nonce uint64) types.Txi
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) Init ¶
func (dag *Dag) Init(genesis *types.Sequencer, genesisBalance map[ogTypes.AddressKey]*math.BigInt) error
Init inits genesis sequencer and genesis state of the network.
func (*Dag) LatestSequencer ¶
LatestSequencer returns the latest sequencer stored in dag
func (*Dag) LatestSequencerHash ¶
func (*Dag) LoadLatestConfirmedSeq ¶
LoadLatestConfirmedSeq load genesis and latest confirmed sequencer from 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(genesisPath string) *GenesisAccounts
type LedgerEngine ¶
type LedgerEngine interface { GetNonce(ogTypes.Address) uint64 SetNonce(ogTypes.Address, uint64) IssueToken(issuer ogTypes.Address, name, symbol string, reIssuable bool, fstIssue *math.BigInt) (int32, error) ReIssueToken(tokenID int32, amount *math.BigInt) error DestroyToken(tokenID int32) error GetTokenBalance(ogTypes.Address, int32) *math.BigInt SubTokenBalance(ogTypes.Address, int32, *math.BigInt) AddTokenBalance(ogTypes.Address, int32, *math.BigInt) }
type OgLedger ¶
type OgLedger struct {
// contains filtered or unexported fields
}
func (*OgLedger) CurrentCommittee ¶
func (ol *OgLedger) CurrentCommittee()
func (*OgLedger) CurrentHeight ¶
func (*OgLedger) GetConsensusState ¶
func (ol *OgLedger) GetConsensusState()
func (*OgLedger) SetConsensusState ¶
func (ol *OgLedger) SetConsensusState()
type OgTxProcessor ¶
type OgTxProcessor struct{}
func NewOgTxProcessor ¶
func NewOgTxProcessor() *OgTxProcessor
func (*OgTxProcessor) Process ¶
func (tp *OgTxProcessor) Process(engine LedgerEngine, tx types.Txi) (*Receipt, error)
type OvmProcessor ¶
type OvmProcessor struct{}
func (*OvmProcessor) CanProcess ¶
func (op *OvmProcessor) CanProcess(txi types.Txi) bool
type Receipt ¶
type Receipt struct { TxHash ogTypes.Hash Status ReceiptStatus ProcessResult string ContractAddress ogTypes.Address }
func ActionTxProcessor ¶
func ActionTxProcessor(engine LedgerEngine, actionTx *types.ActionTx) (*Receipt, error)
func NewReceipt ¶
func (*Receipt) MarshalMsg ¶
type ReceiptSet ¶
type ReceiptStatus ¶
type ReceiptStatus uint8
const ( ReceiptStatusSuccess ReceiptStatus = iota ReceiptStatusVMFailed ReceiptStatusUnknownTxType ReceiptStatusFailed )
type TxList ¶
type TxList struct {
// contains filtered or unexported fields
}
func NewTxListByKeySet ¶
type TxMap ¶
type TxMap struct {
// contains filtered or unexported fields
}
---------------------------------------------------- TxMap
func (*TxMap) GetAllKeys ¶
func (*TxMap) GetAllValues ¶
type TxPool ¶
type TxPool struct { OnBatchConfirmed []chan map[ogTypes.HashKey]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, dag *Dag) *TxPool
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) PreConfirm ¶
func (*TxPool) RegisterOnNewTxReceived ¶
func (*TxPool) Remove ¶
Remove totally removes a tx from pool, it checks badtxs, tips, pendings and txlookup.
func (*TxPool) SeekElders ¶
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"` ConfirmStatusRefreshTime int //minute }
func DefaultTxPoolConfig ¶
func DefaultTxPoolConfig() TxPoolConfig
type TxProcessor ¶
type TxProcessor interface {
Process(engine LedgerEngine, tx types.Txi) (*Receipt, error)
}
type VmProcessor ¶
type VmStateDB ¶
type VmStateDB interface { CreateAccount(ogTypes.Address) SubBalance(ogTypes.Address, *math.BigInt) AddBalance(ogTypes.Address, *math.BigInt) // Retrieve the balance from the given address or 0 if object not found GetBalance(ogTypes.Address) *math.BigInt GetNonce(ogTypes.Address) uint64 SetNonce(ogTypes.Address, uint64) GetCodeHash(ogTypes.Address) ogTypes.Hash GetCode(ogTypes.Address) []byte SetCode(ogTypes.Address, []byte) GetCodeSize(ogTypes.Address) int // AddRefund adds gas to the refund counter AddRefund(uint64) // SubRefund removes gas from the refund counter. // This method will panic if the refund counter goes below zero SubRefund(uint64) // GetRefund returns the current value of the refund counter. GetRefund() uint64 GetCommittedState(ogTypes.Address, ogTypes.Hash) ogTypes.Hash // GetState retrieves a value from the given account's storage trie. GetState(ogTypes.Address, ogTypes.Hash) ogTypes.Hash SetState(ogTypes.Address, ogTypes.Hash, ogTypes.Hash) // Suicide marks the given account as suicided. // This clears the account balance. // // The account's state object is still available until the state is committed, // getStateObject will return a non-nil account after Suicide. Suicide(ogTypes.Address) bool HasSuicided(ogTypes.Address) bool // IsAddressExists reports whether the given account exists in state. // Notably this should also return true for suicided accounts. Exist(ogTypes.Address) bool // Empty returns whether the given account is empty. Empty // is defined according to EIP161 (balance = nonce = code = 0). Empty(ogTypes.Address) bool // RevertToSnapshot reverts all state changes made since the given revision. RevertToSnapshot(int) // Snapshot creates a new revision Snapshot() int AddLog(log *vmtypes.Log) AddPreimage(ogTypes.Hash, []byte) ForEachStorage(ogTypes.Address, func(ogTypes.Hash, ogTypes.Hash) bool) // for debug. String() string }
TODO try to delete those useless evm functions in OG. like AddRefund refund functions, Suicide functions, Log and PreImage functions etc.