From 5b5334728f292641a33306f1d53ec50f5b150d50 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Mon, 8 Jul 2024 14:07:22 +0000 Subject: [PATCH] can't ban for this yet, but may want to eventually --- mixing/mixpool/errors.go | 4 ---- mixing/mixpool/mixpool.go | 5 +++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/mixing/mixpool/errors.go b/mixing/mixpool/errors.go index f43d57da5..6e342f909 100644 --- a/mixing/mixpool/errors.go +++ b/mixing/mixpool/errors.go @@ -91,10 +91,6 @@ var ( // position of a peer's own PR is outside of the possible bounds of // the previously seen messages. ErrPeerPositionOutOfBounds = newBannableError("peer position cannot be a valid seen PRs index", 0) - - // ErrEarlyKE is returned by AcceptMessage if a key exchange message - // with a stated epoch is sent too early for that epoch time. - ErrEarlyKE = newBannableError("KE received too early for stated epoch", 0) ) // IsBannable returns whether the error condition is such that the peer with diff --git a/mixing/mixpool/mixpool.go b/mixing/mixpool/mixpool.go index 29aa6e875..55c8599d5 100644 --- a/mixing/mixpool/mixpool.go +++ b/mixing/mixpool/mixpool.go @@ -1396,8 +1396,9 @@ func (p *Pool) checkAcceptKE(ke *wire.MsgMixKeyExchange) error { } keEpoch := time.Unix(int64(ke.Epoch), 0) - if keEpoch.Add(earlyKEDuration).Before(time.Now()) { - return ruleError(ErrEarlyKE) + if time.Now().Add(-earlyKEDuration).Before(keEpoch) { + err := fmt.Errorf("KE received too early for stated epoch") + return ruleError(err) } return nil