core

package
v0.8.4-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2015 License: LGPL-2.1-or-later Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BlockNumberErr = errors.New("block number invalid")
	BlockFutureErr = errors.New("block time is in the future")
)
View Source
var BlockReward *big.Int = big.NewInt(1.5e+18)
View Source
var EmptyListRoot = crypto.Sha3(ethutil.Encode(""))
View Source
var EmptyShaList = crypto.Sha3(ethutil.Encode([]interface{}{}))
View Source
var (
	ErrInvalidSender = errors.New("Invalid sender")
)
View Source
var ZeroHash160 = make([]byte, 20)
View Source
var ZeroHash256 = make([]byte, 32)
View Source
var ZeroHash512 = make([]byte, 64)

Functions

func AddressFromMessage

func AddressFromMessage(msg Message) []byte

func CalcDifficulty

func CalcDifficulty(block, parent *types.Block) *big.Int

func CalcGasLimit added in v0.8.5

func CalcGasLimit(parent, block *types.Block) *big.Int

func CalculateTD added in v0.8.5

func CalculateTD(block, parent *types.Block) *big.Int

func Disassemble

func Disassemble(script []byte) (asm []string)

func GenesisBlock added in v0.8.5

func GenesisBlock(db ethutil.Database) *types.Block

func IsKnownBlockErr

func IsKnownBlockErr(e error) bool

func IsNonceErr

func IsNonceErr(err error) bool

func IsOutOfGasErr

func IsOutOfGasErr(err error) bool

func IsParentErr

func IsParentErr(err error) bool

func IsTDError

func IsTDError(e error) bool

func IsUncleErr

func IsUncleErr(err error) bool

func IsValidationErr

func IsValidationErr(err error) bool

func MakeContract

func MakeContract(msg Message, state *state.StateDB) *state.StateObject

Converts an transaction in to a state object

func MessageCreatesContract

func MessageCreatesContract(msg Message) bool

func MessageGasValue

func MessageGasValue(msg Message) *big.Int

func ParentError

func ParentError(hash []byte) error

func UncleError

func UncleError(str string) error

Types

type AccountChange

type AccountChange struct {
	Address, StateAddress []byte
}

type Backend added in v0.8.5

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.5

type BlockProcessor struct {

	// Proof of work used for validating
	Pow pow.PoW
	// contains filtered or unexported fields
}

func NewBlockProcessor added in v0.8.5

func NewBlockProcessor(db ethutil.Database, txpool *TxPool, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor

func (*BlockProcessor) AccumulateRewards added in v0.8.5

func (sm *BlockProcessor) AccumulateRewards(statedb *state.StateDB, block, parent *types.Block) error

func (*BlockProcessor) ApplyTransaction added in v0.8.5

func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, tx *types.Transaction, usedGas *big.Int, transientProcess bool) (*types.Receipt, *big.Int, error)

func (*BlockProcessor) ApplyTransactions added in v0.8.5

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) GetLogs added in v0.8.5

func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err error)

func (*BlockProcessor) Process added in v0.8.5

func (sm *BlockProcessor) Process(block *types.Block) (td *big.Int, err error)

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.5

func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block *types.Block) (receipts types.Receipts, err error)

func (*BlockProcessor) ValidateBlock added in v0.8.5

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 ChainEvent added in v0.8.5

type ChainEvent struct {
	Block *types.Block
	Td    *big.Int
}

type ChainManager

type ChainManager struct {
	// contains filtered or unexported fields
}

func NewChainManager

func NewChainManager(db ethutil.Database, mux *event.TypeMux) *ChainManager

func (*ChainManager) CalcTotalDiff

func (self *ChainManager) CalcTotalDiff(block *types.Block) (*big.Int, error)

func (*ChainManager) CurrentBlock

func (self *ChainManager) CurrentBlock() *types.Block

func (*ChainManager) Export

func (self *ChainManager) Export() []byte

func (*ChainManager) Genesis

func (bc *ChainManager) Genesis() *types.Block

Accessors

func (*ChainManager) GetAccount added in v0.8.5

func (self *ChainManager) GetAccount(addr []byte) *state.StateObject

Satisfy state query interface

func (*ChainManager) GetAncestors added in v0.8.5

func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks []*types.Block)

func (*ChainManager) GetBlock

func (self *ChainManager) GetBlock(hash []byte) *types.Block

func (*ChainManager) GetBlockByNumber

func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block

func (*ChainManager) GetBlockHashesFromHash added in v0.8.5

func (self *ChainManager) GetBlockHashesFromHash(hash []byte, max uint64) (chain [][]byte)

func (*ChainManager) GetUnclesInChain added in v0.8.5

func (self *ChainManager) GetUnclesInChain(block *types.Block, length int) (uncles []*types.Header)

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) 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) Status added in v0.8.5

func (self *ChainManager) Status() (td *big.Int, currentBlock []byte, genesisBlock []byte)

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 ChainSplitEvent added in v0.8.5

type ChainSplitEvent struct{ Block *types.Block }

ChainSplit is posted when a new head is detected

type Execution

type Execution struct {
	Gas *big.Int
	// contains filtered or unexported fields
}

func NewExecution

func NewExecution(env vm.Environment, address, input []byte, gas, gasPrice, value *big.Int) *Execution

func (*Execution) Addr

func (self *Execution) Addr() []byte

func (*Execution) Call

func (self *Execution) Call(codeAddr []byte, caller vm.ContextRef) ([]byte, error)

func (*Execution) Create

func (self *Execution) Create(caller vm.ContextRef) (ret []byte, err error, account *state.StateObject)

type Filter

type Filter struct {
	BlockCallback   func(*types.Block)
	PendingCallback func(*types.Block)
	LogsCallback    func(state.Logs)
	// contains filtered or unexported fields
}

Filtering interface

func NewFilter

func NewFilter(eth Backend) *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) FilterLogs added in v0.8.5

func (self *Filter) FilterLogs(logs state.Logs) state.Logs

func (*Filter) Find

func (self *Filter) Find() state.Logs

Run filters logs with the current parameters set

func (*Filter) SetAddress added in v0.8.5

func (self *Filter) SetAddress(addr [][]byte)

func (*Filter) SetEarliestBlock

func (self *Filter) SetEarliestBlock(earliest int64)

Set the earliest and latest block for filtering. -1 = latest block (i.e., the current block) hash = particular hash from-to

func (*Filter) SetLatestBlock

func (self *Filter) SetLatestBlock(latest int64)

func (*Filter) SetMax

func (self *Filter) SetMax(max int)

func (*Filter) SetOptions added in v0.8.5

func (self *Filter) SetOptions(options FilterOptions)

func (*Filter) SetSkip

func (self *Filter) SetSkip(skip int)

func (*Filter) SetTopics added in v0.8.5

func (self *Filter) SetTopics(topics [][]byte)

type FilterOptions added in v0.8.5

type FilterOptions struct {
	Earliest int64
	Latest   int64

	Address [][]byte
	Topics  [][]byte

	Skip int
	Max  int
}

type KnownBlockError

type KnownBlockError struct {
	// contains filtered or unexported fields
}

func (*KnownBlockError) Error

func (self *KnownBlockError) Error() string

type Message

type Message interface {
	Hash() []byte

	From() []byte
	To() []byte

	GasPrice() *big.Int
	Gas() *big.Int
	Value() *big.Int

	Nonce() uint64
	Data() []byte
}

type NewBlockEvent

type NewBlockEvent struct{ Block *types.Block }

NewBlockEvent is posted when a block has been imported.

type NewMinedBlockEvent added in v0.8.5

type NewMinedBlockEvent struct{ Block *types.Block }

NewMinedBlockEvent is posted when a block has been imported.

type NonceErr

type NonceErr struct {
	Message string
	Is, Exp uint64
}

func NonceError

func NonceError(is, exp uint64) *NonceErr

func (*NonceErr) Error

func (err *NonceErr) Error() string

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

func (*ParentErr) Error

func (err *ParentErr) Error() string

type PendingBlockEvent added in v0.8.5

type PendingBlockEvent struct {
	Block *types.Block
}

type StateQuery added in v0.8.5

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

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) UseGas

func (self *StateTransition) UseGas(amount *big.Int) error

type TDError

type TDError struct {
	// contains filtered or unexported fields
}

func (*TDError) Error

func (self *TDError) Error() string

type TxMsg

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 NewTxPool

func NewTxPool(eventMux *event.TypeMux) *TxPool

func (*TxPool) Add

func (self *TxPool) Add(tx *types.Transaction) error

func (*TxPool) AddTransactions added in v0.8.5

func (self *TxPool) AddTransactions(txs []*types.Transaction)

func (*TxPool) Flush

func (pool *TxPool) Flush()

func (*TxPool) GetTransactions added in v0.8.5

func (self *TxPool) GetTransactions() (txs types.Transactions)

func (*TxPool) RemoveInvalid

func (pool *TxPool) RemoveInvalid(query StateQuery)

func (*TxPool) RemoveSet

func (self *TxPool) RemoveSet(txs types.Transactions)

func (*TxPool) Size

func (self *TxPool) Size() int

func (*TxPool) Start

func (pool *TxPool) Start()

func (*TxPool) Stop

func (pool *TxPool) Stop()

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 UncleErr

type UncleErr struct {
	Message string
}

func (*UncleErr) Error

func (err *UncleErr) Error() string

type VMEnv

type VMEnv struct {
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv(state *state.StateDB, chain *ChainManager, msg Message, block *types.Block) *VMEnv

func (*VMEnv) AddLog

func (self *VMEnv) AddLog(log state.Log)

func (*VMEnv) BlockNumber

func (self *VMEnv) BlockNumber() *big.Int

func (*VMEnv) Call

func (self *VMEnv) Call(me vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error)

func (*VMEnv) CallCode

func (self *VMEnv) CallCode(me vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error)

func (*VMEnv) Coinbase

func (self *VMEnv) Coinbase() []byte

func (*VMEnv) Create

func (self *VMEnv) Create(me vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ContextRef)

func (*VMEnv) Depth

func (self *VMEnv) Depth() int

func (*VMEnv) Difficulty

func (self *VMEnv) Difficulty() *big.Int

func (*VMEnv) GasLimit

func (self *VMEnv) GasLimit() *big.Int

func (*VMEnv) GetHash added in v0.8.5

func (self *VMEnv) GetHash(n uint64) []byte

func (*VMEnv) Origin

func (self *VMEnv) Origin() []byte

func (*VMEnv) SetDepth

func (self *VMEnv) SetDepth(i int)

func (*VMEnv) SetVmType added in v0.8.5

func (self *VMEnv) SetVmType(t vm.Type)

func (*VMEnv) State

func (self *VMEnv) State() *state.StateDB

func (*VMEnv) Time

func (self *VMEnv) Time() int64

func (*VMEnv) Transfer

func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error

func (*VMEnv) Value

func (self *VMEnv) Value() *big.Int

func (*VMEnv) VmType added in v0.8.5

func (self *VMEnv) VmType() vm.Type

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL