mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
Merge pull request #253 from gzliudan/issue-252
remove genesis file dependency for apothem network
This commit is contained in:
commit
858bfa2b84
3 changed files with 170 additions and 15 deletions
143
cmd/XDC/apothem.go
Normal file
143
cmd/XDC/apothem.go
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -19,7 +19,6 @@ package main
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
|
@ -30,6 +29,7 @@ import (
|
|||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/console"
|
||||
"github.com/XinFinOrg/XDPoSChain/core"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/state"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
||||
"github.com/XinFinOrg/XDPoSChain/eth/downloader"
|
||||
|
|
@ -47,6 +47,7 @@ var (
|
|||
Flags: []cli.Flag{
|
||||
utils.DataDirFlag,
|
||||
utils.LightModeFlag,
|
||||
utils.XDCTestnetFlag,
|
||||
},
|
||||
Category: "BLOCKCHAIN COMMANDS",
|
||||
Description: `
|
||||
|
|
@ -174,19 +175,31 @@ Use "ethereum dump 0" to dump the genesis block.`,
|
|||
func initGenesis(ctx *cli.Context) error {
|
||||
// Make sure we have a valid genesis JSON
|
||||
genesisPath := ctx.Args().First()
|
||||
if len(genesisPath) == 0 {
|
||||
utils.Fatalf("Must supply path to genesis JSON file")
|
||||
}
|
||||
file, err := os.Open(genesisPath)
|
||||
if err != nil {
|
||||
utils.Fatalf("Failed to read genesis file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
genesis := new(core.Genesis)
|
||||
if err := json.NewDecoder(file).Decode(genesis); err != nil {
|
||||
utils.Fatalf("invalid genesis file: %v", err)
|
||||
|
||||
if ctx.GlobalBool(utils.XDCTestnetFlag.Name) {
|
||||
if len(genesisPath) > 0 {
|
||||
utils.Fatalf("Flags --apothem and genesis file can't be used at the same time")
|
||||
}
|
||||
err := json.Unmarshal(apothemGenesis, &genesis)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid genesis json: %v", err)
|
||||
}
|
||||
} else {
|
||||
if len(genesisPath) == 0 {
|
||||
utils.Fatalf("Must supply path to genesis JSON file")
|
||||
}
|
||||
file, err := os.Open(genesisPath)
|
||||
if err != nil {
|
||||
utils.Fatalf("Failed to read genesis file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if err := json.NewDecoder(file).Decode(genesis); err != nil {
|
||||
utils.Fatalf("invalid genesis file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Open an initialise both full and light databases
|
||||
stack, _ := makeFullNode(ctx)
|
||||
for _, name := range []string{"chaindata", "lightchaindata"} {
|
||||
|
|
|
|||
|
|
@ -160,15 +160,14 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
|
|||
common.TRC21IssuerSMC = common.TRC21IssuerSMCTestNet
|
||||
cfg.Eth.NetworkId = 51
|
||||
common.RelayerRegistrationSMC = common.RelayerRegistrationSMCTestnet
|
||||
common.TIPTRC21Fee = common.TIPXDCXTestnet
|
||||
common.TIPTRC21Fee = common.TIPTRC21FeeTestnet
|
||||
common.TIPXDCXCancellationFee = common.TIPXDCXCancellationFeeTestnet
|
||||
}
|
||||
|
||||
if ctx.GlobalBool(utils.Enable0xPrefixFlag.Name) {
|
||||
common.Enable0xPrefix = true;
|
||||
common.Enable0xPrefix = true
|
||||
}
|
||||
|
||||
|
||||
// Rewound
|
||||
if rewound := ctx.GlobalInt(utils.RewoundFlag.Name); rewound != 0 {
|
||||
common.Rewound = uint64(rewound)
|
||||
|
|
|
|||
Loading…
Reference in a new issue