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"}
This commit is contained in:
Roman Khimov 2020-08-10 00:03:23 +03:00
parent 253c39d4ee
commit ab7a69bfec

View file

@ -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{