Documentation ¶
Index ¶
- Constants
- Variables
- func FromGethAddreses(gethAddresses []gethcmn.Address) [][20]byte
- func FromGethHashes(gethHashes []gethcmn.Hash) [][32]byte
- func GetAccountKey(addr common.Address) []byte
- func GetBytecodeKey(addr common.Address) []byte
- func GetCreationCounterKey(lsb uint8) []byte
- func GetStandbyTxKey(num uint64) []byte
- func GetValueKey(seq uint64, key string) []byte
- func ToGethHashes(rawHashes [][32]byte) []gethcmn.Hash
- func ToGethLog(log Log) *gethtypes.Log
- func ToGethLogs(logs []Log) []*gethtypes.Log
- type AccountInfo
- func (info *AccountInfo) Balance() *uint256.Int
- func (info *AccountInfo) BalanceSlice() []byte
- func (info *AccountInfo) Bytes() []byte
- func (info *AccountInfo) Nonce() uint64
- func (info *AccountInfo) NonceSlice() []byte
- func (info *AccountInfo) Sequence() uint64
- func (info *AccountInfo) SequenceSlice() []byte
- func (info *AccountInfo) UpdateBalance(newBalance *uint256.Int)
- func (info *AccountInfo) UpdateNonce(newNonce uint64)
- func (info *AccountInfo) UpdateSequence(newSeq uint64)
- type BasicTx
- type Block
- func (z *Block) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Block) EncodeMsg(en *msgp.Writer) (err error)
- func (blk *Block) FillBasicInfo(bz []byte)
- func (z *Block) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Block) Msgsize() (s int)
- func (blk *Block) SerializeBasicInfo() []byte
- func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error)
- type BlockInfo
- type BondStatus
- type BytecodeInfo
- type ChainEvent
- type Context
- func (c *Context) BasicQueryLogs(address common.Address, topics []common.Hash, ...) (logs []Log, err error)
- func (c *Context) CheckNonce(sender common.Address, nonce uint64) (*AccountInfo, error)
- func (c *Context) Close(dirty bool)
- func (c *Context) DeductTxFee(sender common.Address, acc *AccountInfo, txGas uint64, gasPrice *uint256.Int) error
- func (c *Context) DeleteAccount(address common.Address)
- func (c *Context) GetAccount(address common.Address) *AccountInfo
- func (c *Context) GetBalance(owner common.Address, height int64) (*uint256.Int, error)
- func (c *Context) GetBlockByHash(hash common.Hash) (blk *Block, err error)
- func (c *Context) GetBlockByHeight(height uint64) (*Block, error)
- func (c *Context) GetBlockHashByHeight(height uint64) [32]byte
- func (c *Context) GetCode(contract common.Address) *BytecodeInfo
- func (c *Context) GetCurrBlockBasicInfo() *Block
- func (c *Context) GetFromAddressCount(addr common.Address) int64
- func (c *Context) GetLatestHeight() int64
- func (c *Context) GetSep20FromAddressCount(contract common.Address, addr common.Address) int64
- func (c *Context) GetSep20ToAddressCount(contract common.Address, addr common.Address) int64
- func (c *Context) GetStorageAt(seq uint64, key string) []byte
- func (c *Context) GetToAddressCount(addr common.Address) int64
- func (c *Context) GetTxByBlkHtAndTxIndex(height uint64, index uint64) *Transaction
- func (c *Context) GetTxByHash(txHash common.Hash) (tx *Transaction, err error)
- func (c *Context) GetTxListByHeight(height uint32) (txs []*Transaction, err error)
- func (c *Context) GetTxListByHeightWithRange(height uint32, start, end int) (txs []*Transaction, err error)
- func (c *Context) IncrNonce(sender common.Address, acc *AccountInfo)
- func (c *Context) QueryLogs(addresses []common.Address, topics [][]common.Hash, ...) (logs []Log, err error)
- func (c *Context) QueryTxByAddr(addr common.Address, startHeight, endHeight, limit uint32) (txs []*Transaction, err error)
- func (c *Context) QueryTxByDst(addr common.Address, startHeight, endHeight, limit uint32) (txs []*Transaction, err error)
- func (c *Context) QueryTxBySrc(addr common.Address, startHeight, endHeight, limit uint32) (txs []*Transaction, err error)
- func (c *Context) SetAccount(address common.Address, acc *AccountInfo)
- func (c *Context) SetCode(contract common.Address, code *BytecodeInfo)
- func (c *Context) SetCurrBlockBasicInfo(blk *Block)
- func (c *Context) SetStorageAt(seq uint64, key string, val []byte)
- func (c *Context) StoreBlock(blk *modbtypes.Block)
- func (c *Context) WithDb(db modbtypes.DB) *Context
- func (c *Context) WithRbt(rabbitStore *rabbit.RabbitStore) *Context
- func (c *Context) WithRbtCopy() *Context
- type Description
- type EvmLog
- type FilterFunc
- type Header
- type Log
- type SystemContractExecutor
- type Transaction
- type TxToRun
- type ValAddress
- type Validator
- type Validators
Constants ¶
const ( // ReceiptStatusFailed is the status code of a transaction if execution failed. ReceiptStatusFailed = uint64(0) // ReceiptStatusSuccessful is the status code of a transaction if execution succeeded. ReceiptStatusSuccessful = uint64(1) )
const ( BondStatusUnbonded = "Unbonded" BondStatusBonded = "Bonded" )
const ACCOUNT_KEY byte = 23
const ACCOUNT_NOT_EXIST int = 1026
const BYTECODE_KEY byte = 25
const CREATION_COUNTER_KEY byte = 21
const CURR_BLOCK_KEY byte = 29
const FAILED_TO_COMMIT int = 1025
const IGNORE_TOO_OLD_TX int = 1024
const TOO_OLD_THRESHOLD uint64 = 10
const TX_NONCE_TOO_LARGE int = 1029
const TX_NONCE_TOO_SMALL int = 1027
const VALUE_KEY byte = 27
Variables ¶
var ( ErrAccountNotExist = errors.New("account does not exist") ErrNonceTooSmall = errors.New("tx nonce is smaller than the account nonce") ErrNonceTooLarge = errors.New("tx nonce is larger than the account nonce") ErrTooManyEntries = errors.New("too many candidicate entries to be returned, please limit the difference between startHeight and endHeight") )
var ( ErrAccNotFound = errors.New("account not found") ErrCodeNotFound = errors.New("code not found") ErrBadAccData = errors.New("bad account data") ErrBadNonce = errors.New("bad nonce") ErrBadGasPrice = errors.New("bad gas price") ErrInsufficientBalance = errors.New("insufficient balance") ErrBlockNotFound = errors.New("block not found") ErrTxNotFound = errors.New("tx not found") ErrNoFromAddr = errors.New("missing from address") ErrInvalidHeight = errors.New("invalid height") )
var StandbyTxQueueKey [8]byte = [8]byte{255, 255, 255, 255, 255, 255, 255, 0}
Functions ¶
func FromGethAddreses ¶
func FromGethHashes ¶
func GetAccountKey ¶
func GetBytecodeKey ¶
func GetCreationCounterKey ¶
func GetStandbyTxKey ¶
func GetValueKey ¶
func ToGethHashes ¶
func ToGethLogs ¶
Types ¶
type AccountInfo ¶
type AccountInfo struct {
// contains filtered or unexported fields
}
func NewAccountInfo ¶
func NewAccountInfo(data []byte) *AccountInfo
func ZeroAccountInfo ¶
func ZeroAccountInfo() *AccountInfo
func (*AccountInfo) Balance ¶
func (info *AccountInfo) Balance() *uint256.Int
func (*AccountInfo) BalanceSlice ¶
func (info *AccountInfo) BalanceSlice() []byte
func (*AccountInfo) Bytes ¶
func (info *AccountInfo) Bytes() []byte
func (*AccountInfo) Nonce ¶
func (info *AccountInfo) Nonce() uint64
func (*AccountInfo) NonceSlice ¶
func (info *AccountInfo) NonceSlice() []byte
func (*AccountInfo) Sequence ¶
func (info *AccountInfo) Sequence() uint64
func (*AccountInfo) SequenceSlice ¶
func (info *AccountInfo) SequenceSlice() []byte
func (*AccountInfo) UpdateBalance ¶
func (info *AccountInfo) UpdateBalance(newBalance *uint256.Int)
func (*AccountInfo) UpdateNonce ¶
func (info *AccountInfo) UpdateNonce(newNonce uint64)
func (*AccountInfo) UpdateSequence ¶
func (info *AccountInfo) UpdateSequence(newSeq uint64)
type Block ¶
type Block struct { Number int64 `msg:"num"` //the block number. Null when the returned block is the pending block. Hash [32]byte `msg:"hash"` //32 Bytes - hash of the block. Null when the returned block is the pending block. ParentHash [32]byte `msg:"parent"` //32 Bytes - hash of the parent block. LogsBloom [256]byte `msg:"bloom"` // 256 Bytes - the bloom filter for the logs of the block. Null when the returned block is the pending block. TransactionsRoot [32]byte `msg:"troot"` // 32 Bytes - the root of the transaction trie of the block. StateRoot [32]byte `msg:"sroot"` //32 Bytes - the root of the final state trie of the block. Miner [20]byte `msg:"miner"` //20 Bytes - the address of the beneficiary to whom the mining rewards were given. Size int64 `msg:"size"` //integer the size of this block in bytes. GasUsed uint64 `msg:"gasused"` //the total used gas by all transactions in this block. Timestamp int64 `msg:"time"` //the unix timestamp for when the block was collated. Transactions [][32]byte `msg:"txs"` //Array - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter. }
BLOCK - A block object, or null when no block was found
func (*Block) FillBasicInfo ¶
func (*Block) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Block) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Block) SerializeBasicInfo ¶
type BondStatus ¶
type BondStatus uint64
BondStatus is the status of a validator
func (BondStatus) String ¶
func (b BondStatus) String() string
String implements the Stringer interface for BondStatus.
type BytecodeInfo ¶
type BytecodeInfo struct {
// contains filtered or unexported fields
}
func NewBytecodeInfo ¶
func NewBytecodeInfo(data []byte) *BytecodeInfo
func (*BytecodeInfo) BytecodeSlice ¶
func (info *BytecodeInfo) BytecodeSlice() []byte
func (*BytecodeInfo) Bytes ¶
func (info *BytecodeInfo) Bytes() []byte
func (*BytecodeInfo) CodeHashSlice ¶
func (info *BytecodeInfo) CodeHashSlice() []byte
type ChainEvent ¶
type ChainEvent struct { BlockHeader *Header Block *modbtypes.Block Hash gethcmn.Hash Logs []*gethtypes.Log }
type ChainEvent struct { Block *types.Block Hash common.Hash Logs []*types.Log }
type Context ¶
type Context struct { Height uint64 Rbt *rabbit.RabbitStore Db modbtypes.DB }
func NewContext ¶
func (*Context) BasicQueryLogs ¶
func (*Context) CheckNonce ¶
func (*Context) DeductTxFee ¶
func (*Context) DeleteAccount ¶
func (*Context) GetAccount ¶
func (c *Context) GetAccount(address common.Address) *AccountInfo
func (*Context) GetBalance ¶
func (*Context) GetBlockByHash ¶
func (*Context) GetBlockByHeight ¶
func (*Context) GetBlockHashByHeight ¶ added in v0.1.1
func (*Context) GetCurrBlockBasicInfo ¶
func (*Context) GetFromAddressCount ¶ added in v0.1.4
return the times addr acts as a from-address of a transaction
func (*Context) GetLatestHeight ¶
func (*Context) GetSep20FromAddressCount ¶ added in v0.1.1
return the times addr acts as a from-address of a SEP20 Transfer event at some contract
func (*Context) GetSep20ToAddressCount ¶ added in v0.1.1
return the times addr acts as a to-address of a SEP20 Transfer event at some contract
func (*Context) GetToAddressCount ¶ added in v0.1.1
return the times addr acts as a to-address of a transaction
func (*Context) GetTxByBlkHtAndTxIndex ¶
func (c *Context) GetTxByBlkHtAndTxIndex(height uint64, index uint64) *Transaction
func (*Context) GetTxByHash ¶
func (c *Context) GetTxByHash(txHash common.Hash) (tx *Transaction, err error)
func (*Context) GetTxListByHeight ¶
func (c *Context) GetTxListByHeight(height uint32) (txs []*Transaction, err error)
func (*Context) GetTxListByHeightWithRange ¶ added in v0.2.0
func (c *Context) GetTxListByHeightWithRange(height uint32, start, end int) (txs []*Transaction, err error)
func (*Context) QueryTxByAddr ¶
func (*Context) QueryTxByDst ¶
func (*Context) QueryTxBySrc ¶
func (*Context) SetAccount ¶
func (c *Context) SetAccount(address common.Address, acc *AccountInfo)
func (*Context) SetCurrBlockBasicInfo ¶
func (*Context) StoreBlock ¶
func (*Context) WithRbtCopy ¶
new empty rbt with same parent store as the old one
type Description ¶
type Description struct { Moniker string `json:"moniker" yaml:"moniker"` // name Identity string `json:"identity" yaml:"identity"` // optional identity signature (ex. UPort or Keybase) Website string `json:"website" yaml:"website"` // optional website link SecurityContact string `json:"security_contact" yaml:"security_contact"` // optional security contact info Details string `json:"details" yaml:"details"` // optional details }
Description - description fields for a validator
func NewDescription ¶
func NewDescription(moniker, identity, website, securityContact, details string) Description
NewDescription returns a new Description with the provided values.
type FilterFunc ¶ added in v0.2.0
type Log ¶
type Log struct { // Consensus fields: // address of the contract that generated the event Address [20]byte `msgp:"address"` // list of topics provided by the contract. Topics [][32]byte `msgp:"topics"` // supplied by the contract, usually ABI-encoded Data []byte `msgp:"data"` // Derived fields. These fields are filled in by the node // but not secured by consensus. // block in which the transaction was included BlockNumber uint64 `msgp:"blockNumber"` // hash of the transaction TxHash [32]byte `msgp:"transactionHash"` // index of the transaction in the block TxIndex uint `msgp:"transactionIndex"` // hash of the block in which the transaction was included BlockHash [32]byte `msgp:"blockHash"` // index of the log in the block Index uint `msgp:"logIndex"` // The Removed field is true if this log was reverted due to a chain reorganisation. // You must pay attention to this field if you receive logs through a filter query. Removed bool `msgp:"removed"` }
func (*Log) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type SystemContractExecutor ¶
type Transaction ¶
type Transaction struct { Hash [32]byte `msg:"hash"` //32 Bytes - hash of the transaction. TransactionIndex int64 `msg:"index"` //integer of the transactions index position in the block. null when its pending. Nonce uint64 `msg:"nonce"` //the number of transactions made by the sender prior to this one. BlockHash [32]byte `msg:"block"` //32 Bytes - hash of the block where this transaction was in. null when its pending. BlockNumber int64 `msg:"height"` //block number where this transaction was in. null when its pending. From [20]byte `msg:"from"` //20 Bytes - address of the sender. To [20]byte `msg:"to"` //20 Bytes - address of the receiver. null when its a contract creation transaction. Value [32]byte `msg:"value"` //value transferred in Wei. GasPrice [32]byte `msg:"gasprice"` //gas price provided by the sender in Wei. Gas uint64 `msg:"gas"` //gas provided by the sender. Input []byte `msg:"input"` //the data send along with the transaction. CumulativeGasUsed uint64 `msg:"cgasused"` // the total amount of gas used when this transaction was executed in the block. GasUsed uint64 `msg:"gasused"` //the amount of gas used by this specific transaction alone. ContractAddress [20]byte `msg:"contractaddr"` //20 Bytes - the contract address created, if the transaction was a contract creation, otherwise - null. Logs []Log `msg:"logs"` //Array - Array of log objects, which this transaction generated. LogsBloom [256]byte `msg:"bloom"` //256 Bytes - Bloom filter for light clients to quickly retrieve related logs. Status uint64 `msg:"status"` //tx execute result: ReceiptStatusFailed or ReceiptStatusSuccessful StatusStr string `msg:"statusstr"` //tx execute result explained OutData []byte `msg:"outdata"` //the output data from the transaction }
TRANSACTION - A transaction object, or null when no transaction was found
func (*Transaction) DecodeMsg ¶
func (z *Transaction) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*Transaction) EncodeMsg ¶
func (z *Transaction) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*Transaction) MarshalMsg ¶
func (z *Transaction) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*Transaction) Msgsize ¶
func (z *Transaction) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Transaction) UnmarshalMsg ¶
func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type TxToRun ¶
func (*TxToRun) FromGethTx ¶
type ValAddress ¶
type ValAddress []byte
type Validator ¶
type Validator struct { OperatorAddress ValAddress `json:"operator_address" yaml:"operator_address"` // address of the validator's operator; bech encoded in JSON ConsPubKey crypto.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` // the consensus public key of the validator; bech encoded in JSON //Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from bonded status? Status BondStatus `json:"status" yaml:"status"` // validator status (bonded/unbonded) Tokens *big.Int `json:"tokens" yaml:"tokens"` // delegated tokens Description Description `json:"description" yaml:"description"` // description terms for the validator }
func (Validator) MarshalJSON ¶
func (*Validator) UnmarshalJSON ¶
UnmarshalJSON unmarshals the validator from JSON using Bech32
type Validators ¶
type Validators []Validator
Validators is a collection of Validator
func (Validators) Sort ¶
func (v Validators) Sort()
Sort Validators sorts validator array in ascending operator address order
func (Validators) String ¶
func (v Validators) String() (out string)