consensus: check if payload is present in cache before validation

Don't check signature correctness twice.
This commit is contained in:
Evgenii Stratonikov 2020-06-29 10:21:44 +03:00
parent b92a1e3480
commit f67b8ce607

View file

@ -256,12 +256,12 @@ func (s *service) getKeyPair(pubs []crypto.PublicKey) (int, crypto.PrivateKey, c
// OnPayload handles Payload receive.
func (s *service) OnPayload(cp *Payload) {
log := s.log.With(zap.Stringer("hash", cp.Hash()))
if !s.validatePayload(cp) {
log.Debug("can't validate payload")
return
} else if s.cache.Has(cp.Hash()) {
if s.cache.Has(cp.Hash()) {
log.Debug("payload is already in cache")
return
} else if !s.validatePayload(cp) {
log.Debug("can't validate payload")
return
}
s.Config.Broadcast(cp)