Block header changed & console miner control

* miner control moved to `admin.miner`
* miner option to set extra data
* block extra now bytes
This commit is contained in:
obscuren
2015-04-05 18:57:03 +02:00
parent 3040296beb
commit 9c55576c7b
8 changed files with 41 additions and 14 deletions

View File

@ -55,7 +55,7 @@ func NewCanonical(n int, db common.Database) (*BlockProcessor, error) {
// block time is fixed at 10 seconds
func newBlockFromParent(addr common.Address, parent *types.Block) *types.Block {
block := types.NewBlock(parent.Hash(), addr, parent.Root(), common.BigPow(2, 32), 0, "")
block := types.NewBlock(parent.Hash(), addr, parent.Root(), common.BigPow(2, 32), 0, nil)
block.SetUncles(nil)
block.SetTransactions(nil)
block.SetReceipts(nil)

View File

@ -228,7 +228,7 @@ func (bc *ChainManager) NewBlock(coinbase common.Address) *types.Block {
root,
common.BigPow(2, 32),
0,
"")
nil)
block.SetUncles(nil)
block.SetTransactions(nil)
block.SetReceipts(nil)

View File

@ -20,7 +20,7 @@ var ZeroHash160 = make([]byte, 20)
var ZeroHash512 = make([]byte, 64)
func GenesisBlock(db common.Database) *types.Block {
genesis := types.NewBlock(common.Hash{}, common.Address{}, common.Hash{}, params.GenesisDifficulty, 42, "")
genesis := types.NewBlock(common.Hash{}, common.Address{}, common.Hash{}, params.GenesisDifficulty, 42, nil)
genesis.Header().Number = common.Big0
genesis.Header().GasLimit = params.GenesisGasLimit
genesis.Header().GasUsed = common.Big0

View File

@ -39,7 +39,7 @@ type Header struct {
// Creation time
Time uint64
// Extra data
Extra string
Extra []byte
// Mix digest for quick checking to prevent DOS
MixDigest common.Hash
// Nonce
@ -121,7 +121,7 @@ type storageblock struct {
TD *big.Int
}
func NewBlock(parentHash common.Hash, coinbase common.Address, root common.Hash, difficulty *big.Int, nonce uint64, extra string) *Block {
func NewBlock(parentHash common.Hash, coinbase common.Address, root common.Hash, difficulty *big.Int, nonce uint64, extra []byte) *Block {
header := &Header{
Root: root,
ParentHash: parentHash,
@ -371,7 +371,7 @@ func (self *Header) String() string {
GasLimit: %v
GasUsed: %v
Time: %v
Extra: %v
Extra: %s
MixDigest: %x
Nonce: %x`,
self.ParentHash, self.UncleHash, self.Coinbase, self.Root, self.TxHash, self.ReceiptHash, self.Bloom, self.Difficulty, self.Number, self.GasLimit, self.GasUsed, self.Time, self.Extra, self.MixDigest, self.Nonce)