Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mempool: Rename RelayNonStd config option. #1024

Merged
merged 2 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions blockchain/fullblocktests/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 12 additions & 8 deletions chaincfg/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
22 changes: 11 additions & 11 deletions mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions sampleconfig/sampleconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down