Skip to content

Commit

Permalink
mixpool: remove expiry from message interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Mar 19, 2024
1 parent 495ae90 commit f8c573d
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions mixing/mixpool/mixpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,6 @@ func (p *Pool) AcceptMessage(msg mixing.Message) (accepted mixing.Message, err e
}
id := (*idPubKey)(msg.Pub())

// Check that expiry has not been reached, nor that it is too far
// into the future. This limits replay attacks.
_, curHeight := p.blockchain.BestHeader()
err = checkExpiry(msg, uint32(curHeight), p.params)
if err != nil {
return nil, err
}

var msgtype msgtype
switch msg := msg.(type) {
case *wire.MsgMixPairReq:
Expand Down Expand Up @@ -703,19 +695,18 @@ func (p *Pool) AcceptMessage(msg mixing.Message) (accepted mixing.Message, err e
return msg, nil
}

func checkExpiry(msg mixing.Message, curHeight uint32, params *chaincfg.Params) error {
expires := msg.Expires()
maxExpiry := mixing.MaxExpiry(curHeight, params)
func (p *Pool) acceptPR(pr *wire.MsgMixPairReq, hash *chainhash.Hash, id *idPubKey) (accepted *wire.MsgMixPairReq, err error) {
// Check that expiry has not been reached, nor that it is too far
// into the future. This limits replay attacks.
_, curHeight := p.blockchain.BestHeader()
maxExpiry := mixing.MaxExpiry(uint32(curHeight), p.params)
switch {
case curHeight >= expires:
return fmt.Errorf("message has expired")
case expires > maxExpiry:
return fmt.Errorf("expiry is too far into future")
case uint32(curHeight) >= pr.Expiry:
return nil, fmt.Errorf("message has expired")
case pr.Expiry > maxExpiry:
return nil, fmt.Errorf("expiry is too far into future")
}
return nil
}

func (p *Pool) acceptPR(pr *wire.MsgMixPairReq, hash *chainhash.Hash, id *idPubKey) (accepted *wire.MsgMixPairReq, err error) {
if len(pr.UTXOs) == 0 {
return nil, fmt.Errorf("at least one UTXO must be submitted")
}
Expand Down

0 comments on commit f8c573d

Please sign in to comment.