[DEV-325] Add SubNetwork command-line and config flag (#135)

* [DEV-325] Added subnetwork cmd/config flag

* [DEV-325] Fixed subnetwork comments
This commit is contained in:
Evgeny Khirin 2018-12-30 11:25:43 +02:00 committed by stasatdaglabs
parent 4a6fd8fad1
commit 6d035fce29
2 changed files with 19 additions and 0 deletions

View File

@ -165,6 +165,7 @@ type configFlags struct {
DropAddrIndex bool `long:"dropaddrindex" description:"Deletes the address-based transaction index from the database on start up and then exits."` 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."` 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."` RejectNonStd bool `long:"rejectnonstd" description:"Reject non-standard transactions regardless of the default settings for the active network."`
SubNetwork uint64 `long:"subnetwork" description:"If subnetwork > 0, than node will request and process only payloads from specified subnetwork. And if subnetwork is 0, than payloads of all subnetworks are processed."`
} }
// Config defines the configuration options for btcd. // Config defines the configuration options for btcd.
@ -750,6 +751,15 @@ func loadConfig() (*Config, []string, error) {
cfg.MiningAddrs = append(cfg.MiningAddrs, addr) cfg.MiningAddrs = append(cfg.MiningAddrs, addr)
} }
// Check that 'generate' and 'subnetwork' flags do not conflict
if cfg.Generate && cfg.SubNetwork != 0 {
str := "%s: both generate flag and subnetwork filtering are set "
err := fmt.Errorf(str, funcName)
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr, usageMessage)
return nil, nil, err
}
// Ensure there is at least one mining address when the generate flag is // Ensure there is at least one mining address when the generate flag is
// set. // set.
if cfg.Generate && len(cfg.MiningAddrs) == 0 { if cfg.Generate && len(cfg.MiningAddrs) == 0 {

View File

@ -343,3 +343,12 @@
; be disabled if this option is not specified. The profile information can be ; be disabled if this option is not specified. The profile information can be
; accessed at http://localhost:<profileport>/debug/pprof once running. ; accessed at http://localhost:<profileport>/debug/pprof once running.
; profile=6061 ; profile=6061
; ------------------------------------------------------------------------------
; Subnetworks
; ------------------------------------------------------------------------------
; If subnetwork > 0, than node will request and process only payloads from
; specified subnetwork. And if subnetwork is 0, than payloads of all subnetworks
; are processed. It also requires that generate flag will be false.
; subnetwork=0