Documentation ¶
Index ¶
- Variables
- func AddTestNetFunds(block *types.Block)
- func AddressFromMessage(msg Message) []byte
- func CalcDifficulty(block, parent *types.Block) *big.Int
- func DaggerVerify(hash, diff, nonce *big.Int) bool
- func Disassemble(script []byte) (asm []string)
- func EachTx(pool *list.List, it func(*types.Transaction, *list.Element) bool)
- func FindTx(pool *list.List, finder func(*types.Transaction, *list.Element) bool) *types.Transaction
- func IsGasLimitErr(err error) bool
- 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 Sum(sha hash.Hash) []byte
- func UncleError(str string) error
- type AccountChange
- type BlockManager
- func (sm *BlockManager) AccumelateRewards(statedb *state.StateDB, block, parent *types.Block) error
- func (self *BlockManager) ApplyTransactions(coinbase *state.StateObject, state *state.StateDB, block *types.Block, ...) (types.Receipts, types.Transactions, types.Transactions, types.Transactions, ...)
- func (sm *BlockManager) CalculateTD(block *types.Block) (*big.Int, bool)
- func (sm *BlockManager) GetMessages(block *types.Block) (messages []*state.Message, err error)
- func (sm *BlockManager) Process(block *types.Block) (td *big.Int, msgs state.Messages, err error)
- func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.Int, messages state.Messages, err error)
- func (sm *BlockManager) TransitionState(statedb *state.StateDB, parent, block *types.Block) (receipts types.Receipts, err error)
- func (sm *BlockManager) ValidateBlock(block, parent *types.Block) error
- type ChainManager
- func (bc *ChainManager) BlockInfo(block *types.Block) types.BlockInfo
- 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) GetBlock(hash []byte) *types.Block
- func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block
- func (self *ChainManager) GetChainHashesFromHash(hash []byte, max uint64) (chain [][]byte)
- func (bc *ChainManager) HasBlock(hash []byte) bool
- func (self *ChainManager) InsertChain(chain types.Blocks) error
- func (self *ChainManager) LastBlockHash() []byte
- func (self *ChainManager) LastBlockNumber() uint64
- 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 (bc *ChainManager) Stop()
- func (self *ChainManager) Td() *big.Int
- func (self *ChainManager) TransState() *state.StateDB
- type Dagger
- type EthManager
- type Execution
- type Filter
- func (self *Filter) AddAltered(address, stateAddress []byte)
- func (self *Filter) AddFrom(addr []byte)
- func (self *Filter) AddTo(addr []byte)
- func (self *Filter) FilterMessages(msgs []*state.Message) []*state.Message
- func (self *Filter) Find() []*state.Message
- func (self *Filter) SetEarliestBlock(earliest int64)
- func (self *Filter) SetFrom(addr [][]byte)
- func (self *Filter) SetLatestBlock(latest int64)
- func (self *Filter) SetMax(max int)
- func (self *Filter) SetSkip(skip int)
- func (self *Filter) SetTo(addr [][]byte)
- type GasLimitErr
- type KnownBlockError
- type Message
- type NewBlockEvent
- type NonceErr
- type OutOfGasErr
- type ParentErr
- type Peer
- 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
- func (self *StateTransition) VmEnv() vm.Environment
- type TDError
- type TxMsg
- type TxMsgTy
- type TxPool
- func (self *TxPool) Add(tx *types.Transaction) error
- func (pool *TxPool) CurrentTransactions() []*types.Transaction
- func (pool *TxPool) Flush() []*types.Transaction
- func (pool *TxPool) RemoveInvalid(state *state.StateDB)
- 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) BlockHash() []byte
- func (self *VMEnv) BlockNumber() *big.Int
- func (self *VMEnv) Call(me vm.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error)
- func (self *VMEnv) CallCode(me vm.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error)
- func (self *VMEnv) Coinbase() []byte
- func (self *VMEnv) Create(me vm.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ClosureRef)
- func (self *VMEnv) Depth() int
- func (self *VMEnv) Difficulty() *big.Int
- func (self *VMEnv) GasLimit() *big.Int
- func (self *VMEnv) Origin() []byte
- func (self *VMEnv) PrevHash() []byte
- func (self *VMEnv) SetDepth(i int)
- 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
- type ValidationErr
Constants ¶
This section is empty.
Variables ¶
var BlockReward *big.Int = big.NewInt(1.5e+18)
var EmptyListRoot = crypto.Sha3(ethutil.Encode(""))
var EmptyShaList = crypto.Sha3(ethutil.Encode([]interface{}{}))
var Found bool
var Genesis = []interface{}{GenesisHeader, []interface{}{}, []interface{}{}}
var GenesisHeader = []interface{}{ ZeroHash256, EmptyShaList, ZeroHash160, EmptyShaList, EmptyListRoot, EmptyListRoot, ZeroHash512, big.NewInt(131072), ethutil.Big0, big.NewInt(1000000), ethutil.Big0, ethutil.Big0, nil, crypto.Sha3(big.NewInt(42).Bytes()), }
var MinGasPrice = big.NewInt(10000000000000)
var ZeroHash160 = make([]byte, 20)
var ZeroHash256 = make([]byte, 32)
var ZeroHash512 = make([]byte, 64)
Functions ¶
func AddTestNetFunds ¶
func AddressFromMessage ¶
func DaggerVerify ¶
func Disassemble ¶
func FindTx ¶
func FindTx(pool *list.List, finder func(*types.Transaction, *list.Element) bool) *types.Transaction
func IsGasLimitErr ¶
func IsKnownBlockErr ¶
func IsNonceErr ¶
func IsOutOfGasErr ¶
func IsParentErr ¶
func IsUncleErr ¶
func IsValidationErr ¶
func MakeContract ¶
func MakeContract(msg Message, state *state.StateDB) *state.StateObject
Converts an transaction in to a state object
func MessageCreatesContract ¶
func MessageGasValue ¶
func ParentError ¶
func UncleError ¶
Types ¶
type AccountChange ¶
type AccountChange struct {
Address, StateAddress []byte
}
type BlockManager ¶
type BlockManager struct { // Proof of work used for validating Pow pow.PoW // contains filtered or unexported fields }
func NewBlockManager ¶
func NewBlockManager(txpool *TxPool, chainManager *ChainManager, eventMux *event.TypeMux) *BlockManager
func (*BlockManager) AccumelateRewards ¶
func (*BlockManager) ApplyTransactions ¶
func (self *BlockManager) ApplyTransactions(coinbase *state.StateObject, state *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, types.Transactions, types.Transactions, types.Transactions, error)
func (*BlockManager) CalculateTD ¶
func (*BlockManager) GetMessages ¶
func (*BlockManager) ProcessWithParent ¶
func (*BlockManager) TransitionState ¶
func (*BlockManager) ValidateBlock ¶
func (sm *BlockManager) 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 ¶
type ChainManager struct {
// contains filtered or unexported fields
}
func NewChainManager ¶
func NewChainManager(mux *event.TypeMux) *ChainManager
func (*ChainManager) BlockInfo ¶
func (bc *ChainManager) BlockInfo(block *types.Block) types.BlockInfo
func (*ChainManager) CalcTotalDiff ¶
func (*ChainManager) CurrentBlock ¶
func (self *ChainManager) CurrentBlock() *types.Block
func (*ChainManager) Export ¶
func (self *ChainManager) Export() []byte
func (*ChainManager) GetBlockByNumber ¶
func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block
func (*ChainManager) GetChainHashesFromHash ¶
func (self *ChainManager) GetChainHashesFromHash(hash []byte, max uint64) (chain [][]byte)
func (*ChainManager) HasBlock ¶
func (bc *ChainManager) HasBlock(hash []byte) bool
Block fetching methods
func (*ChainManager) InsertChain ¶
func (self *ChainManager) InsertChain(chain types.Blocks) error
func (*ChainManager) LastBlockHash ¶
func (self *ChainManager) LastBlockHash() []byte
func (*ChainManager) LastBlockNumber ¶
func (self *ChainManager) LastBlockNumber() uint64
func (*ChainManager) NewBlock ¶
func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block
Block creation & chain handling
func (*ChainManager) Reset ¶
func (bc *ChainManager) Reset()
func (*ChainManager) SetProcessor ¶
func (self *ChainManager) SetProcessor(proc types.BlockProcessor)
func (*ChainManager) State ¶
func (self *ChainManager) State() *state.StateDB
func (*ChainManager) Stop ¶
func (bc *ChainManager) Stop()
func (*ChainManager) Td ¶
func (self *ChainManager) Td() *big.Int
func (*ChainManager) TransState ¶
func (self *ChainManager) TransState() *state.StateDB
type EthManager ¶
type EthManager interface { BlockManager() *BlockManager ChainManager() *ChainManager TxPool() *TxPool Broadcast(msgType wire.MsgType, data []interface{}) PeerCount() int IsMining() bool IsListening() bool Peers() *list.List KeyManager() *crypto.KeyManager ClientIdentity() wire.ClientIdentity Db() ethutil.Database EventMux() *event.TypeMux }
type Execution ¶
func NewExecution ¶
func (*Execution) Create ¶
func (self *Execution) Create(caller vm.ClosureRef) (ret []byte, err error, account *state.StateObject)
type Filter ¶
type Filter struct { Altered []AccountChange BlockCallback func(*types.Block) MessageCallback func(state.Messages) // contains filtered or unexported fields }
Filtering interface
func NewFilter ¶
func NewFilter(eth EthManager) *Filter
Create a new filter which uses a bloom filter on blocks to figure out whether a particular block is interesting or not.
func (*Filter) AddAltered ¶
func (*Filter) FilterMessages ¶
func (*Filter) SetEarliestBlock ¶
Set the earliest and latest block for filtering. -1 = latest block (i.e., the current block) hash = particular hash from-to
func (*Filter) SetLatestBlock ¶
type GasLimitErr ¶
func GasLimitError ¶
func GasLimitError(is, max *big.Int) *GasLimitErr
func (*GasLimitErr) Error ¶
func (err *GasLimitErr) Error() string
type KnownBlockError ¶
type KnownBlockError struct {
// contains filtered or unexported fields
}
func (*KnownBlockError) Error ¶
func (self *KnownBlockError) Error() string
type NewBlockEvent ¶
NewBlockEvent is posted when a block has been imported.
type NonceErr ¶
func NonceError ¶
type OutOfGasErr ¶
type OutOfGasErr struct {
Message string
}
func OutOfGasError ¶
func OutOfGasError() *OutOfGasErr
func (*OutOfGasErr) Error ¶
func (self *OutOfGasErr) Error() string
type ParentErr ¶
type ParentErr struct {
Message string
}
Parent error. In case a parent is unknown this error will be thrown by the block manager
type StateTransition ¶
type StateTransition struct { Env vm.Environment // 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(coinbase *state.StateObject, msg Message, state *state.StateDB, block *types.Block) *StateTransition
func (*StateTransition) AddGas ¶
func (self *StateTransition) AddGas(amount *big.Int)
func (*StateTransition) BuyGas ¶
func (self *StateTransition) BuyGas() error
func (*StateTransition) Coinbase ¶
func (self *StateTransition) Coinbase() *state.StateObject
func (*StateTransition) From ¶
func (self *StateTransition) From() *state.StateObject
func (*StateTransition) GasUsed ¶
func (self *StateTransition) GasUsed() *big.Int
func (*StateTransition) RefundGas ¶
func (self *StateTransition) RefundGas()
func (*StateTransition) To ¶
func (self *StateTransition) To() *state.StateObject
func (*StateTransition) TransitionState ¶
func (self *StateTransition) TransitionState() (ret []byte, err error)
func (*StateTransition) VmEnv ¶
func (self *StateTransition) VmEnv() vm.Environment
type TxMsg ¶
type TxMsg struct { Tx *types.Transaction Type TxMsgTy }
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. If the pool is being drained or synced for whatever reason the transactions will simple queue up and handled when the mutex is freed.
func NewTxPool ¶
func NewTxPool(chainManager *ChainManager, broadcaster types.Broadcaster, eventMux *event.TypeMux) *TxPool
func (*TxPool) CurrentTransactions ¶
func (pool *TxPool) CurrentTransactions() []*types.Transaction
func (*TxPool) Flush ¶
func (pool *TxPool) Flush() []*types.Transaction
func (*TxPool) RemoveInvalid ¶
func (*TxPool) RemoveSet ¶
func (self *TxPool) RemoveSet(txs types.Transactions)
func (*TxPool) ValidateTransaction ¶
func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error
type TxPoolHook ¶
type TxPoolHook chan *types.Transaction
type TxPostEvent ¶
type TxPostEvent struct{ Tx *types.Transaction }
TxPostEvent is posted when a transaction has been processed.
type TxPreEvent ¶
type TxPreEvent struct{ Tx *types.Transaction }
TxPreEvent is posted when a transaction enters the transaction pool.
type TxProcessor ¶
type TxProcessor interface {
ProcessTransaction(tx *types.Transaction)
}
type VMEnv ¶
type VMEnv struct {
// contains filtered or unexported fields
}
func (*VMEnv) BlockNumber ¶
func (*VMEnv) Create ¶
func (self *VMEnv) Create(me vm.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ClosureRef)
func (*VMEnv) Difficulty ¶
type ValidationErr ¶
type ValidationErr struct {
Message string
}
Block validation error. If any validation fails, this error will be thrown
func ValidationError ¶
func ValidationError(format string, v ...interface{}) *ValidationErr
func (*ValidationErr) Error ¶
func (err *ValidationErr) Error() string