diff --git a/blockchain/fullblocktests/params.go b/blockchain/fullblocktests/params.go index cbb87a97..2d76954b 100644 --- a/blockchain/fullblocktests/params.go +++ b/blockchain/fullblocktests/params.go @@ -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", diff --git a/chaincfg/params.go b/chaincfg/params.go index 9a3f8982..1bdfb53b 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -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", diff --git a/config.go b/config.go index 92123723..3dd6d36f 100644 --- a/config.go +++ b/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 diff --git a/doc.go b/doc.go index cf6b2c7b..10e358a2 100644 --- a/doc.go +++ b/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. diff --git a/mempool/mempool.go b/mempool/mempool.go index ee90de24..e7d549f8 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -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 diff --git a/sampleconfig/sampleconfig.go b/sampleconfig/sampleconfig.go index fa68370d..1da406a3 100644 --- a/sampleconfig/sampleconfig.go +++ b/sampleconfig/sampleconfig.go @@ -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 diff --git a/server.go b/server.go index 774e1300..fd18307d 100644 --- a/server.go +++ b/server.go @@ -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,