network: do not process state roots below verified height

Implement fast path to skip state root retrieval and decoding.
This commit is contained in:
Evgenii Stratonikov 2020-06-22 11:46:57 +03:00
parent e2e1bd09ae
commit caf53740d3

View file

@ -621,7 +621,11 @@ func (s *Server) handleGetRootsCmd(p Peer, gr *payload.GetStateRoots) error {
// handleStateRootsCmd processees `roots` request.
func (s *Server) handleRootsCmd(p Peer, rs *payload.StateRoots) error {
h := s.chain.StateHeight()
for i := range rs.Roots {
if rs.Roots[i].Index <= h {
continue
}
_ = s.chain.AddStateRoot(&rs.Roots[i])
}
// request more state roots from peer if needed