Merge pull request #77 from getamis/feature/genesis-alloc

container, genesis: use common.Address in genesis alloc option
This commit is contained in:
Alan Chen 2017-09-13 17:25:21 +08:00 committed by GitHub
commit 2950c03765
2 changed files with 9 additions and 5 deletions

View File

@ -512,9 +512,14 @@ func (bc *blockchain) generateAccounts(num int) {
func (bc *blockchain) setupGenesis(addrs []common.Address) {
balance, _ := new(big.Int).SetString(allocBalance, 10)
if bc.genesisFile == "" {
var allocAddrs []common.Address
allocAddrs = append(allocAddrs, addrs...)
for _, acc := range bc.accounts {
allocAddrs = append(allocAddrs, acc.Address)
}
bc.genesisFile = genesis.NewFile(bc.isQuorum,
genesis.Validators(addrs...),
genesis.Alloc(bc.accounts, balance),
genesis.Alloc(allocAddrs, balance),
)
}
}

View File

@ -19,7 +19,6 @@ package genesis
import (
"math/big"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core"
@ -47,11 +46,11 @@ func GasLimit(limit uint64) Option {
}
}
func Alloc(accounts []accounts.Account, balance *big.Int) Option {
func Alloc(addrs []common.Address, balance *big.Int) Option {
return func(genesis *core.Genesis) {
alloc := make(map[common.Address]core.GenesisAccount)
for _, a := range accounts {
alloc[a.Address] = core.GenesisAccount{Balance: balance}
for _, addr := range addrs {
alloc[addr] = core.GenesisAccount{Balance: balance}
}
genesis.Alloc = alloc
}