@@ -9,12 +9,12 @@ import (
99 "github.com/ethereum/go-ethereum/common"
1010 "github.com/ethereum/go-ethereum/core/state"
1111 "github.com/ethereum/go-ethereum/core/types"
12+ "github.com/ethereum/go-ethereum/crypto"
1213 "github.com/ethereum/go-ethereum/event"
1314 "github.com/ethereum/go-ethereum/logger"
1415 "github.com/ethereum/go-ethereum/logger/glog"
1516 "github.com/ethereum/go-ethereum/params"
1617 "github.com/ethereum/go-ethereum/pow"
17- "github.com/ethereum/go-ethereum/rlp"
1818 "gopkg.in/fatih/set.v0"
1919)
2020
@@ -24,8 +24,6 @@ const (
2424 BlockChainVersion = 3
2525)
2626
27- var receiptsPre = []byte ("receipts-" )
28-
2927type BlockProcessor struct {
3028 db common.Database
3129 extraDb common.Database
@@ -83,6 +81,12 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
8381
8482 usedGas .Add (usedGas , gas )
8583 receipt := types .NewReceipt (statedb .Root ().Bytes (), usedGas )
84+ receipt .TxHash = tx .Hash ()
85+ if MessageCreatesContract (tx ) {
86+ from , _ := tx .From ()
87+ receipt .ContractAddress = crypto .CreateAddress (from , tx .Nonce ())
88+ }
89+
8690 logs := statedb .GetLogs (tx .Hash ())
8791 receipt .SetLogs (logs )
8892 receipt .Bloom = types .CreateBloom (types.Receipts {receipt })
@@ -319,16 +323,20 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
319323}
320324
321325// GetBlockReceipts returns the receipts beloniging to the block hash
322- func (sm * BlockProcessor ) GetBlockReceipts (bhash common.Hash ) (receipts types.Receipts , err error ) {
323- return getBlockReceipts (sm .extraDb , bhash )
326+ func (sm * BlockProcessor ) GetBlockReceipts (bhash common.Hash ) types.Receipts {
327+ if block := sm .ChainManager ().GetBlock (bhash ); block != nil {
328+ return GetReceiptsFromBlock (sm .extraDb , block )
329+ }
330+
331+ return nil
324332}
325333
326334// GetLogs returns the logs of the given block. This method is using a two step approach
327335// where it tries to get it from the (updated) method which gets them from the receipts or
328336// the depricated way by re-processing the block.
329337func (sm * BlockProcessor ) GetLogs (block * types.Block ) (logs state.Logs , err error ) {
330- receipts , err := sm .GetBlockReceipts ( block . Hash () )
331- if err == nil && len (receipts ) > 0 {
338+ receipts := GetReceiptsFromBlock ( sm .extraDb , block )
339+ if len (receipts ) > 0 {
332340 // coalesce logs
333341 for _ , receipt := range receipts {
334342 logs = append (logs , receipt .Logs ()... )
@@ -391,15 +399,3 @@ func ValidateHeader(pow pow.PoW, block *types.Header, parent *types.Block, check
391399
392400 return nil
393401}
394-
395- func getBlockReceipts (db common.Database , bhash common.Hash ) (receipts types.Receipts , err error ) {
396- var rdata []byte
397- rdata , err = db .Get (append (receiptsPre , bhash [:]... ))
398-
399- if err == nil {
400- err = rlp .DecodeBytes (rdata , & receipts )
401- } else {
402- glog .V (logger .Detail ).Infof ("getBlockReceipts error %v\n " , err )
403- }
404- return
405- }
0 commit comments