Skip to content

Commit

Permalink
mixing: introduce module
Browse files Browse the repository at this point in the history
This introduces the mixing module and mixpool package which implements
a mixing message pool.  Similar to the transaction mempool, the
mixpool records recently observed mixing messages and 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 also designed with wallet usage in mind, providing most
of these same acceptance rules to mixing messages received by wallets,
and implements queries for messages matching compatible pairings and
ongoing sessions.
  • Loading branch information
jrick committed Apr 5, 2023
1 parent 7cdb08e commit 2d0d3c6
Show file tree
Hide file tree
Showing 5 changed files with 966 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mixing/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/decred/dcrd/mixing

go 1.17
31 changes: 31 additions & 0 deletions mixing/mixpool/log.go
Original file line number Diff line number Diff line change
@@ -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 2d0d3c6

Please sign in to comment.