core

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2014 License: LGPL-2.1-or-later Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 Found bool
View Source
var Genesis = []interface{}{GenesisHeader, []interface{}{}, []interface{}{}}
View Source
var MinGasPrice = big.NewInt(10000000000000)
View Source
var ZeroHash160 = make([]byte, 20)
View Source
var ZeroHash256 = make([]byte, 32)
View Source
var ZeroHash512 = make([]byte, 64)

Functions

func AddTestNetFunds added in v0.7.10

func AddTestNetFunds(block *types.Block)

func AddressFromMessage added in v0.7.10

func AddressFromMessage(msg Message) []byte

func CalcDifficulty added in v0.7.10

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

func DaggerVerify added in v0.7.10

func DaggerVerify(hash, diff, nonce *big.Int) bool

func Disassemble added in v0.7.10

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

func EachTx added in v0.7.10

func EachTx(pool *list.List, it func(*types.Transaction, *list.Element) bool)

func FindTx added in v0.7.10

func FindTx(pool *list.List, finder func(*types.Transaction, *list.Element) bool) *types.Transaction

func IsGasLimitErr added in v0.7.10

func IsGasLimitErr(err error) bool

func IsKnownBlockErr added in v0.7.10

func IsKnownBlockErr(e error) bool

func IsNonceErr added in v0.7.10

func IsNonceErr(err error) bool

func IsOutOfGasErr added in v0.7.10

func IsOutOfGasErr(err error) bool

func IsParentErr added in v0.7.10

func IsParentErr(err error) bool

func IsTDError added in v0.7.10

func IsTDError(e error) bool

func IsUncleErr added in v0.7.10

func IsUncleErr(err error) bool

func IsValidationErr added in v0.7.10

func IsValidationErr(err error) bool

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 MessageCreatesContract(msg Message) bool

func MessageGasValue added in v0.7.10

func MessageGasValue(msg Message) *big.Int

func ParentError added in v0.7.10

func ParentError(hash []byte) error

func Sum added in v0.7.10

func Sum(sha hash.Hash) []byte

func UncleError added in v0.7.10

func UncleError(str string) error

Types

type AccountChange added in v0.7.10

type AccountChange struct {
	Address, StateAddress []byte
}

type BlockManager added in v0.7.10

type BlockManager struct {

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

func NewBlockManager added in v0.7.10

func NewBlockManager(txpool *TxPool, chainManager *ChainManager, eventMux *event.TypeMux) *BlockManager

func (*BlockManager) AccumelateRewards added in v0.7.10

func (sm *BlockManager) AccumelateRewards(statedb *state.StateDB, block, parent *types.Block) error

func (*BlockManager) ApplyTransactions added in v0.7.10

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

func (sm *BlockManager) CalculateTD(block *types.Block) (*big.Int, bool)

func (*BlockManager) GetMessages added in v0.7.10

func (sm *BlockManager) GetMessages(block *types.Block) (messages []*state.Message, err error)

func (*BlockManager) Process added in v0.7.10

func (sm *BlockManager) Process(block *types.Block) (td *big.Int, msgs state.Messages, err error)

func (*BlockManager) ProcessWithParent added in v0.7.10

func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.Int, messages state.Messages, err error)

func (*BlockManager) TransitionState added in v0.7.10

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

func (*BlockManager) ValidateBlock added in v0.7.10

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

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

func NewChainManager added in v0.7.10

func NewChainManager(mux *event.TypeMux) *ChainManager

func (*ChainManager) BlockInfo added in v0.7.10

func (bc *ChainManager) BlockInfo(block *types.Block) types.BlockInfo

func (*ChainManager) CalcTotalDiff added in v0.7.10

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

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) 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) GetChainHashesFromHash added in v0.7.10

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

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) LastBlockNumber added in v0.7.10

func (self *ChainManager) LastBlockNumber() uint64

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

type Dagger added in v0.7.10

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

func (*Dagger) Eval added in v0.7.10

func (dag *Dagger) Eval(N *big.Int) *big.Int

func (*Dagger) Find added in v0.7.10

func (dag *Dagger) Find(obj *big.Int, resChan chan int64)

func (*Dagger) Node added in v0.7.10

func (dag *Dagger) Node(L uint64, i uint64) *big.Int

func (*Dagger) Search added in v0.7.10

func (dag *Dagger) Search(hash, diff *big.Int) *big.Int

func (*Dagger) Verify added in v0.7.10

func (dag *Dagger) Verify(hash, diff, nonce *big.Int) bool

type EthManager added in v0.7.10

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

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

func NewExecution added in v0.7.10

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

func (*Execution) Addr added in v0.7.10

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

func (*Execution) Call added in v0.7.10

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

func (*Execution) Create added in v0.7.10

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

type Filter added in v0.7.10

type Filter struct {
	Altered []AccountChange

	BlockCallback   func(*types.Block)
	MessageCallback func(state.Messages)
	// contains filtered or unexported fields
}

Filtering interface

func NewFilter added in v0.7.10

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

func (self *Filter) AddAltered(address, stateAddress []byte)

func (*Filter) AddFrom added in v0.7.10

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

func (*Filter) AddTo added in v0.7.10

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

func (*Filter) FilterMessages added in v0.7.10

func (self *Filter) FilterMessages(msgs []*state.Message) []*state.Message

func (*Filter) Find added in v0.7.10

func (self *Filter) Find() []*state.Message

Run filters messages with the current parameters set

func (*Filter) SetEarliestBlock added in v0.7.10

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) SetFrom added in v0.7.10

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

func (*Filter) SetLatestBlock added in v0.7.10

func (self *Filter) SetLatestBlock(latest int64)

func (*Filter) SetMax added in v0.7.10

func (self *Filter) SetMax(max int)

func (*Filter) SetSkip added in v0.7.10

func (self *Filter) SetSkip(skip int)

func (*Filter) SetTo added in v0.7.10

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

type GasLimitErr added in v0.7.10

type GasLimitErr struct {
	Message string
	Is, Max *big.Int
}

func GasLimitError added in v0.7.10

func GasLimitError(is, max *big.Int) *GasLimitErr

func (*GasLimitErr) Error added in v0.7.10

func (err *GasLimitErr) Error() string

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

type NewBlockEvent struct{ Block *types.Block }

NewBlockEvent is posted when a block has been imported.

type NonceErr added in v0.7.10

type NonceErr struct {
	Message string
	Is, Exp uint64
}

func NonceError added in v0.7.10

func NonceError(is, exp uint64) *NonceErr

func (*NonceErr) Error added in v0.7.10

func (err *NonceErr) Error() string

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

func (*ParentErr) Error added in v0.7.10

func (err *ParentErr) Error() string

type Peer added in v0.7.10

type Peer interface {
	Inbound() bool
	LastSend() time.Time
	LastPong() int64
	Host() []byte
	Port() uint16
	Version() string
	PingTime() string
	Connected() *int32
	Caps() *ethutil.Value
}

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

func (*StateTransition) UseGas added in v0.7.10

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

func (*StateTransition) VmEnv added in v0.7.10

func (self *StateTransition) VmEnv() vm.Environment

type TDError added in v0.7.10

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

func (*TDError) Error added in v0.7.10

func (self *TDError) Error() string

type TxMsg added in v0.7.10

type TxMsg struct {
	Tx   *types.Transaction
	Type TxMsgTy
}

type TxMsgTy added in v0.7.10

type TxMsgTy byte

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) Add added in v0.7.10

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

func (*TxPool) CurrentTransactions added in v0.7.10

func (pool *TxPool) CurrentTransactions() []*types.Transaction

func (*TxPool) Flush added in v0.7.10

func (pool *TxPool) Flush() []*types.Transaction

func (*TxPool) RemoveInvalid added in v0.7.10

func (pool *TxPool) RemoveInvalid(state *state.StateDB)

func (*TxPool) RemoveSet added in v0.7.10

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

func (*TxPool) Size added in v0.7.10

func (self *TxPool) Size() int

func (*TxPool) Start added in v0.7.10

func (pool *TxPool) Start()

func (*TxPool) Stop

func (pool *TxPool) Stop()

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 UncleErr added in v0.7.10

type UncleErr struct {
	Message string
}

func (*UncleErr) Error added in v0.7.10

func (err *UncleErr) Error() string

type VMEnv added in v0.7.10

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

func NewEnv added in v0.7.10

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

func (*VMEnv) AddLog added in v0.7.10

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

func (*VMEnv) BlockHash added in v0.7.10

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

func (*VMEnv) BlockNumber added in v0.7.10

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

func (*VMEnv) Call added in v0.7.10

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

func (*VMEnv) CallCode added in v0.7.10

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

func (*VMEnv) Coinbase added in v0.7.10

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

func (*VMEnv) Create added in v0.7.10

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

func (*VMEnv) Depth added in v0.7.10

func (self *VMEnv) Depth() int

func (*VMEnv) Difficulty added in v0.7.10

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

func (*VMEnv) GasLimit added in v0.7.10

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

func (*VMEnv) Origin added in v0.7.10

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

func (*VMEnv) PrevHash added in v0.7.10

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

func (*VMEnv) SetDepth added in v0.7.10

func (self *VMEnv) SetDepth(i int)

func (*VMEnv) State added in v0.7.10

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

func (*VMEnv) Time added in v0.7.10

func (self *VMEnv) Time() int64

func (*VMEnv) Transfer added in v0.7.10

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

func (*VMEnv) Value added in v0.7.10

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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