forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core, miner: miner header validation, transaction & receipt writing
* Miners do now verify their own header, not their state. * Changed old putTx and putReceipts to be exported * Moved writing of transactions and receipts out of the block processer in to the chain manager. Closes ethereum#1386 * Miner post ChainHeadEvent & ChainEvent. Closes ethereum#1388
- Loading branch information
Showing
15 changed files
with
126 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package core | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/logger" | ||
"github.com/ethereum/go-ethereum/logger/glog" | ||
"github.com/ethereum/go-ethereum/rlp" | ||
) | ||
|
||
func PutTransactions(db common.Database, block *types.Block, txs types.Transactions) { | ||
for i, tx := range block.Transactions() { | ||
rlpEnc, err := rlp.EncodeToBytes(tx) | ||
if err != nil { | ||
glog.V(logger.Debug).Infoln("Failed encoding tx", err) | ||
return | ||
} | ||
db.Put(tx.Hash().Bytes(), rlpEnc) | ||
|
||
var txExtra struct { | ||
BlockHash common.Hash | ||
BlockIndex uint64 | ||
Index uint64 | ||
} | ||
txExtra.BlockHash = block.Hash() | ||
txExtra.BlockIndex = block.NumberU64() | ||
txExtra.Index = uint64(i) | ||
rlpMeta, err := rlp.EncodeToBytes(txExtra) | ||
if err != nil { | ||
glog.V(logger.Debug).Infoln("Failed encoding tx meta data", err) | ||
return | ||
} | ||
db.Put(append(tx.Hash().Bytes(), 0x0001), rlpMeta) | ||
} | ||
} | ||
|
||
func PutReceipts(db common.Database, hash common.Hash, receipts types.Receipts) error { | ||
storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) | ||
for i, receipt := range receipts { | ||
storageReceipts[i] = (*types.ReceiptForStorage)(receipt) | ||
} | ||
|
||
bytes, err := rlp.EncodeToBytes(storageReceipts) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
db.Put(append(receiptsPre, hash[:]...), bytes) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.