mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 01:40:07 +01:00
config: introduce new flags to accept/reject non-std transactions
This commit adds two new cli flags: one for accepting non-std transactions, and the other for rejecting non-std transactions. The two flag are rejected when using concurrently. Config parsing is set up such that, the desired policy expressed via the config always overrides the policy set by default for a particular chain. The doc.go files and the sample-btcd.conf file have been updated to document the new flags exposing further policy control.
This commit is contained in:
parent
dc5486a579
commit
815ded348e
22
config.go
22
config.go
@ -141,6 +141,8 @@ type config struct {
|
||||
DropTxIndex bool `long:"droptxindex" description:"Deletes the hash-based transaction index from the database on start up and then exits."`
|
||||
AddrIndex bool `long:"addrindex" description:"Maintain a full address-based transaction index which makes the searchrawtransactions RPC available"`
|
||||
DropAddrIndex bool `long:"dropaddrindex" description:"Deletes the address-based transaction index from the database on start up and then exits."`
|
||||
RelayNonStd bool `long:"relaynonstd" description:"Relay non-standard transactions 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."`
|
||||
onionlookup func(string) ([]net.IP, error)
|
||||
lookup func(string) ([]net.IP, error)
|
||||
oniondial func(string, string) (net.Conn, error)
|
||||
@ -479,6 +481,26 @@ func loadConfig() (*config, []string, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Set the default policy for relaying non-standard transactions
|
||||
// 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
|
||||
switch {
|
||||
case cfg.RelayNonStd && cfg.RejectNonStd:
|
||||
str := "%s: rejectnonstd and relaynonstd 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
|
||||
}
|
||||
cfg.RelayNonStd = relayNonStd
|
||||
|
||||
// Append the network type to the data directory so it is "namespaced"
|
||||
// per network. In addition to the block database, there are other
|
||||
// pieces of data that are saved to disk such as address manager state.
|
||||
|
4
doc.go
4
doc.go
@ -108,6 +108,10 @@ 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.
|
||||
--rejectnonstd Reject non-standard transactions regardless of the
|
||||
default settings for the active network.
|
||||
|
||||
Help Options:
|
||||
-h, --help Show this help message
|
||||
|
@ -238,6 +238,12 @@
|
||||
; Do not accept transactions from remote peers.
|
||||
; blocksonly=1
|
||||
|
||||
; Relay non-standard transactions regardless of default network settings.
|
||||
; relaynonstd=1
|
||||
|
||||
; Reject non-standard transactions regardless of default network settings.
|
||||
; rejectnonstd=1
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; Optional Transaction Indexes
|
||||
|
@ -2519,7 +2519,7 @@ func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Param
|
||||
txC := mempool.Config{
|
||||
Policy: mempool.Policy{
|
||||
DisableRelayPriority: cfg.NoRelayPriority,
|
||||
RelayNonStd: chainParams.RelayNonStdTxs,
|
||||
RelayNonStd: cfg.RelayNonStd,
|
||||
FreeTxRelayLimit: cfg.FreeTxRelayLimit,
|
||||
MaxOrphanTxs: cfg.MaxOrphanTxs,
|
||||
MaxOrphanTxSize: defaultMaxOrphanTxSize,
|
||||
|
Loading…
Reference in New Issue
Block a user