From 2818ad97f5b302f76e3296195bf8daae1868c435 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Sun, 17 Mar 2019 09:12:50 +0800 Subject: dex: implement recovery mechanism (#258) * dex: implement recovery mechanism The DEXON recovery protocol allows us to use the Ethereum blockchain as a fallback consensus chain to coordinate recovery. * fix --- cmd/gdex/main.go | 1 + cmd/utils/flags.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'cmd') diff --git a/cmd/gdex/main.go b/cmd/gdex/main.go index dcd46e796..29b61a4ec 100644 --- a/cmd/gdex/main.go +++ b/cmd/gdex/main.go @@ -140,6 +140,7 @@ var ( utils.IndexerEnableFlag, utils.IndexerPluginFlag, utils.IndexerPluginFlagsFlag, + utils.RecoveryNetworkRPCFlag, configFileFlag, } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c6d60d0bb..6b0c682a7 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -664,6 +664,13 @@ var ( Usage: "External indexer plugin's flags if needed", Value: "", } + + // Dexcon settings. + RecoveryNetworkRPCFlag = cli.StringFlag{ + Name: "recovery.network-rpc", + Usage: "RPC URL of the recovery network", + Value: "https://mainnet.infura.io", + } ) // MakeDataDir retrieves the currently requested data directory, terminating @@ -1257,27 +1264,41 @@ func SetDexConfig(ctx *cli.Context, stack *node.Node, cfg *dex.Config) { cfg.RPCGasCap = new(big.Int).SetUint64(ctx.GlobalUint64(RPCGlobalGasCap.Name)) } + cfg.RecoveryNetworkRPC = ctx.GlobalString(RecoveryNetworkRPCFlag.Name) + // Override any default configs for hard coded networks. switch { case ctx.GlobalBool(TestnetFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 238 } + if !ctx.GlobalIsSet(RecoveryNetworkRPCFlag.Name) { + cfg.RecoveryNetworkRPC = "http://rinkeby.infura.io" + } cfg.Genesis = core.DefaultTestnetGenesisBlock() case ctx.GlobalBool(TaipeiFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 239 } + if !ctx.GlobalIsSet(RecoveryNetworkRPCFlag.Name) { + cfg.RecoveryNetworkRPC = "http://rinkeby.infura.io" + } cfg.Genesis = core.DefaultTaipeiGenesisBlock() case ctx.GlobalBool(YilanFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 240 } + if !ctx.GlobalIsSet(RecoveryNetworkRPCFlag.Name) { + cfg.RecoveryNetworkRPC = "http://rinkeby.infura.io" + } cfg.Genesis = core.DefaultYilanGenesisBlock() case ctx.GlobalBool(DeveloperFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 1337 } + if !ctx.GlobalIsSet(RecoveryNetworkRPCFlag.Name) { + cfg.RecoveryNetworkRPC = "http://rinkeby.infura.io" + } // Create new developer account or reuse existing one var ( developer accounts.Account -- cgit v1.2.3