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

func AddTestNetFunds(block *types.Block)

func AddressFromMessage

func AddressFromMessage(msg Message) []byte

func CalcDifficulty

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

func DaggerVerify

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

func Disassemble

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

func EachTx

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

func FindTx

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

func IsGasLimitErr

func IsGasLimitErr(err error) bool

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 Sum

func Sum(sha hash.Hash) []byte

func UncleError

func UncleError(str string) error

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 (sm *BlockManager) AccumelateRewards(statedb *state.StateDB, block, parent *types.Block) error

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 (sm *BlockManager) CalculateTD(block *types.Block) (*big.Int, bool)

func (*BlockManager) GetMessages

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

func (*BlockManager) Process

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

func (*BlockManager) ProcessWithParent

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

func (*BlockManager) TransitionState

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

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

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

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 Dagger

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

func (*Dagger) Eval

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

func (*Dagger) Find

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

func (*Dagger) Node

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

func (*Dagger) Search

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

func (*Dagger) Verify

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

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

type Execution struct {
	Gas          *big.Int
	SkipTransfer bool
	// 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.ClosureRef) ([]byte, error)

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 (self *Filter) AddAltered(address, stateAddress []byte)

func (*Filter) AddFrom

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

func (*Filter) AddTo

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

func (*Filter) FilterMessages

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

func (*Filter) Find

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

Run filters messages with the current parameters set

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

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

func (*Filter) SetLatestBlock

func (self *Filter) SetLatestBlock(latest int64)

func (*Filter) SetMax

func (self *Filter) SetMax(max int)

func (*Filter) SetSkip

func (self *Filter) SetSkip(skip int)

func (*Filter) SetTo

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

type GasLimitErr

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

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

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

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

func (*StateTransition) VmEnv

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

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 TxMsgTy
}

type TxMsgTy

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

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

func (*TxPool) CurrentTransactions

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

func (*TxPool) Flush

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

func (*TxPool) RemoveInvalid

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

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, msg Message, block *types.Block) *VMEnv

func (*VMEnv) AddLog

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

func (*VMEnv) BlockHash

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

func (*VMEnv) BlockNumber

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

func (*VMEnv) Call

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

func (*VMEnv) CallCode

func (self *VMEnv) CallCode(me vm.ClosureRef, 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.ClosureRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ClosureRef)

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

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

func (*VMEnv) PrevHash

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

func (*VMEnv) SetDepth

func (self *VMEnv) SetDepth(i int)

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

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