From 3ba6900b81f1249b0c9abbe0d6b72d8d70ba297c Mon Sep 17 00:00:00 2001 From: Lucas Hendren Date: Thu, 30 Aug 2018 01:34:36 -0400 Subject: [PATCH] cmd/geth/main, les/fletcher: added in light mode support --- cmd/geth/main.go | 12 ++++++++++++ les/fetcher.go | 1 + 2 files changed, 13 insertions(+) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index e91fcf6576..2544ecfaeb 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -34,6 +34,7 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/console" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/internal/debug" "github.com/ethereum/go-ethereum/log" @@ -322,7 +323,18 @@ func startNode(ctx *cli.Context, stack *node.Node) { if exitWhenSynced := ctx.GlobalDuration(utils.ExitWhenSyncedFlag.Name); exitWhenSynced >= 0 { go func() { //TODO addd in light mode support + log.Info("🔗 block Synced 🔗 ") + if ctx.GlobalBool(utils.LightModeFlag.Name) || ctx.GlobalString(utils.SyncModeFlag.Name) == "light" { + var lightEthereum *les.LightEthereum + if err := stack.Service(&lightEthereum); err != nil { + utils.Fatalf("LightEthereum service not running: %v", err) + } + <-lightEthereum.Downloader().SyncedCh + log.Info("Synchronisation completed, exitting", "countdown", exitWhenSynced) + time.Sleep(exitWhenSynced) + stack.Stop() + } else { var ethereum *eth.Ethereum diff --git a/les/fetcher.go b/les/fetcher.go index eff58b8711..280247300c 100644 --- a/les/fetcher.go +++ b/les/fetcher.go @@ -447,6 +447,7 @@ func (f *lightFetcher) nextRequest() (*distReq, uint64) { p.Log().Debug("Synchronisation started") f.pm.synchronise(p) f.syncDone <- p + f.SyncedCh <- true }() return nil },