Skip to content

Commit

Permalink
add onlyannounce flag
Browse files Browse the repository at this point in the history
  • Loading branch information
b00ris committed May 3, 2018
1 parent c535734 commit c8e44cd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ var (
utils.FastSyncFlag,
utils.LightModeFlag,
utils.ULCModeConfigFlag,
utils.OnlyAnnounceModeFlag,
utils.SyncModeFlag,
utils.GCModeFlag,
utils.LightServFlag,
Expand Down
7 changes: 7 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ var (
Name: "ulcconfig",
Usage: "Config file to use for ULC mode",
}
OnlyAnnounceModeFlag = cli.BoolFlag{
Name: "onlyannounce",
Usage: "Les server sends only announce",
}
defaultSyncMode = eth.DefaultConfig.SyncMode
SyncModeFlag = TextMarshalerFlag{
Name: "syncmode",
Expand Down Expand Up @@ -1062,6 +1066,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
if ctx.GlobalIsSet(LightPeersFlag.Name) {
cfg.LightPeers = ctx.GlobalInt(LightPeersFlag.Name)
}
if ctx.GlobalIsSet(OnlyAnnounceModeFlag.Name) {
cfg.OnlyAnnounce = ctx.GlobalBool(OnlyAnnounceModeFlag.Name)
}
if ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = ctx.GlobalUint64(NetworkIdFlag.Name)
}
Expand Down
1 change: 1 addition & 0 deletions eth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type Config struct {
// Light client options
LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
OnlyAnnounce bool `toml:",omitempty"` // Maximum number of LES client peers

// Ultra Light client options
ULC *ULCConfig `toml:",omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion les/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func (p *peer) Handshake(td *big.Int, head common.Hash, headNum uint64, genesis
send = send.add("headNum", headNum)
send = send.add("genesisHash", genesis)
if server != nil {
if !server.onlyAnnounse {
if !server.onlyAnnounce {
//only announce server. It sends only announse requests
send = send.add("serveHeaders", nil)
send = send.add("serveChainSince", uint64(0))
Expand Down
4 changes: 0 additions & 4 deletions les/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,6 @@ func TestPeerHandshakeClientReceiveOnlyAnnounceRequestsHeaders(t *testing.T) {
version: protocol_version,
rw: &rwStub{
ReadHook: func(l keyValueList) keyValueList {
//l = l.add("serveHeaders", nil)
//l = l.add("serveChainSince", uint64(0))
//l = l.add("serveStateSince", uint64(0))
//l = l.add("txRelay", nil)
l = l.add("flowControl/BL", uint64(0))
l = l.add("flowControl/MRR", uint64(0))
l = l.add("flowControl/MRC", RequestCostList{})
Expand Down
3 changes: 2 additions & 1 deletion les/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type LesServer struct {
lesTopics []discv5.Topic
privateKey *ecdsa.PrivateKey
quitSync chan struct{}
onlyAnnounse bool
onlyAnnounce bool

chtIndexer, bloomTrieIndexer *core.ChainIndexer
}
Expand Down Expand Up @@ -84,6 +84,7 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
lesTopics: lesTopics,
chtIndexer: light.NewChtIndexer(eth.ChainDb(), false),
bloomTrieIndexer: light.NewBloomTrieIndexer(eth.ChainDb(), false),
onlyAnnounce: config.OnlyAnnounce,
}

logger := log.New()
Expand Down

0 comments on commit c8e44cd

Please sign in to comment.