From ab7a69bfec0fc644663c133e8016c0884cc9e0ae Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 10 Aug 2020 00:03:23 +0300 Subject: [PATCH] network: prevent useless getroots requests At the height of A we only reliably have a state root for A-1, so there is no point in requesting state root for A from our peers. Prevents tons of useless traffic: 2020-08-10T00:02:35.537+0300 DEBUG got msg {"addr": "127.0.0.1:20333", "type": "getroots"} 2020-08-10T00:02:35.537+0300 DEBUG got msg {"addr": "127.0.0.1:20333", "type": "roots"} 2020-08-10T00:02:35.537+0300 DEBUG got msg {"addr": "127.0.0.1:20333", "type": "getroots"} 2020-08-10T00:02:35.537+0300 DEBUG got msg {"addr": "127.0.0.1:20333", "type": "roots"} 2020-08-10T00:02:35.539+0300 DEBUG got msg {"addr": "127.0.0.1:20335", "type": "getroots"} 2020-08-10T00:02:35.539+0300 DEBUG got msg {"addr": "127.0.0.1:20335", "type": "roots"} 2020-08-10T00:02:35.539+0300 DEBUG got msg {"addr": "127.0.0.1:20334", "type": "getroots"} 2020-08-10T00:02:35.539+0300 DEBUG got msg {"addr": "127.0.0.1:20334", "type": "roots"} 2020-08-10T00:02:35.540+0300 DEBUG got msg {"addr": "127.0.0.1:20334", "type": "getroots"} 2020-08-10T00:02:35.540+0300 DEBUG got msg {"addr": "127.0.0.1:20334", "type": "roots"} 2020-08-10T00:02:35.542+0300 DEBUG got msg {"addr": "127.0.0.1:20336", "type": "getroots"} 2020-08-10T00:02:35.542+0300 DEBUG got msg {"addr": "127.0.0.1:20336", "type": "roots"} --- pkg/network/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/network/server.go b/pkg/network/server.go index aadc7d6d0..af79c964e 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -657,7 +657,7 @@ func (s *Server) requestStateRoot(p Peer) error { if diff := hdrHeight - stateHeight; diff < count { count = diff } - if count == 0 { + if count <= 1 { return nil } gr := &payload.GetStateRoots{