mirror of
https://github.com/btcsuite/btcd.git
synced 2025-02-23 06:35:20 +01:00
main: Add prune flag
This change is part of the effort to add pruning support to btcd. Pruning is now available to the end user via --prune flag. There are checks in place so that the user doesn't go below the minimum prune target of 1536 MiB. The minimum is set so that we keep at least 288 blocks per the requirement for NODE_NETWORK_LIMITED nodes specified by BIP0159. The default value of 0 will disable pruning.
This commit is contained in:
parent
0212c334ce
commit
02469e16a6
2 changed files with 14 additions and 0 deletions
10
config.go
10
config.go
|
@ -66,6 +66,7 @@ const (
|
|||
sampleConfigFilename = "sample-btcd.conf"
|
||||
defaultTxIndex = false
|
||||
defaultAddrIndex = false
|
||||
pruneMinSize = 1536
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -146,6 +147,7 @@ type config struct {
|
|||
Proxy string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"`
|
||||
ProxyPass string `long:"proxypass" default-mask:"-" description:"Password for proxy server"`
|
||||
ProxyUser string `long:"proxyuser" description:"Username for proxy server"`
|
||||
Prune uint64 `long:"prune" description:"Prune already validated blocks from the database. Must specify a target size in MiB (minimum value of 1536, default value of 0 will disable pruning)"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
RejectNonStd bool `long:"rejectnonstd" description:"Reject non-standard transactions regardless of the default settings for the active network."`
|
||||
RejectReplacement bool `long:"rejectreplacement" description:"Reject transactions that attempt to replace existing transactions within the mempool through the Replace-By-Fee (RBF) signaling policy."`
|
||||
|
@ -1137,6 +1139,14 @@ func loadConfig() (*config, []string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if cfg.Prune != 0 && cfg.Prune < pruneMinSize {
|
||||
err := fmt.Errorf("%s: the minimum value for --prune is %d. Got %d",
|
||||
funcName, pruneMinSize, cfg.Prune)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
fmt.Fprintln(os.Stderr, usageMessage)
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Warn about missing config file only after all other configuration is
|
||||
// done. This prevents the warning on help messages and invalid
|
||||
// options. Note this should go directly before the return.
|
||||
|
|
|
@ -2730,6 +2730,9 @@ func newServer(listenAddrs, agentBlacklist, agentWhitelist []string,
|
|||
if cfg.NoCFilters {
|
||||
services &^= wire.SFNodeCF
|
||||
}
|
||||
if cfg.Prune != 0 {
|
||||
services &^= wire.SFNodeNetwork
|
||||
}
|
||||
|
||||
amgr := addrmgr.New(cfg.DataDir, btcdLookup)
|
||||
|
||||
|
@ -2831,6 +2834,7 @@ func newServer(listenAddrs, agentBlacklist, agentWhitelist []string,
|
|||
SigCache: s.sigCache,
|
||||
IndexManager: indexManager,
|
||||
HashCache: s.hashCache,
|
||||
Prune: cfg.Prune * 1024 * 1024,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Reference in a new issue