Skip to content

Commit

Permalink
mixing: add mixpool package
Browse files Browse the repository at this point in the history
The mixpool package implements a memory pool of recently observed mix
messages.  Similar to the transaction mempool, the mixpool allows these
messages to be temporarily stored in memory to be relayed through the P2P
network.  It handles message acceptance, expiry, UTXO ownership proof checks,
and that previously referenced messages have also been accepted to the
mixpool.

The mixpool is designed with both full-node and wallet usage in mind,
providing all of these same acceptance rules to mixing wallets with the
exception of UTXO proof checks.  For wallets, it also implements query
functions for messages matching compatible pairings and messages belong to
ongoing sessions.
  • Loading branch information
jrick committed Nov 7, 2023
1 parent 5ca7c48 commit 7d3b021
Show file tree
Hide file tree
Showing 4 changed files with 1,571 additions and 0 deletions.
31 changes: 31 additions & 0 deletions mixing/mixpool/log.go
@@ -0,0 +1,31 @@
// Copyright (c) 2020-2021 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package mixpool

import (
"github.com/decred/slog"
)

// log is a logger that is initialized with no output filters. This
// means the package will not perform any logging by default until the caller
// requests it.
// The default amount of logging is none.
var log = slog.Disabled

// UseLogger uses a specified Logger to output package logging info.
// This should be used in preference to SetLogWriter if the caller is also
// using slog.
func UseLogger(logger slog.Logger) {
log = logger
}

// pickNoun returns the singular or plural form of a noun depending on the
// provided count.
func pickNoun(n uint64, singular, plural string) string {
if n == 1 {
return singular
}
return plural
}

0 comments on commit 7d3b021

Please sign in to comment.