Skip to content

Commit

Permalink
mixpool: Remove unused exported methods
Browse files Browse the repository at this point in the history
One exception: we are keeping RemoveConfirmedMixes.  This method behaves
similarly to RemoveSpentPRs but removes mixes that completed with a confirmed
coinjoin transaction matching any of the provided hashes.  This may be used
later by wallet to remove mixes that include transaction hashes in the merkle
tree, while dcrd can just provide the mined transactions themselves and remove
anything that double spends a PR UTXO.
  • Loading branch information
jrick committed Jun 3, 2024
1 parent 2796b22 commit 2eb935e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 59 deletions.
2 changes: 1 addition & 1 deletion mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func (c *Client) removeUnresponsiveDuringEpoch(prs []*wire.MsgMixPairReq, prevEp
}

func (c *Client) epochTicker(ctx context.Context) error {
prevPRs := c.mixpool.MixPRs(nil)
prevPRs := c.mixpool.MixPRs()

// Wait for the next epoch + the KE timeout + extra duration for local
// clock differences, then remove any previous pair requests that are
Expand Down
68 changes: 10 additions & 58 deletions mixing/mixpool/mixpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,6 @@ func (p *Pool) Epoch() time.Duration {
return p.epoch
}

// MixPRHashes returns the hashes of all MixPR messages recorded by the pool.
// This data is provided to peers requesting initial state of the mixpool.
func (p *Pool) MixPRHashes() []chainhash.Hash {
p.mtx.RLock()
hashes := make([]chainhash.Hash, 0, len(p.prs))
for hash := range p.prs {
hashes = append(hashes, hash)
}
p.mtx.RUnlock()

return hashes
}

// Message searches the mixing pool for a message by its hash.
func (p *Pool) Message(query *chainhash.Hash) (mixing.Message, error) {
p.mtx.RLock()
Expand All @@ -253,60 +240,25 @@ func (p *Pool) HaveMessage(query *chainhash.Hash) bool {
return ok
}

// MixPR searches the mixing pool for a PR message by its hash.
func (p *Pool) MixPR(query *chainhash.Hash) (*wire.MsgMixPairReq, error) {
var pr *wire.MsgMixPairReq

p.mtx.RLock()
pr = p.prs[*query]
p.mtx.RUnlock()

if pr == nil {
return nil, fmt.Errorf("PR message not found")
}

return pr, nil
}

// MixPRs returns all MixPR messages with hashes matching the query. Unknown
// messages are ignored.
//
// If query is nil, all PRs are returned.
// MixPRs returns all MixPR messages.
//
// In both cases, any expired PRs that are still internally tracked by the
// mixpool for ongoing sessions are excluded from the result set.
func (p *Pool) MixPRs(query []chainhash.Hash) []*wire.MsgMixPairReq {
// Any expired PRs that are still internally tracked by the mixpool for
// ongoing sessions are excluded from the result set.
func (p *Pool) MixPRs() []*wire.MsgMixPairReq {
p.mtx.Lock()
defer p.mtx.Unlock()

p.removeConfirmedRuns()

if query == nil {
res := make([]*wire.MsgMixPairReq, 0, len(p.prs))
for _, pr := range p.prs {
// Exclude expired but not yet removed PRs.
if pr.Expiry <= p.expireHeight {
continue
}

res = append(res, pr)
res := make([]*wire.MsgMixPairReq, 0, len(p.prs))
for _, pr := range p.prs {
// Exclude expired but not yet removed PRs.
if pr.Expiry <= p.expireHeight {
continue
}
return res
}

res := make([]*wire.MsgMixPairReq, 0, len(query))
for i := range query {
pr, ok := p.prs[query[i]]
if ok {
// Exclude expired but not yet removed PRs.
if pr.Expiry <= p.expireHeight {
continue
}

res = append(res, pr)
}
res = append(res, pr)
}

return res
}

Expand Down

0 comments on commit 2eb935e

Please sign in to comment.