mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
mempool: Rename RelayNonStd config option.
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).
This commit is contained in:
commit
e48b9ab823
@ -245,8 +245,9 @@ var simNetParams = &chaincfg.Params{
|
||||
BlockRejectNumRequired: 75,
|
||||
BlockUpgradeNumToCheck: 100,
|
||||
|
||||
// Mempool parameters
|
||||
RelayNonStdTxs: true,
|
||||
// AcceptNonStdTxs is a Mempool param to accept and relay non standard
|
||||
// txs to the network or reject them
|
||||
AcceptNonStdTxs: true,
|
||||
|
||||
// Address encoding magics
|
||||
NetworkAddressPrefix: "S",
|
||||
|
||||
@ -359,8 +359,9 @@ type Params struct {
|
||||
// The number of nodes to check.
|
||||
BlockUpgradeNumToCheck uint64
|
||||
|
||||
// Mempool parameters
|
||||
RelayNonStdTxs bool
|
||||
// AcceptNonStdTxs is a mempool param to either accept and relay
|
||||
// non standard txs to the network or reject them
|
||||
AcceptNonStdTxs bool
|
||||
|
||||
// NetworkAddressPrefix is the first letter of the network
|
||||
// for any given address encoded as a string.
|
||||
@ -626,8 +627,9 @@ var MainNetParams = Params{
|
||||
BlockRejectNumRequired: 950,
|
||||
BlockUpgradeNumToCheck: 1000,
|
||||
|
||||
// Mempool parameters
|
||||
RelayNonStdTxs: false,
|
||||
// AcceptNonStdTxs is a mempool param to either accept and relay
|
||||
// non standard txs to the network or reject them
|
||||
AcceptNonStdTxs: false,
|
||||
|
||||
// Address encoding magics
|
||||
NetworkAddressPrefix: "D",
|
||||
@ -805,8 +807,9 @@ var TestNet2Params = Params{
|
||||
BlockRejectNumRequired: 75,
|
||||
BlockUpgradeNumToCheck: 100,
|
||||
|
||||
// Mempool parameters
|
||||
RelayNonStdTxs: true,
|
||||
// AcceptNonStdTxs is a mempool param to either accept and relay
|
||||
// non standard txs to the network or reject them
|
||||
AcceptNonStdTxs: true,
|
||||
|
||||
// Address encoding magics
|
||||
NetworkAddressPrefix: "T",
|
||||
@ -999,8 +1002,9 @@ var SimNetParams = Params{
|
||||
BlockRejectNumRequired: 75,
|
||||
BlockUpgradeNumToCheck: 100,
|
||||
|
||||
// Mempool parameters
|
||||
RelayNonStdTxs: true,
|
||||
// AcceptNonStdTxs is a mempool param to either accept and relay
|
||||
// non standard txs to the network or reject them
|
||||
AcceptNonStdTxs: true,
|
||||
|
||||
// Address encoding magics
|
||||
NetworkAddressPrefix: "S",
|
||||
|
||||
16
config.go
16
config.go
@ -150,7 +150,7 @@ type config struct {
|
||||
NoMiningStateSync bool `long:"nominingstatesync" description:"Disable synchronizing the mining state with other nodes"`
|
||||
AllowOldVotes bool `long:"allowoldvotes" description:"Enable the addition of very old votes to the mempool"`
|
||||
BlocksOnly bool `long:"blocksonly" description:"Do not accept transactions from remote peers."`
|
||||
RelayNonStd bool `long:"relaynonstd" description:"Relay non-standard transactions regardless of the default settings for the active network."`
|
||||
AcceptNonStd bool `long:"acceptnonstd" description:"Accept and relay non-standard transactions to the network regardless of the default settings for the active network."`
|
||||
RejectNonStd bool `long:"rejectnonstd" description:"Reject non-standard transactions regardless of the default settings for the active network."`
|
||||
TxIndex bool `long:"txindex" description:"Maintain a full hash-based transaction index which makes all transactions available via the getrawtransaction RPC"`
|
||||
DropTxIndex bool `long:"droptxindex" description:"Deletes the hash-based transaction index from the database on start up and then exits."`
|
||||
@ -574,21 +574,21 @@ func loadConfig() (*config, []string, error) {
|
||||
// according to the default of the active network. The set
|
||||
// configuration value takes precedence over the default value for the
|
||||
// selected network.
|
||||
relayNonStd := activeNetParams.RelayNonStdTxs
|
||||
acceptNonStd := activeNetParams.AcceptNonStdTxs
|
||||
switch {
|
||||
case cfg.RelayNonStd && cfg.RejectNonStd:
|
||||
str := "%s: rejectnonstd and relaynonstd cannot be used " +
|
||||
case cfg.AcceptNonStd && cfg.RejectNonStd:
|
||||
str := "%s: rejectnonstd and acceptnonstd cannot be used " +
|
||||
"together -- choose only one"
|
||||
err := fmt.Errorf(str, funcName)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
fmt.Fprintln(os.Stderr, usageMessage)
|
||||
return nil, nil, err
|
||||
case cfg.RejectNonStd:
|
||||
relayNonStd = false
|
||||
case cfg.RelayNonStd:
|
||||
relayNonStd = true
|
||||
acceptNonStd = false
|
||||
case cfg.AcceptNonStd:
|
||||
acceptNonStd = true
|
||||
}
|
||||
cfg.RelayNonStd = relayNonStd
|
||||
cfg.AcceptNonStd = acceptNonStd
|
||||
|
||||
// Append the network type to the data directory so it is "namespaced"
|
||||
// per network. In addition to the block database, there are other
|
||||
|
||||
5
doc.go
5
doc.go
@ -121,8 +121,9 @@ Application Options:
|
||||
--sigcachemaxsize= The maximum number of entries in the signature
|
||||
verification cache.
|
||||
--blocksonly Do not accept transactions from remote peers.
|
||||
--relaynonstd Relay non-standard transactions regardless of the
|
||||
default settings for the active network.
|
||||
--acceptnonstd Accept and relay non-standard transactions to
|
||||
the network regardless of the default settings
|
||||
for the active network.
|
||||
--rejectnonstd Reject non-standard transactions regardless of the
|
||||
default settings for the active network.
|
||||
|
||||
|
||||
@ -147,11 +147,11 @@ 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 and relay non-standard
|
||||
// transactions to the network. If true, non-standard transactions
|
||||
// will be accepted into the mempool and relayed to the rest of the
|
||||
// network. 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.
|
||||
@ -830,10 +830,10 @@ func (mp *TxPool) maybeAcceptTransaction(tx *dcrutil.Tx, isNew, rateLimit, allow
|
||||
tx.SetTree(wire.TxTreeStake)
|
||||
}
|
||||
|
||||
// Don't allow non-standard transactions if the network parameters
|
||||
// forbid their relaying.
|
||||
// Don't allow non-standard transactions if the mempool config forbids
|
||||
// their acceptance and relaying.
|
||||
medianTime := mp.cfg.PastMedianTime()
|
||||
if !mp.cfg.Policy.RelayNonStd {
|
||||
if !mp.cfg.Policy.AcceptNonStd {
|
||||
err := checkTransactionStandard(tx, txType, nextBlockHeight,
|
||||
medianTime, mp.cfg.Policy.MinRelayTxFee,
|
||||
mp.cfg.Policy.MaxTxVersion)
|
||||
@ -1017,9 +1017,9 @@ func (mp *TxPool) maybeAcceptTransaction(tx *dcrutil.Tx, isNew, rateLimit, allow
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Don't allow transactions with non-standard inputs if the network
|
||||
// parameters forbid their relaying.
|
||||
if !mp.cfg.Policy.RelayNonStd {
|
||||
// Don't allow transactions with non-standard inputs if the mempool config
|
||||
// forbids their acceptance and relaying.
|
||||
if !mp.cfg.Policy.AcceptNonStd {
|
||||
err := checkInputsStandard(tx, txType, utxoView)
|
||||
if err != nil {
|
||||
// Attempt to extract a reject code from the error so
|
||||
|
||||
@ -247,8 +247,9 @@ const FileContents = `[Application Options]
|
||||
; Do not accept transactions from remote peers.
|
||||
; blocksonly=1
|
||||
|
||||
; Relay non-standard transactions regardless of default network settings.
|
||||
; relaynonstd=1
|
||||
; Accept and relay non-standard transactions to the network regardless
|
||||
default network settings.
|
||||
; acceptnonstd=1
|
||||
|
||||
; Reject non-standard transactions regardless of default network settings.
|
||||
; rejectnonstd=1
|
||||
|
||||
@ -2435,7 +2435,7 @@ func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Param
|
||||
Policy: mempool.Policy{
|
||||
MaxTxVersion: 2,
|
||||
DisableRelayPriority: cfg.NoRelayPriority,
|
||||
RelayNonStd: cfg.RelayNonStd,
|
||||
AcceptNonStd: cfg.AcceptNonStd,
|
||||
FreeTxRelayLimit: cfg.FreeTxRelayLimit,
|
||||
MaxOrphanTxs: cfg.MaxOrphanTxs,
|
||||
MaxOrphanTxSize: defaultMaxOrphanTxSize,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user