From e602a34fb8fef66d72c03ac5ad0ecbbd5c571b3c Mon Sep 17 00:00:00 2001 From: gary rong <garyrong0905@gmail.com> Date: Thu, 25 Feb 2021 20:55:07 +0800 Subject: [PATCH] cmd, eth, les: enable serving light clients when non-synced (#22250) This PR adds a more CLI flag, so that the les-server can serve light clients even the local node is not synced yet. This functionality is needed in some testing environments(e.g. hive). After launching the les server, no more blocks will be imported so the node is always marked as "non-synced". # Conflicts: # cmd/geth/main.go # cmd/geth/usage.go # cmd/utils/flags.go # eth/ethconfig/gen_config.go # les/server.go --- eth/ethconfig/config.go | 1 + eth/ethconfig/gen_config.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index faafbc1557..8a5ceb18ea 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -162,6 +162,7 @@ type Config struct { LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers LightPeers int `toml:",omitempty"` // Maximum number of LES client peers LightNoPrune bool `toml:",omitempty"` // Whether to disable light chain pruning + LightNoSyncServe bool `toml:",omitempty"` // Whether to serve light clients before syncing SyncFromCheckpoint bool `toml:",omitempty"` // Whether to sync the header chain from the configured checkpoint // Ultra Light client options diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index cff2f84ed4..e5d224036c 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -29,6 +29,8 @@ func (c Config) MarshalTOML() (interface{}, error) { LightIngress int `toml:",omitempty"` LightEgress int `toml:",omitempty"` StorageMode string + LightNoPrune bool `toml:",omitempty"` + LightNoSyncServe bool `toml:",omitempty"` ArchiveSyncInterval int LightServ int `toml:",omitempty"` LightPeers int `toml:",omitempty"` @@ -112,6 +114,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { LightIngress *int `toml:",omitempty"` LightEgress *int `toml:",omitempty"` Mode *string + LightNoPrune *bool `toml:",omitempty"` + LightNoSyncServe *bool `toml:",omitempty"` ArchiveSyncInterval *int LightServ *int `toml:",omitempty"` LightPeers *int `toml:",omitempty"` -- GitLab