1

I am not able to locate, the declaration of the following variables (Time, ParentHash, Extra, etc.) in go-ethereum. It is the part of the core/genesis.go program

Variable:

            Time:       common.String2Big(genesis.Timestamp),
            ParentHash: common.HexToHash(genesis.ParentHash),
            Extra:      common.FromHex(genesis.ExtraData),
            GasLimit:   common.String2Big(genesis.GasLimit),
            Difficulty: difficulty,
            MixDigest:  common.HexToHash(genesis.Mixhash),
            Coinbase:   common.HexToAddress(genesis.Coinbase),
            Root:       root,

I found the declarations in core/types/block.go, but those declarations are not mapping with this. I wish to add additional parameter in the block. I would like to do it in private network.

2

If you want to add a new variable to the block header - and it sounds like you do - then block.go is the place to start.

I'd start with the definition of Header itself, then look at other places in that file that the new member will need to be added. (For example, the JSON definition and associated functions [1, 2] .)

With regards to how these variables are set, if the variable is something that you want to be able to set in the genesis block of your private chain, then you'll also need to handle it in genesis.go (like you found). If the variable relates to something that is set after genesis, then you will need to decide how and where to do that - it will presumably depend on exactly what the function of the variable is.

  • thank you very much. I made the mistake that I did not use capital first letter for the new variable. – userven Jan 3 '17 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.