aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2019-06-28 15:34:02 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-06-28 15:34:02 +0800
commitf7cdea2bdcd7ff3cec99731cb912cde0b233d6c9 (patch)
treeb463c8dd42547edceb778d946927d2c363303324 /cmd/geth
parent702f52fb99d60b4b6bab05799c14dafdd8648854 (diff)
downloadgo-tangerine-f7cdea2bdcd7ff3cec99731cb912cde0b233d6c9.tar
go-tangerine-f7cdea2bdcd7ff3cec99731cb912cde0b233d6c9.tar.gz
go-tangerine-f7cdea2bdcd7ff3cec99731cb912cde0b233d6c9.tar.bz2
go-tangerine-f7cdea2bdcd7ff3cec99731cb912cde0b233d6c9.tar.lz
go-tangerine-f7cdea2bdcd7ff3cec99731cb912cde0b233d6c9.tar.xz
go-tangerine-f7cdea2bdcd7ff3cec99731cb912cde0b233d6c9.tar.zst
go-tangerine-f7cdea2bdcd7ff3cec99731cb912cde0b233d6c9.zip
all: on-chain oracle checkpoint syncing (#19543)
* all: implement simple checkpoint syncing cmd, les, node: remove callback mechanism cmd, node: remove callback definition les: simplify the registrar les: expose checkpoint rpc services in the light client les, light: don't store untrusted receipt cmd, contracts, les: discard stale checkpoint cmd, contracts/registrar: loose restriction of registeration cmd, contracts: add replay-protection all: off-chain multi-signature contract params: deploy checkpoint contract for rinkeby cmd/registrar: add raw signing mode for registrar cmd/registrar, contracts/registrar, les: fixed messages * cmd/registrar, contracts/registrar: fix lints * accounts/abi/bind, les: address comments * cmd, contracts, les, light, params: minor checkpoint sync cleanups * cmd, eth, les, light: move checkpoint config to config file * cmd, eth, les, params: address comments * eth, les, params: address comments * cmd: polish up the checkpoint admin CLI * cmd, contracts, params: deploy new version contract * cmd/checkpoint-admin: add another flag for clef mode signing * cmd, contracts, les: rename and regen checkpoint oracle with abigen
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/main.go35
1 files changed, 27 insertions, 8 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 00809e2e1..7e94da1f5 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -37,6 +37,7 @@ import (
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/internal/debug"
+ "github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
@@ -323,14 +324,33 @@ func startNode(ctx *cli.Context, stack *node.Node) {
events := make(chan accounts.WalletEvent, 16)
stack.AccountManager().Subscribe(events)
- go func() {
- // Create a chain state reader for self-derivation
- rpcClient, err := stack.Attach()
- if err != nil {
- utils.Fatalf("Failed to attach to self: %v", err)
+ // Create a client to interact with local geth node.
+ rpcClient, err := stack.Attach()
+ if err != nil {
+ utils.Fatalf("Failed to attach to self: %v", err)
+ }
+ ethClient := ethclient.NewClient(rpcClient)
+
+ // Set contract backend for ethereum service if local node
+ // is serving LES requests.
+ if ctx.GlobalInt(utils.LightServFlag.Name) > 0 {
+ var ethService *eth.Ethereum
+ if err := stack.Service(&ethService); err != nil {
+ utils.Fatalf("Failed to retrieve ethereum service: %v", err)
+ }
+ ethService.SetContractBackend(ethClient)
+ }
+ // Set contract backend for les service if local node is
+ // running as a light client.
+ if ctx.GlobalString(utils.SyncModeFlag.Name) == "light" {
+ var lesService *les.LightEthereum
+ if err := stack.Service(&lesService); err != nil {
+ utils.Fatalf("Failed to retrieve light ethereum service: %v", err)
}
- stateReader := ethclient.NewClient(rpcClient)
+ lesService.SetContractBackend(ethClient)
+ }
+ go func() {
// Open any wallets already attached
for _, wallet := range stack.AccountManager().Wallets() {
if err := wallet.Open(""); err != nil {
@@ -354,7 +374,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
}
derivationPaths = append(derivationPaths, accounts.DefaultBaseDerivationPath)
- event.Wallet.SelfDerive(derivationPaths, stateReader)
+ event.Wallet.SelfDerive(derivationPaths, ethClient)
case accounts.WalletDropped:
log.Info("Old wallet dropped", "url", event.Wallet.URL())
@@ -383,7 +403,6 @@ func startNode(ctx *cli.Context, stack *node.Node) {
"age", common.PrettyAge(timestamp))
stack.Stop()
}
-
}
}()
}