From b1870631a4829e075eae77064973ef94aa2166b3 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 4 Feb 2015 05:52:59 -0800 Subject: WIP miner --- core/types/block.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'core/types') diff --git a/core/types/block.go b/core/types/block.go index be57e86a6..a334c512e 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -6,7 +6,6 @@ import ( "math/big" "sort" "time" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/rlp" @@ -146,6 +145,10 @@ func (self *Block) SetTransactions(transactions Transactions) { self.transactions = transactions self.header.TxHash = DeriveSha(transactions) } +func (self *Block) AddTransaction(transaction *Transaction) { + self.transactions = append(self.transactions, transaction) + self.SetTransactions(self.transactions) +} func (self *Block) Receipts() Receipts { return self.receipts @@ -156,6 +159,10 @@ func (self *Block) SetReceipts(receipts Receipts) { self.header.ReceiptHash = DeriveSha(receipts) self.header.Bloom = CreateBloom(receipts) } +func (self *Block) AddReceipt(receipt *Receipt) { + self.receipts = append(self.receipts, receipt) + self.SetReceipts(self.receipts) +} func (self *Block) RlpData() interface{} { return []interface{}{self.header, self.transactions, self.uncles} @@ -166,16 +173,13 @@ func (self *Block) RlpDataForStorage() interface{} { } // Header accessors (add as you need them) -func (self *Block) Number() *big.Int { return self.header.Number } -func (self *Block) NumberU64() uint64 { return self.header.Number.Uint64() } -func (self *Block) Bloom() []byte { return self.header.Bloom } -func (self *Block) Coinbase() []byte { return self.header.Coinbase } -func (self *Block) Time() int64 { return int64(self.header.Time) } -func (self *Block) GasLimit() *big.Int { return self.header.GasLimit } -func (self *Block) GasUsed() *big.Int { return self.header.GasUsed } - -//func (self *Block) Trie() *ptrie.Trie { return ptrie.New(self.header.Root, ethutil.Config.Db) } -//func (self *Block) State() *state.StateDB { return state.New(self.Trie()) } +func (self *Block) Number() *big.Int { return self.header.Number } +func (self *Block) NumberU64() uint64 { return self.header.Number.Uint64() } +func (self *Block) Bloom() []byte { return self.header.Bloom } +func (self *Block) Coinbase() []byte { return self.header.Coinbase } +func (self *Block) Time() int64 { return int64(self.header.Time) } +func (self *Block) GasLimit() *big.Int { return self.header.GasLimit } +func (self *Block) GasUsed() *big.Int { return self.header.GasUsed } func (self *Block) Root() []byte { return self.header.Root } func (self *Block) SetRoot(root []byte) { self.header.Root = root } func (self *Block) Size() ethutil.StorageSize { return ethutil.StorageSize(len(ethutil.Encode(self))) } -- cgit v1.2.3