Documentation ¶
Index ¶
- Constants
- Variables
- func AddTestNetFunds(block *Block)
- func CalculateBlockReward(block *Block, uncleLength int) *big.Int
- func CalculateUncleReward(block *Block) *big.Int
- func Call(vm *Vm, closure *Closure, data []byte) (ret []byte, err error)
- func CreateTxSha(receipts Receipts) (sha []byte)
- func DaggerVerify(hash, diff, nonce *big.Int) bool
- func Disassemble(script []byte) (asm []string)
- func IsContractAddr(addr []byte) bool
- func IsGasLimitErr(err error) bool
- func IsNonceErr(err error) bool
- func IsOpCode(s string) bool
- func IsOutOfGasErr(err error) bool
- func IsParentErr(err error) bool
- func IsValidationErr(err error) bool
- func ParentError(hash []byte) error
- func Sum(sha hash.Hash) []byte
- type Block
- func (block *Block) BlockInfo() BlockInfo
- func (block *Block) CalcGasLimit(parent *Block) *big.Int
- func (block *Block) GetRoot() interface{}
- func (self *Block) GetTransaction(hash []byte) *Transaction
- func (block *Block) Hash() []byte
- func (block *Block) HashNoNonce() []byte
- func (block *Block) PayFee(addr []byte, fee *big.Int) bool
- func (self *Block) Receipts() []*Receipt
- func (block *Block) RlpDecode(data []byte)
- func (block *Block) RlpEncode() []byte
- func (block *Block) RlpValueDecode(decoder *ethutil.Value)
- func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction)
- func (self *Block) SetTxHash(receipts Receipts)
- func (block *Block) SetUncles(uncles []*Block)
- func (block *Block) State() *State
- func (block *Block) String() string
- func (block *Block) Sync()
- func (block *Block) Transactions() []*Transaction
- func (block *Block) Undo()
- func (block *Block) Value() *ethutil.Value
- type BlockChain
- func (bc *BlockChain) Add(block *Block)
- func (bc *BlockChain) BlockInfo(block *Block) BlockInfo
- func (bc *BlockChain) BlockInfoByHash(hash []byte) BlockInfo
- func (bc *BlockChain) CalculateBlockTD(block *Block) *big.Int
- func (bc *BlockChain) FindCanonicalChain(blocks []*Block, commonBlockHash []byte) bool
- func (bc *BlockChain) FindCanonicalChainFromMsg(msg *ethwire.Msg, commonBlockHash []byte) bool
- func (bc *BlockChain) Genesis() *Block
- func (bc *BlockChain) GenesisBlock() *Block
- func (bc *BlockChain) GetBlock(hash []byte) *Block
- func (bc *BlockChain) GetChain(hash []byte, amount int) []*Block
- func (bc *BlockChain) GetChainFromHash(hash []byte, max uint64) []interface{}
- func (bc *BlockChain) HasBlock(hash []byte) bool
- func (bc *BlockChain) HasBlockWithPrevHash(hash []byte) bool
- func (bc *BlockChain) NewBlock(coinbase []byte) *Block
- func (bc *BlockChain) ResetTillBlockHash(hash []byte) error
- func (bc *BlockChain) SetTotalDifficulty(td *big.Int)
- func (bc *BlockChain) Stop()
- type BlockInfo
- type BlockProcessor
- type Closure
- func (c *Closure) Address() []byte
- func (c *Closure) Call(vm *Vm, args []byte) ([]byte, *big.Int, error)
- func (c *Closure) Caller() ClosureRef
- func (c *Closure) Get(x *big.Int) *ethutil.Value
- func (c *Closure) GetStorage(x *big.Int) *ethutil.Value
- func (c *Closure) Gets(x, y *big.Int) *ethutil.Value
- func (c *Closure) N() *big.Int
- func (c *Closure) Object() *StateObject
- func (c *Closure) Return(ret []byte) []byte
- func (c *Closure) ReturnGas(gas, price *big.Int, state *State)
- func (c *Closure) SetStorage(x *big.Int, val *ethutil.Value)
- func (c *Closure) UseGas(gas *big.Int) bool
- type ClosureRef
- type Code
- type Dagger
- type Debugger
- type EasyPow
- type EthManager
- type GasLimitErr
- type Manifest
- type Memory
- type NonceErr
- type OpCode
- type OpType
- type OutOfGasErr
- type ParentErr
- type Peer
- type PoW
- type Receipt
- type Receipts
- type RuntimeVars
- type Stack
- func (st *Stack) Data() []*big.Int
- func (st *Stack) Get(amount *big.Int) []*big.Int
- func (st *Stack) Len() int
- func (st *Stack) Peek() *big.Int
- func (st *Stack) Peekn() (*big.Int, *big.Int)
- func (st *Stack) Pop() *big.Int
- func (st *Stack) Popn() (*big.Int, *big.Int)
- func (st *Stack) Print()
- func (st *Stack) Push(d *big.Int)
- type State
- func (s *State) Cmp(other *State) bool
- func (self *State) Copy() *State
- func (self *State) CreateOutputForDiff()
- func (self *State) DeleteStateObject(stateObject *StateObject)
- func (s *State) EachStorage(cb ethtrie.EachCallback)
- func (self *State) Empty()
- func (self *State) GetAccount(addr []byte) *StateObject
- func (self *State) GetBalance(addr []byte) *big.Int
- func (self *State) GetNonce(addr []byte) uint64
- func (self *State) GetOrNewStateObject(addr []byte) *StateObject
- func (self *State) GetStateObject(addr []byte) *StateObject
- func (self *State) NewStateObject(addr []byte) *StateObject
- func (s *State) Reset()
- func (s *State) Root() interface{}
- func (self *State) Set(state *State)
- func (s *State) Sync()
- func (self *State) Update()
- func (self *State) UpdateStateObject(stateObject *StateObject)
- type StateManager
- func (sm *StateManager) AccumelateRewards(state *State, block *Block) error
- func (sm *StateManager) ApplyDiff(state *State, parent, block *Block) (receipts Receipts, err error)
- func (sm *StateManager) BlockChain() *BlockChain
- func (sm *StateManager) CalculateTD(block *Block) bool
- func (sm *StateManager) CurrentState() *State
- func (sm *StateManager) MiningState() *State
- func (sm *StateManager) NewMiningState() *State
- func (sm *StateManager) Process(block *Block, dontReact bool) (err error)
- func (self *StateManager) ProcessTransactions(coinbase *StateObject, state *State, block, parent *Block, txs Transactions) (Receipts, Transactions, Transactions, error)
- func (sm *StateManager) Stop()
- func (sm *StateManager) TransState() *State
- func (sm *StateManager) ValidateBlock(block *Block) error
- type StateObject
- func (c *StateObject) AddAmount(amount *big.Int)
- func (c *StateObject) Address() []byte
- func (self *StateObject) BuyGas(gas, price *big.Int) error
- func (c *StateObject) ConvertGas(gas, price *big.Int) error
- func (self *StateObject) Copy() *StateObject
- func (c *StateObject) GetAddr(addr []byte) *ethutil.Value
- func (c *StateObject) GetInstr(pc *big.Int) *ethutil.Value
- func (self *StateObject) GetStorage(key *big.Int) *ethutil.Value
- func (c *StateObject) Init() Code
- func (self *StateObject) MarkForDeletion()
- func (c *StateObject) N() *big.Int
- func (self *StateObject) RefundGas(gas, price *big.Int)
- func (self *StateObject) Reset()
- func (c *StateObject) ReturnGas(gas, price *big.Int, state *State)
- func (c *StateObject) RlpDecode(data []byte)
- func (c *StateObject) RlpEncode() []byte
- func (c *StateObject) Script() Code
- func (self *StateObject) Set(stateObject *StateObject)
- func (c *StateObject) SetAddr(addr []byte, value interface{})
- func (c *StateObject) SetAmount(amount *big.Int)
- func (self *StateObject) SetGasPool(gasLimit *big.Int)
- func (self *StateObject) SetStorage(key *big.Int, value *ethutil.Value)
- func (c *StateObject) State() *State
- func (c *StateObject) SubAmount(amount *big.Int)
- func (self *StateObject) Sync()
- type StateTransition
- func (self *StateTransition) AddGas(amount *big.Int)
- func (self *StateTransition) BuyGas() error
- func (self *StateTransition) Coinbase() *StateObject
- func (self *StateTransition) Eval(script []byte, context *StateObject, typ string) (ret []byte, err error)
- func (self *StateTransition) MakeStateObject(state *State, tx *Transaction) *StateObject
- func (self *StateTransition) Receiver() *StateObject
- func (self *StateTransition) RefundGas()
- func (self *StateTransition) Sender() *StateObject
- func (self *StateTransition) TransitionState() (err error)
- func (self *StateTransition) UseGas(amount *big.Int) error
- type Storage
- type StorageState
- type Transaction
- func FindTx(pool *list.List, finder func(*Transaction, *list.Element) bool) *Transaction
- func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transaction
- func NewTransactionFromBytes(data []byte) *Transaction
- func NewTransactionFromValue(val *ethutil.Value) *Transaction
- func NewTransactionMessage(to []byte, value, gas, gasPrice *big.Int, data []byte) *Transaction
- func (tx *Transaction) CreatesContract() bool
- func (tx *Transaction) CreationAddress() []byte
- func (self *Transaction) GasValue() *big.Int
- func (tx *Transaction) Hash() []byte
- func (tx *Transaction) IsContract() bool
- func (tx *Transaction) PublicKey() []byte
- func (tx *Transaction) RlpData() interface{}
- func (tx *Transaction) RlpDecode(data []byte)
- func (tx *Transaction) RlpEncode() []byte
- func (tx *Transaction) RlpValue() *ethutil.Value
- func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value)
- func (tx *Transaction) Sender() []byte
- func (tx *Transaction) Sign(privk []byte) error
- func (tx *Transaction) Signature(key []byte) []byte
- func (tx *Transaction) String() string
- func (self *Transaction) TotalValue() *big.Int
- type Transactions
- type TxByNonce
- type TxCallback
- type TxMsg
- type TxMsgTy
- type TxPool
- func (pool *TxPool) CurrentTransactions() []*Transaction
- func (pool *TxPool) Flush() []*Transaction
- func (pool *TxPool) QueueTransaction(tx *Transaction)
- func (pool *TxPool) RemoveInvalid(state *State)
- func (pool *TxPool) Start()
- func (pool *TxPool) Stop()
- func (pool *TxPool) ValidateTransaction(tx *Transaction) error
- type TxPoolHook
- type TxProcessor
- type ValidationErr
- type Vm
Constants ¶
const ( TxPre = iota TxPost )
const ( // 0x0 range - arithmetic ops STOP = 0x00 ADD = 0x01 MUL = 0x02 SUB = 0x03 DIV = 0x04 SDIV = 0x05 MOD = 0x06 SMOD = 0x07 EXP = 0x08 NEG = 0x09 LT = 0x0a GT = 0x0b SLT = 0x0c SGT = 0x0d EQ = 0x0e NOT = 0x0f // 0x10 range - bit ops AND = 0x10 OR = 0x11 XOR = 0x12 BYTE = 0x13 // 0x20 range - crypto SHA3 = 0x20 // 0x30 range - closure state ADDRESS = 0x30 BALANCE = 0x31 ORIGIN = 0x32 CALLER = 0x33 CALLVALUE = 0x34 CALLDATALOAD = 0x35 CALLDATASIZE = 0x36 CALLDATACOPY = 0x37 CODESIZE = 0x38 CODECOPY = 0x39 GASPRICE = 0x3a // 0x40 range - block operations PREVHASH = 0x40 COINBASE = 0x41 TIMESTAMP = 0x42 NUMBER = 0x43 DIFFICULTY = 0x44 GASLIMIT = 0x45 // 0x50 range - 'storage' and execution POP = 0x50 DUP = 0x51 SWAP = 0x52 MLOAD = 0x53 MSTORE = 0x54 MSTORE8 = 0x55 SLOAD = 0x56 SSTORE = 0x57 JUMP = 0x58 JUMPI = 0x59 PC = 0x5a MSIZE = 0x5b GAS = 0x5c // 0x60 range PUSH1 = 0x60 PUSH2 = 0x61 PUSH3 = 0x62 PUSH4 = 0x63 PUSH5 = 0x64 PUSH6 = 0x65 PUSH7 = 0x66 PUSH8 = 0x67 PUSH9 = 0x68 PUSH10 = 0x69 PUSH11 = 0x6a PUSH12 = 0x6b PUSH13 = 0x6c PUSH14 = 0x6d PUSH15 = 0x6e PUSH16 = 0x6f PUSH17 = 0x70 PUSH18 = 0x71 PUSH19 = 0x72 PUSH20 = 0x73 PUSH21 = 0x74 PUSH22 = 0x75 PUSH23 = 0x76 PUSH24 = 0x77 PUSH25 = 0x78 PUSH26 = 0x79 PUSH27 = 0x7a PUSH28 = 0x7b PUSH29 = 0x7c PUSH30 = 0x7d PUSH31 = 0x7e PUSH32 = 0x7f // 0xf0 range - closures CREATE = 0xf0 CALL = 0xf1 RETURN = 0xf2 // 0x70 range - other LOG = 0xfe // XXX Unofficial SUICIDE = 0xff )
Op codes
Variables ¶
var ( GasStep = big.NewInt(1) GasSha = big.NewInt(20) GasSLoad = big.NewInt(20) GasSStore = big.NewInt(100) GasBalance = big.NewInt(20) GasCreate = big.NewInt(100) GasCall = big.NewInt(20) GasMemory = big.NewInt(1) GasData = big.NewInt(5) GasTx = big.NewInt(500) LogTyPretty byte = 0x1 LogTyDiff byte = 0x2 )
var BlockReward *big.Int = big.NewInt(1.5e+18)
var ContractAddr = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
var EmptyShaList = ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{}))
var Found bool
var Genesis = []interface{}{GenesisHeader, []interface{}{}, []interface{}{}}
var GenesisHeader = []interface{}{ ZeroHash256, ethcrypto.Sha3Bin(ethutil.Encode([]interface{}{})), ZeroHash160, "", "", ethutil.BigPow(2, 22), ethutil.Big0, ethutil.Big0, big.NewInt(1000000), ethutil.Big0, ethutil.Big0, nil, ethcrypto.Sha3Bin(big.NewInt(42).Bytes()), }
var OpCodes = map[string]byte{
"STOP": 0x00,
"ADD": 0x01,
"MUL": 0x02,
"SUB": 0x03,
"DIV": 0x04,
"SDIV": 0x05,
"MOD": 0x06,
"SMOD": 0x07,
"EXP": 0x08,
"NEG": 0x09,
"LT": 0x0a,
"GT": 0x0b,
"EQ": 0x0c,
"NOT": 0x0d,
"AND": 0x10,
"OR": 0x11,
"XOR": 0x12,
"BYTE": 0x13,
"SHA3": 0x20,
"ADDRESS": 0x30,
"BALANCE": 0x31,
"ORIGIN": 0x32,
"CALLER": 0x33,
"CALLVALUE": 0x34,
"CALLDATALOAD": 0x35,
"CALLDATASIZE": 0x36,
"GASPRICE": 0x38,
"PREVHASH": 0x40,
"COINBASE": 0x41,
"TIMESTAMP": 0x42,
"NUMBER": 0x43,
"DIFFICULTY": 0x44,
"GASLIMIT": 0x45,
"POP": 0x51,
"DUP": 0x52,
"SWAP": 0x53,
"MLOAD": 0x54,
"MSTORE": 0x55,
"MSTORE8": 0x56,
"SLOAD": 0x57,
"SSTORE": 0x58,
"JUMP": 0x59,
"JUMPI": 0x5a,
"PC": 0x5b,
"MSIZE": 0x5c,
"PUSH1": 0x60,
"PUSH2": 0x61,
"PUSH3": 0x62,
"PUSH4": 0x63,
"PUSH5": 0x64,
"PUSH6": 0x65,
"PUSH7": 0x66,
"PUSH8": 0x67,
"PUSH9": 0x68,
"PUSH10": 0x69,
"PUSH11": 0x6a,
"PUSH12": 0x6b,
"PUSH13": 0x6c,
"PUSH14": 0x6d,
"PUSH15": 0x6e,
"PUSH16": 0x6f,
"PUSH17": 0x70,
"PUSH18": 0x71,
"PUSH19": 0x72,
"PUSH20": 0x73,
"PUSH21": 0x74,
"PUSH22": 0x75,
"PUSH23": 0x76,
"PUSH24": 0x77,
"PUSH25": 0x78,
"PUSH26": 0x70,
"PUSH27": 0x7a,
"PUSH28": 0x7b,
"PUSH29": 0x7c,
"PUSH30": 0x7d,
"PUSH31": 0x7e,
"PUSH32": 0x7f,
"CREATE": 0xf0,
"CALL": 0xf1,
"RETURN": 0xf2,
"LOG": 0xfe,
"SUICIDE": 0x7f,
}
Op codes for assembling
var Pow256 = ethutil.BigPow(2, 256)
var UncleInclusionReward *big.Int = big.NewInt(1.875e+17)
var UncleReward *big.Int = big.NewInt(1.125e+18)
var ZeroHash160 = make([]byte, 20)
var ZeroHash256 = make([]byte, 32)
Functions ¶
func AddTestNetFunds ¶
func AddTestNetFunds(block *Block)
func CalculateUncleReward ¶
func CreateTxSha ¶
func DaggerVerify ¶
func Disassemble ¶
func IsContractAddr ¶
func IsGasLimitErr ¶
func IsNonceErr ¶
func IsOutOfGasErr ¶
func IsParentErr ¶
func IsValidationErr ¶
func ParentError ¶
Types ¶
type Block ¶
type Block struct { // Hash to the previous block PrevHash []byte // Uncles of this block Uncles []*Block UncleSha []byte // The coin base address Coinbase []byte // Difficulty for the current block Difficulty *big.Int // Creation time Time int64 // The block number Number *big.Int // Minimum Gas Price MinGasPrice *big.Int // Gas limit GasLimit *big.Int // Gas used GasUsed *big.Int // Extra data Extra string // Block Nonce for verification Nonce []byte TxSha []byte // contains filtered or unexported fields }
func CreateBlock ¶
func NewBlockFromBytes ¶
func NewBlockFromData ¶
New block takes a raw encoded string XXX DEPRICATED
func NewBlockFromRlpValue ¶
New block takes a raw encoded string
func NewUncleBlockFromValue ¶
func (*Block) GetTransaction ¶
func (self *Block) GetTransaction(hash []byte) *Transaction
func (*Block) HashNoNonce ¶
func (*Block) RlpValueDecode ¶
func (*Block) SetReceipts ¶
func (self *Block) SetReceipts(receipts []*Receipt, txs []*Transaction)
func (*Block) Transactions ¶
func (block *Block) Transactions() []*Transaction
type BlockChain ¶
type BlockChain struct { Ethereum EthManager // Last known total difficulty TD *big.Int LastBlockNumber uint64 CurrentBlock *Block LastBlockHash []byte // contains filtered or unexported fields }
func NewBlockChain ¶
func NewBlockChain(ethereum EthManager) *BlockChain
func (*BlockChain) Add ¶
func (bc *BlockChain) Add(block *Block)
Add a block to the chain and record addition information
func (*BlockChain) BlockInfo ¶
func (bc *BlockChain) BlockInfo(block *Block) BlockInfo
func (*BlockChain) BlockInfoByHash ¶
func (bc *BlockChain) BlockInfoByHash(hash []byte) BlockInfo
func (*BlockChain) CalculateBlockTD ¶
func (bc *BlockChain) CalculateBlockTD(block *Block) *big.Int
func (*BlockChain) FindCanonicalChain ¶
func (bc *BlockChain) FindCanonicalChain(blocks []*Block, commonBlockHash []byte) bool
Is tasked by finding the CanonicalChain and resetting the chain if we are not the Conical one Return true if we are the using the canonical chain false if not
func (*BlockChain) FindCanonicalChainFromMsg ¶
func (bc *BlockChain) FindCanonicalChainFromMsg(msg *ethwire.Msg, commonBlockHash []byte) bool
func (*BlockChain) Genesis ¶
func (bc *BlockChain) Genesis() *Block
func (*BlockChain) GenesisBlock ¶
func (bc *BlockChain) GenesisBlock() *Block
func (*BlockChain) GetBlock ¶
func (bc *BlockChain) GetBlock(hash []byte) *Block
func (*BlockChain) GetChainFromHash ¶
func (bc *BlockChain) GetChainFromHash(hash []byte, max uint64) []interface{}
Get chain return blocks from hash up to max in RLP format
func (*BlockChain) HasBlock ¶
func (bc *BlockChain) HasBlock(hash []byte) bool
func (*BlockChain) HasBlockWithPrevHash ¶
func (bc *BlockChain) HasBlockWithPrevHash(hash []byte) bool
TODO: At one point we might want to save a block by prevHash in the db to optimise this...
func (*BlockChain) NewBlock ¶
func (bc *BlockChain) NewBlock(coinbase []byte) *Block
func (*BlockChain) ResetTillBlockHash ¶
func (bc *BlockChain) ResetTillBlockHash(hash []byte) error
func (*BlockChain) SetTotalDifficulty ¶
func (bc *BlockChain) SetTotalDifficulty(td *big.Int)
func (*BlockChain) Stop ¶
func (bc *BlockChain) Stop()
type BlockProcessor ¶
type BlockProcessor interface {
ProcessBlock(block *Block)
}
type Closure ¶
type Closure struct { Script []byte State *State Gas, UsedGas, Price *big.Int Args []byte // contains filtered or unexported fields }
Basic inline closure object which implement the 'closure' interface
func NewClosure ¶
func NewClosure(caller ClosureRef, object *StateObject, script []byte, state *State, gas, price *big.Int) *Closure
Create a new closure for the given data items
func (*Closure) Caller ¶
func (c *Closure) Caller() ClosureRef
func (*Closure) GetStorage ¶
Retuns the x element in data slice
func (*Closure) Object ¶
func (c *Closure) Object() *StateObject
type ClosureRef ¶
type EasyPow ¶
type EasyPow struct { HashRate int64 // contains filtered or unexported fields }
func (*EasyPow) GetHashrate ¶
type EthManager ¶
type EthManager interface { StateManager() *StateManager BlockChain() *BlockChain TxPool() *TxPool Broadcast(msgType ethwire.MsgType, data []interface{}) Reactor() *ethutil.ReactorEngine PeerCount() int IsMining() bool IsListening() bool Peers() *list.List KeyManager() *ethcrypto.KeyManager ClientIdentity() ethwire.ClientIdentity }
type GasLimitErr ¶
func GasLimitError ¶
func GasLimitError(is, max *big.Int) *GasLimitErr
func (*GasLimitErr) Error ¶
func (err *GasLimitErr) Error() string
type Manifest ¶
type Manifest struct {
// contains filtered or unexported fields
}
Object manifest
The object manifest is used to keep changes to the state so we can keep track of the changes that occurred during a state transitioning phase.
func NewManifest ¶
func NewManifest() *Manifest
func (*Manifest) AddObjectChange ¶
func (m *Manifest) AddObjectChange(stateObject *StateObject)
func (*Manifest) AddStorageChange ¶
func (m *Manifest) AddStorageChange(stateObject *StateObject, storageAddr []byte, storage *big.Int)
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 Receipt ¶
type Receipt struct { Tx *Transaction PostState []byte CumulativeGasUsed *big.Int }
func NewRecieptFromValue ¶
func (*Receipt) RlpValueDecode ¶
type RuntimeVars ¶
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Simple push/pop stack mechanism
type State ¶
type State struct {
// contains filtered or unexported fields
}
States within the ethereum protocol are used to store anything within the merkle trie. States take care of caching and storing nested states. It's the general query interface to retrieve: * Contracts * Accounts
func (*State) DeleteStateObject ¶
func (self *State) DeleteStateObject(stateObject *StateObject)
Delete the given state object and delete it from the state trie
func (*State) EachStorage ¶
func (s *State) EachStorage(cb ethtrie.EachCallback)
Iterate over each storage address and yield callback
func (*State) GetBalance ¶
Retrieve the balance from the given address or 0 if object not found
func (*State) GetOrNewStateObject ¶
func (self *State) GetOrNewStateObject(addr []byte) *StateObject
Retrieve a state object or create a new state object if nil
func (*State) GetStateObject ¶
func (self *State) GetStateObject(addr []byte) *StateObject
Retrieve a state object given my the address. Nil if not found
func (*State) NewStateObject ¶
func (self *State) NewStateObject(addr []byte) *StateObject
Create a state object whether it exist in the trie or not
func (*State) UpdateStateObject ¶
func (self *State) UpdateStateObject(stateObject *StateObject)
Update the given state object and apply it to state trie
type StateManager ¶
type StateManager struct { // Proof of work used for validating Pow PoW // The ethereum manager interface Ethereum EthManager // contains filtered or unexported fields }
func NewStateManager ¶
func NewStateManager(ethereum EthManager) *StateManager
func (*StateManager) AccumelateRewards ¶
func (sm *StateManager) AccumelateRewards(state *State, block *Block) error
func (*StateManager) ApplyDiff ¶
func (sm *StateManager) ApplyDiff(state *State, parent, block *Block) (receipts Receipts, err error)
func (*StateManager) BlockChain ¶
func (sm *StateManager) BlockChain() *BlockChain
func (*StateManager) CalculateTD ¶
func (sm *StateManager) CalculateTD(block *Block) bool
func (*StateManager) CurrentState ¶
func (sm *StateManager) CurrentState() *State
func (*StateManager) MiningState ¶
func (sm *StateManager) MiningState() *State
func (*StateManager) NewMiningState ¶
func (sm *StateManager) NewMiningState() *State
func (*StateManager) Process ¶
func (sm *StateManager) Process(block *Block, dontReact bool) (err error)
func (*StateManager) ProcessTransactions ¶
func (self *StateManager) ProcessTransactions(coinbase *StateObject, state *State, block, parent *Block, txs Transactions) (Receipts, Transactions, Transactions, error)
func (*StateManager) Stop ¶
func (sm *StateManager) Stop()
func (*StateManager) TransState ¶
func (sm *StateManager) TransState() *State
func (*StateManager) ValidateBlock ¶
func (sm *StateManager) ValidateBlock(block *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 StateObject ¶
type StateObject struct { // Shared attributes Amount *big.Int ScriptHash []byte Nonce uint64 // contains filtered or unexported fields }
func MakeContract ¶
func MakeContract(tx *Transaction, state *State) *StateObject
Converts an transaction in to a state object
func NewContract ¶
func NewContract(address []byte, Amount *big.Int, root []byte) *StateObject
func NewStateObject ¶
func NewStateObject(addr []byte) *StateObject
func NewStateObjectFromBytes ¶
func NewStateObjectFromBytes(address, data []byte) *StateObject
func (*StateObject) AddAmount ¶
func (c *StateObject) AddAmount(amount *big.Int)
func (*StateObject) Address ¶
func (c *StateObject) Address() []byte
Returns the address of the contract/account
func (*StateObject) ConvertGas ¶
func (c *StateObject) ConvertGas(gas, price *big.Int) error
func (*StateObject) Copy ¶
func (self *StateObject) Copy() *StateObject
func (*StateObject) GetStorage ¶
func (self *StateObject) GetStorage(key *big.Int) *ethutil.Value
func (*StateObject) MarkForDeletion ¶
func (self *StateObject) MarkForDeletion()
func (*StateObject) N ¶
func (c *StateObject) N() *big.Int
func (*StateObject) RefundGas ¶
func (self *StateObject) RefundGas(gas, price *big.Int)
func (*StateObject) Reset ¶
func (self *StateObject) Reset()
func (*StateObject) ReturnGas ¶
func (c *StateObject) ReturnGas(gas, price *big.Int, state *State)
Return the gas back to the origin. Used by the Virtual machine or Closures
func (*StateObject) RlpDecode ¶
func (c *StateObject) RlpDecode(data []byte)
func (*StateObject) RlpEncode ¶
func (c *StateObject) RlpEncode() []byte
State object encoding methods
func (*StateObject) Set ¶
func (self *StateObject) Set(stateObject *StateObject)
func (*StateObject) SetAddr ¶
func (c *StateObject) SetAddr(addr []byte, value interface{})
func (*StateObject) SetAmount ¶
func (c *StateObject) SetAmount(amount *big.Int)
func (*StateObject) SetGasPool ¶
func (self *StateObject) SetGasPool(gasLimit *big.Int)
func (*StateObject) SetStorage ¶
func (self *StateObject) SetStorage(key *big.Int, value *ethutil.Value)
func (*StateObject) State ¶
func (c *StateObject) State() *State
func (*StateObject) SubAmount ¶
func (c *StateObject) SubAmount(amount *big.Int)
func (*StateObject) Sync ¶
func (self *StateObject) Sync()
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(coinbase *StateObject, tx *Transaction, state *State, block *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() *StateObject
func (*StateTransition) Eval ¶
func (self *StateTransition) Eval(script []byte, context *StateObject, typ string) (ret []byte, err error)
func (*StateTransition) MakeStateObject ¶
func (self *StateTransition) MakeStateObject(state *State, tx *Transaction) *StateObject
func (*StateTransition) Receiver ¶
func (self *StateTransition) Receiver() *StateObject
func (*StateTransition) RefundGas ¶
func (self *StateTransition) RefundGas()
func (*StateTransition) Sender ¶
func (self *StateTransition) Sender() *StateObject
func (*StateTransition) TransitionState ¶
func (self *StateTransition) TransitionState() (err error)
type StorageState ¶
Storage change object. Used by the manifest for notifying changes to the sub channels.
type Transaction ¶
type Transaction struct { Nonce uint64 Recipient []byte Value *big.Int Gas *big.Int GasPrice *big.Int Data []byte // contains filtered or unexported fields }
func FindTx ¶
func FindTx(pool *list.List, finder func(*Transaction, *list.Element) bool) *Transaction
func NewContractCreationTx ¶
func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transaction
func NewTransactionFromBytes ¶
func NewTransactionFromBytes(data []byte) *Transaction
func NewTransactionFromValue ¶
func NewTransactionFromValue(val *ethutil.Value) *Transaction
func NewTransactionMessage ¶
func NewTransactionMessage(to []byte, value, gas, gasPrice *big.Int, data []byte) *Transaction
func (*Transaction) CreatesContract ¶
func (tx *Transaction) CreatesContract() bool
func (*Transaction) CreationAddress ¶
func (tx *Transaction) CreationAddress() []byte
func (*Transaction) GasValue ¶
func (self *Transaction) GasValue() *big.Int
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() []byte
func (*Transaction) PublicKey ¶
func (tx *Transaction) PublicKey() []byte
func (*Transaction) RlpData ¶
func (tx *Transaction) RlpData() interface{}
func (*Transaction) RlpDecode ¶
func (tx *Transaction) RlpDecode(data []byte)
func (*Transaction) RlpEncode ¶
func (tx *Transaction) RlpEncode() []byte
func (*Transaction) RlpValue ¶
func (tx *Transaction) RlpValue() *ethutil.Value
func (*Transaction) RlpValueDecode ¶
func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value)
func (*Transaction) Sender ¶
func (tx *Transaction) Sender() []byte
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privk []byte) error
func (*Transaction) Signature ¶
func (tx *Transaction) Signature(key []byte) []byte
func (*Transaction) String ¶
func (tx *Transaction) String() string
func (*Transaction) TotalValue ¶
func (self *Transaction) TotalValue() *big.Int
type Transactions ¶
type Transactions []*Transaction
Transaction slice type for basic sorting
func (Transactions) Len ¶
func (s Transactions) Len() int
func (Transactions) Swap ¶
func (s Transactions) Swap(i, j int)
type TxByNonce ¶
type TxByNonce struct{ Transactions }
type TxCallback ¶
type TxMsg ¶
type TxMsg struct { Tx *Transaction Type TxMsgTy }
type TxPool ¶
type TxPool struct { Ethereum EthManager 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(ethereum EthManager) *TxPool
func (*TxPool) CurrentTransactions ¶
func (pool *TxPool) CurrentTransactions() []*Transaction
func (*TxPool) Flush ¶
func (pool *TxPool) Flush() []*Transaction
func (*TxPool) QueueTransaction ¶
func (pool *TxPool) QueueTransaction(tx *Transaction)
func (*TxPool) RemoveInvalid ¶
func (*TxPool) ValidateTransaction ¶
func (pool *TxPool) ValidateTransaction(tx *Transaction) error
type TxPoolHook ¶
type TxPoolHook chan *Transaction
type TxProcessor ¶
type TxProcessor interface {
ProcessTransaction(tx *Transaction)
}
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