Documentation ¶
Index ¶
- Variables
- func AddressFromMessage(msg Message) []byte
- func CalcDifficulty(block, parent *types.Block) *big.Int
- func CalcGasLimit(parent, block *types.Block) *big.Int
- func CalculateTD(block, parent *types.Block) *big.Int
- func Disassemble(script []byte) (asm []string)
- func GenesisBlock(db ethutil.Database) *types.Block
- func IsKnownBlockErr(e error) bool
- func IsNonceErr(err error) bool
- func IsOutOfGasErr(err error) bool
- func IsParentErr(err error) bool
- func IsTDError(e error) bool
- func IsUncleErr(err error) bool
- func IsValidationErr(err error) bool
- func MakeContract(msg Message, state *state.StateDB) *state.StateObject
- func MessageCreatesContract(msg Message) bool
- func MessageGasValue(msg Message) *big.Int
- func ParentError(hash []byte) error
- func UncleError(str string) error
- type AccountChange
- type Backend
- type BlockProcessor
- func (sm *BlockProcessor) AccumulateRewards(statedb *state.StateDB, block, parent *types.Block) error
- func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, ...) (*types.Receipt, *big.Int, error)
- func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, ...) (types.Receipts, types.Transactions, types.Transactions, types.Transactions, ...)
- func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err error)
- func (sm *BlockProcessor) Process(block *types.Block) (td *big.Int, err error)
- func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block *types.Block, transientProcess bool) (receipts types.Receipts, err error)
- func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error
- type ChainEvent
- type ChainManager
- func (self *ChainManager) CalcTotalDiff(block *types.Block) (*big.Int, error)
- func (self *ChainManager) CurrentBlock() *types.Block
- func (self *ChainManager) Export() []byte
- func (bc *ChainManager) Genesis() *types.Block
- func (self *ChainManager) GetAccount(addr []byte) *state.StateObject
- func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks []*types.Block)
- func (self *ChainManager) GetBlock(hash []byte) *types.Block
- func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block
- func (self *ChainManager) GetBlockHashesFromHash(hash []byte, max uint64) (chain [][]byte)
- func (self *ChainManager) GetUnclesInChain(block *types.Block, length int) (uncles []*types.Header)
- func (bc *ChainManager) HasBlock(hash []byte) bool
- func (self *ChainManager) InsertChain(chain types.Blocks) error
- func (self *ChainManager) LastBlockHash() []byte
- func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block
- func (bc *ChainManager) Reset()
- func (self *ChainManager) SetProcessor(proc types.BlockProcessor)
- func (self *ChainManager) State() *state.StateDB
- func (self *ChainManager) Status() (td *big.Int, currentBlock []byte, genesisBlock []byte)
- func (bc *ChainManager) Stop()
- func (self *ChainManager) Td() *big.Int
- func (self *ChainManager) TransState() *state.StateDB
- func (self *ChainManager) TxState() *state.StateDB
- type ChainSplitEvent
- type Execution
- type Filter
- func (self *Filter) FilterLogs(logs state.Logs) state.Logs
- func (self *Filter) Find() state.Logs
- func (self *Filter) SetAddress(addr [][]byte)
- func (self *Filter) SetEarliestBlock(earliest int64)
- func (self *Filter) SetLatestBlock(latest int64)
- func (self *Filter) SetMax(max int)
- func (self *Filter) SetOptions(options FilterOptions)
- func (self *Filter) SetSkip(skip int)
- func (self *Filter) SetTopics(topics [][]byte)
- type FilterOptions
- type KnownBlockError
- type Message
- type NewBlockEvent
- type NewMinedBlockEvent
- type NonceErr
- type OutOfGasErr
- type ParentErr
- type PendingBlockEvent
- type StateQuery
- type StateTransition
- func (self *StateTransition) AddGas(amount *big.Int)
- func (self *StateTransition) BuyGas() error
- func (self *StateTransition) Coinbase() *state.StateObject
- func (self *StateTransition) From() *state.StateObject
- func (self *StateTransition) GasUsed() *big.Int
- func (self *StateTransition) RefundGas()
- func (self *StateTransition) To() *state.StateObject
- func (self *StateTransition) TransitionState() (ret []byte, err error)
- func (self *StateTransition) UseGas(amount *big.Int) error
- type TDError
- type TxMsg
- type TxPool
- func (self *TxPool) Add(tx *types.Transaction) error
- func (self *TxPool) AddTransactions(txs []*types.Transaction)
- func (pool *TxPool) Flush()
- func (self *TxPool) GetTransactions() (txs types.Transactions)
- func (pool *TxPool) RemoveInvalid(query StateQuery)
- func (self *TxPool) RemoveSet(txs types.Transactions)
- func (self *TxPool) Size() int
- func (pool *TxPool) Start()
- func (pool *TxPool) Stop()
- func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error
- type TxPoolHook
- type TxPostEvent
- type TxPreEvent
- type TxProcessor
- type UncleErr
- type VMEnv
- func (self *VMEnv) AddLog(log state.Log)
- func (self *VMEnv) BlockNumber() *big.Int
- func (self *VMEnv) Call(me vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error)
- func (self *VMEnv) CallCode(me vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error)
- func (self *VMEnv) Coinbase() []byte
- func (self *VMEnv) Create(me vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ContextRef)
- func (self *VMEnv) Depth() int
- func (self *VMEnv) Difficulty() *big.Int
- func (self *VMEnv) GasLimit() *big.Int
- func (self *VMEnv) GetHash(n uint64) []byte
- func (self *VMEnv) Origin() []byte
- func (self *VMEnv) SetDepth(i int)
- func (self *VMEnv) SetVmType(t vm.Type)
- func (self *VMEnv) State() *state.StateDB
- func (self *VMEnv) Time() int64
- func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error
- func (self *VMEnv) Value() *big.Int
- func (self *VMEnv) VmType() vm.Type
- type ValidationErr
Constants ¶
This section is empty.
Variables ¶
var ( BlockNumberErr = errors.New("block number invalid") BlockFutureErr = errors.New("block time is in the future") )
var BlockReward *big.Int = big.NewInt(1.5e+18)
var EmptyListRoot = crypto.Sha3(ethutil.Encode(""))
var EmptyShaList = crypto.Sha3(ethutil.Encode([]interface{}{}))
var (
ErrInvalidSender = errors.New("Invalid sender")
)
var ZeroHash160 = make([]byte, 20)
var ZeroHash256 = make([]byte, 32)
var ZeroHash512 = make([]byte, 64)
Functions ¶
func AddressFromMessage ¶ added in v0.7.10
func Disassemble ¶ added in v0.7.10
func IsKnownBlockErr ¶ added in v0.7.10
func IsNonceErr ¶ added in v0.7.10
func IsOutOfGasErr ¶ added in v0.7.10
func IsParentErr ¶ added in v0.7.10
func IsUncleErr ¶ added in v0.7.10
func IsValidationErr ¶ added in v0.7.10
func MakeContract ¶ added in v0.7.10
func MakeContract(msg Message, state *state.StateDB) *state.StateObject
Converts an transaction in to a state object
func MessageCreatesContract ¶ added in v0.7.10
func MessageGasValue ¶ added in v0.7.10
func ParentError ¶ added in v0.7.10
func UncleError ¶ added in v0.7.10
Types ¶
type AccountChange ¶ added in v0.7.10
type AccountChange struct {
Address, StateAddress []byte
}
type Backend ¶ added in v0.8.4
type Backend interface { BlockProcessor() *BlockProcessor ChainManager() *ChainManager TxPool() *TxPool PeerCount() int IsListening() bool Peers() []*p2p.Peer KeyManager() *crypto.KeyManager Db() ethutil.Database EventMux() *event.TypeMux }
type BlockProcessor ¶ added in v0.8.4
type BlockProcessor struct { // Proof of work used for validating Pow pow.PoW // contains filtered or unexported fields }
func NewBlockProcessor ¶ added in v0.8.4
func NewBlockProcessor(db ethutil.Database, txpool *TxPool, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor
func (*BlockProcessor) AccumulateRewards ¶ added in v0.8.4
func (*BlockProcessor) ApplyTransaction ¶ added in v0.8.4
func (*BlockProcessor) ApplyTransactions ¶ added in v0.8.4
func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, types.Transactions, types.Transactions, types.Transactions, error)
func (*BlockProcessor) Process ¶ added in v0.8.4
Process block will attempt to process the given block's transactions and applies them on top of the block's parent state (given it exists) and will return wether it was successful or not.
func (*BlockProcessor) TransitionState ¶ added in v0.8.4
func (*BlockProcessor) ValidateBlock ¶ added in v0.8.4
func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error
Validates the current block. Returns an error if the block was invalid, an uncle or anything that isn't on the current block chain. Validation validates easy over difficult (dagger takes longer time = difficult)
type ChainManager ¶ added in v0.7.10
type ChainManager struct {
// contains filtered or unexported fields
}
func NewChainManager ¶ added in v0.7.10
func NewChainManager(db ethutil.Database, mux *event.TypeMux) *ChainManager
func (*ChainManager) CalcTotalDiff ¶ added in v0.7.10
func (*ChainManager) CurrentBlock ¶ added in v0.7.10
func (self *ChainManager) CurrentBlock() *types.Block
func (*ChainManager) Export ¶ added in v0.7.10
func (self *ChainManager) Export() []byte
func (*ChainManager) Genesis ¶ added in v0.7.10
func (bc *ChainManager) Genesis() *types.Block
Accessors
func (*ChainManager) GetAccount ¶ added in v0.8.4
func (self *ChainManager) GetAccount(addr []byte) *state.StateObject
Satisfy state query interface
func (*ChainManager) GetAncestors ¶ added in v0.8.4
func (*ChainManager) GetBlock ¶ added in v0.7.10
func (self *ChainManager) GetBlock(hash []byte) *types.Block
func (*ChainManager) GetBlockByNumber ¶ added in v0.7.10
func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block
func (*ChainManager) GetBlockHashesFromHash ¶ added in v0.8.4
func (self *ChainManager) GetBlockHashesFromHash(hash []byte, max uint64) (chain [][]byte)
func (*ChainManager) GetUnclesInChain ¶ added in v0.8.4
func (*ChainManager) HasBlock ¶ added in v0.7.10
func (bc *ChainManager) HasBlock(hash []byte) bool
Block fetching methods
func (*ChainManager) InsertChain ¶ added in v0.7.10
func (self *ChainManager) InsertChain(chain types.Blocks) error
func (*ChainManager) LastBlockHash ¶ added in v0.7.10
func (self *ChainManager) LastBlockHash() []byte
func (*ChainManager) NewBlock ¶ added in v0.7.10
func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block
Block creation & chain handling
func (*ChainManager) Reset ¶ added in v0.7.10
func (bc *ChainManager) Reset()
func (*ChainManager) SetProcessor ¶ added in v0.7.10
func (self *ChainManager) SetProcessor(proc types.BlockProcessor)
func (*ChainManager) State ¶ added in v0.7.10
func (self *ChainManager) State() *state.StateDB
func (*ChainManager) Status ¶ added in v0.8.4
func (self *ChainManager) Status() (td *big.Int, currentBlock []byte, genesisBlock []byte)
func (*ChainManager) Stop ¶ added in v0.7.10
func (bc *ChainManager) Stop()
func (*ChainManager) Td ¶ added in v0.7.10
func (self *ChainManager) Td() *big.Int
func (*ChainManager) TransState ¶ added in v0.7.10
func (self *ChainManager) TransState() *state.StateDB
func (*ChainManager) TxState ¶ added in v0.9.17
func (self *ChainManager) TxState() *state.StateDB
type ChainSplitEvent ¶ added in v0.8.4
ChainSplit is posted when a new head is detected
type Execution ¶ added in v0.7.10
func NewExecution ¶ added in v0.7.10
func (*Execution) Create ¶ added in v0.7.10
func (self *Execution) Create(caller vm.ContextRef) (ret []byte, err error, account *state.StateObject)
type Filter ¶ added in v0.7.10
type Filter struct { BlockCallback func(*types.Block) PendingCallback func(*types.Block) LogsCallback func(state.Logs) // contains filtered or unexported fields }
Filtering interface
func NewFilter ¶ added in v0.7.10
Create a new filter which uses a bloom filter on blocks to figure out whether a particular block is interesting or not.
func (*Filter) FilterLogs ¶ added in v0.8.4
func (*Filter) SetAddress ¶ added in v0.8.4
func (*Filter) SetEarliestBlock ¶ added in v0.7.10
Set the earliest and latest block for filtering. -1 = latest block (i.e., the current block) hash = particular hash from-to
func (*Filter) SetLatestBlock ¶ added in v0.7.10
func (*Filter) SetOptions ¶ added in v0.8.4
func (self *Filter) SetOptions(options FilterOptions)
type FilterOptions ¶ added in v0.8.4
type KnownBlockError ¶ added in v0.7.10
type KnownBlockError struct {
// contains filtered or unexported fields
}
func (*KnownBlockError) Error ¶ added in v0.7.10
func (self *KnownBlockError) Error() string
type NewBlockEvent ¶ added in v0.7.10
NewBlockEvent is posted when a block has been imported.
type NewMinedBlockEvent ¶
NewMinedBlockEvent is posted when a block has been imported.
type NonceErr ¶ added in v0.7.10
func NonceError ¶ added in v0.7.10
type OutOfGasErr ¶ added in v0.7.10
type OutOfGasErr struct {
Message string
}
func OutOfGasError ¶ added in v0.7.10
func OutOfGasError() *OutOfGasErr
func (*OutOfGasErr) Error ¶ added in v0.7.10
func (self *OutOfGasErr) Error() string
type ParentErr ¶ added in v0.7.10
type ParentErr struct {
Message string
}
Parent error. In case a parent is unknown this error will be thrown by the block manager
type PendingBlockEvent ¶ added in v0.8.4
type StateQuery ¶ added in v0.8.4
type StateQuery interface {
GetAccount(addr []byte) *state.StateObject
}
type StateTransition ¶
type StateTransition struct {
// contains filtered or unexported fields
}
* The State transitioning model * * A state transition is a change made when a transaction is applied to the current world state * The state transitioning model does all all the necessary work to work out a valid new state root. * 1) Nonce handling * 2) Pre pay / buy gas of the coinbase (miner) * 3) Create a new state object if the recipient is \0*32 * 4) Value transfer * == If contract creation == * 4a) Attempt to run transaction data * 4b) If valid, use result as code for the new state object * == end == * 5) Run Script section * 6) Derive new state root
func NewStateTransition ¶
func NewStateTransition(env vm.Environment, msg Message, coinbase *state.StateObject) *StateTransition
func (*StateTransition) AddGas ¶ added in v0.7.10
func (self *StateTransition) AddGas(amount *big.Int)
func (*StateTransition) BuyGas ¶ added in v0.7.10
func (self *StateTransition) BuyGas() error
func (*StateTransition) Coinbase ¶ added in v0.7.10
func (self *StateTransition) Coinbase() *state.StateObject
func (*StateTransition) From ¶ added in v0.7.10
func (self *StateTransition) From() *state.StateObject
func (*StateTransition) GasUsed ¶ added in v0.7.10
func (self *StateTransition) GasUsed() *big.Int
func (*StateTransition) RefundGas ¶ added in v0.7.10
func (self *StateTransition) RefundGas()
func (*StateTransition) To ¶ added in v0.7.10
func (self *StateTransition) To() *state.StateObject
func (*StateTransition) TransitionState ¶ added in v0.7.10
func (self *StateTransition) TransitionState() (ret []byte, err error)
type TxMsg ¶ added in v0.7.10
type TxMsg struct {
Tx *types.Transaction
}
type TxPool ¶
type TxPool struct { SecondaryProcessor TxProcessor // contains filtered or unexported fields }
The tx pool a thread safe transaction pool handler. In order to guarantee a non blocking pool we use a queue channel which can be independently read without needing access to the actual pool.
func (*TxPool) AddTransactions ¶ added in v0.8.4
func (self *TxPool) AddTransactions(txs []*types.Transaction)
func (*TxPool) GetTransactions ¶ added in v0.8.4
func (self *TxPool) GetTransactions() (txs types.Transactions)
func (*TxPool) RemoveInvalid ¶ added in v0.7.10
func (pool *TxPool) RemoveInvalid(query StateQuery)
func (*TxPool) RemoveSet ¶ added in v0.7.10
func (self *TxPool) RemoveSet(txs types.Transactions)
func (*TxPool) ValidateTransaction ¶ added in v0.7.10
func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error
type TxPoolHook ¶ added in v0.7.10
type TxPoolHook chan *types.Transaction
type TxPostEvent ¶ added in v0.7.10
type TxPostEvent struct{ Tx *types.Transaction }
TxPostEvent is posted when a transaction has been processed.
type TxPreEvent ¶ added in v0.7.10
type TxPreEvent struct{ Tx *types.Transaction }
TxPreEvent is posted when a transaction enters the transaction pool.
type TxProcessor ¶ added in v0.7.10
type TxProcessor interface {
ProcessTransaction(tx *types.Transaction)
}
type VMEnv ¶ added in v0.7.10
type VMEnv struct {
// contains filtered or unexported fields
}
func (*VMEnv) BlockNumber ¶ added in v0.7.10
func (*VMEnv) Create ¶ added in v0.7.10
func (self *VMEnv) Create(me vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ContextRef)
func (*VMEnv) Difficulty ¶ added in v0.7.10
type ValidationErr ¶ added in v0.7.10
type ValidationErr struct {
Message string
}
Block validation error. If any validation fails, this error will be thrown
func ValidationError ¶ added in v0.7.10
func ValidationError(format string, v ...interface{}) *ValidationErr
func (*ValidationErr) Error ¶ added in v0.7.10
func (err *ValidationErr) Error() string