Skip to content

Commit

Permalink
mempool: Rename RelayNonStd config option.
Browse files Browse the repository at this point in the history
This renames the mempool.Config.RelayNonStd option to AcceptNonStd which
more accurately describes its behavior since the mempool was refactored
into a separate package.

The reasoning for this change is that the mempool is not responsible for
relaying transactions (nor should it be).  Its job is to maintain a pool
of unmined transactions that are validated according to consensus and
policy configuration options which are then used to provide a source of
transactions that need to be mined.

Instead, it is the server that is responsible for relaying transactions.
While it is true that the current server code currently only relays txns
that were accepted to the mempool, this does not necessarily have to
be the case.  It would be entirely possible (and perhaps even a good
idea as something do in the future), to separate the relay policy from
the mempool acceptance policy (and thus indirectly the mining policy).
  • Loading branch information
davecgh committed Oct 24, 2016
1 parent f161d6b commit 26e2279
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ type Policy struct {
// transactions that do not have enough priority to be relayed.
DisableRelayPriority bool

// RelayNonStd defines whether to relay non-standard transactions. If
// true, non-standard transactions will be accepted into the mempool
// and relayed. Otherwise, all non-standard transactions will be
// rejected.
RelayNonStd bool
// AcceptNonStd defines whether to accept non-standard transactions. If
// true, non-standard transactions will be accepted into the mempool.
// Otherwise, all non-standard transactions will be rejected.
AcceptNonStd bool

// FreeTxRelayLimit defines the given amount in thousands of bytes
// per minute that transactions with no fee are rate limited to.
Expand Down Expand Up @@ -546,8 +545,8 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit bool)
nextBlockHeight := bestHeight + 1

// Don't allow non-standard transactions if the network parameters
// forbid their relaying.
if !mp.cfg.Policy.RelayNonStd {
// forbid their acceptance.
if !mp.cfg.Policy.AcceptNonStd {
medianTimePast := mp.cfg.MedianTimePast()
err = checkTransactionStandard(tx, nextBlockHeight,
medianTimePast, mp.cfg.Policy.MinRelayTxFee)
Expand Down Expand Up @@ -632,8 +631,8 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit bool)
}

// Don't allow transactions with non-standard inputs if the network
// parameters forbid their relaying.
if !mp.cfg.Policy.RelayNonStd {
// parameters forbid their acceptance.
if !mp.cfg.Policy.AcceptNonStd {
err := checkInputsStandard(tx, utxoView)
if err != nil {
// Attempt to extract a reject code from the error so
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2349,7 +2349,7 @@ func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Param
txC := mempool.Config{
Policy: mempool.Policy{
DisableRelayPriority: cfg.NoRelayPriority,
RelayNonStd: cfg.RelayNonStd,
AcceptNonStd: cfg.RelayNonStd,
FreeTxRelayLimit: cfg.FreeTxRelayLimit,
MaxOrphanTxs: cfg.MaxOrphanTxs,
MaxOrphanTxSize: defaultMaxOrphanTxSize,
Expand Down

0 comments on commit 26e2279

Please sign in to comment.