Skip to content

Commit

Permalink
lower time check, make bannable
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Jul 8, 2024
1 parent f278df3 commit e2d9739
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions mixing/mixpool/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ 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
Expand Down
5 changes: 2 additions & 3 deletions mixing/mixpool/mixpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

const minconf = 1
const feeRate = 0.0001e8
const clientTimeoutDuration = 30 * time.Second
const earlyKEDuration = 5 * time.Second

type idPubKey = [33]byte

Expand Down Expand Up @@ -1396,8 +1396,7 @@ func (p *Pool) checkAcceptKE(ke *wire.MsgMixKeyExchange) error {
}

keEpoch := time.Unix(int64(ke.Epoch), 0)
if keEpoch.Add(clientTimeoutDuration).Before(time.Now()) {
err := fmt.Errorf("KE received too early for stated epoch")
if keEpoch.Add(earlyKEDuration).Before(time.Now()) {
return ruleError(err)

Check failure on line 1400 in mixing/mixpool/mixpool.go

View workflow job for this annotation

GitHub Actions / Go CI (1.21)

undefined: err

Check failure on line 1400 in mixing/mixpool/mixpool.go

View workflow job for this annotation

GitHub Actions / Go CI (1.22)

undefined: err
}

Expand Down

0 comments on commit e2d9739

Please sign in to comment.