aboutsummaryrefslogtreecommitdiffstats
path: root/core/block_processor.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/block_processor.go')
-rw-r--r--core/block_processor.go34
1 files changed, 15 insertions, 19 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index 7171e3b2e..e8014ec22 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -9,12 +9,12 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
- "github.com/ethereum/go-ethereum/rlp"
"gopkg.in/fatih/set.v0"
)
@@ -24,8 +24,6 @@ const (
BlockChainVersion = 3
)
-var receiptsPre = []byte("receipts-")
-
type BlockProcessor struct {
db common.Database
extraDb common.Database
@@ -83,6 +81,12 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
usedGas.Add(usedGas, gas)
receipt := types.NewReceipt(statedb.Root().Bytes(), usedGas)
+ receipt.TxHash = tx.Hash()
+ if MessageCreatesContract(tx) {
+ from, _ := tx.From()
+ receipt.ContractAddress = crypto.CreateAddress(from, tx.Nonce())
+ }
+
logs := statedb.GetLogs(tx.Hash())
receipt.SetLogs(logs)
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
@@ -319,16 +323,20 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
}
// GetBlockReceipts returns the receipts beloniging to the block hash
-func (sm *BlockProcessor) GetBlockReceipts(bhash common.Hash) (receipts types.Receipts, err error) {
- return getBlockReceipts(sm.extraDb, bhash)
+func (sm *BlockProcessor) GetBlockReceipts(bhash common.Hash) types.Receipts {
+ if block := sm.ChainManager().GetBlock(bhash); block != nil {
+ return GetReceiptsFromBlock(sm.extraDb, block)
+ }
+
+ return nil
}
// GetLogs returns the logs of the given block. This method is using a two step approach
// where it tries to get it from the (updated) method which gets them from the receipts or
// the depricated way by re-processing the block.
func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err error) {
- receipts, err := sm.GetBlockReceipts(block.Hash())
- if err == nil && len(receipts) > 0 {
+ receipts := GetReceiptsFromBlock(sm.extraDb, block)
+ if len(receipts) > 0 {
// coalesce logs
for _, receipt := range receipts {
logs = append(logs, receipt.Logs()...)
@@ -391,15 +399,3 @@ func ValidateHeader(pow pow.PoW, block *types.Header, parent *types.Block, check
return nil
}
-
-func getBlockReceipts(db common.Database, bhash common.Hash) (receipts types.Receipts, err error) {
- var rdata []byte
- rdata, err = db.Get(append(receiptsPre, bhash[:]...))
-
- if err == nil {
- err = rlp.DecodeBytes(rdata, &receipts)
- } else {
- glog.V(logger.Detail).Infof("getBlockReceipts error %v\n", err)
- }
- return
-}