Skip to content

Commit

Permalink
Merge pull request #133 from kcalvinalvin/2024-02-04-make-prune-default
Browse files Browse the repository at this point in the history
main, integration: making pruning the default
  • Loading branch information
kcalvinalvin authored Feb 4, 2024
2 parents 426098b + 41ca508 commit d40e352
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
18 changes: 7 additions & 11 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type config struct {
UtxoCacheMaxSizeMiB uint `long:"utxocachemaxsize" description:"The maximum size in MiB of the UTXO cache"`
NoUtreexo bool `long:"noutreexo" description:"Disable utreexo compact state during block validation"`
NoWinService bool `long:"nowinservice" description:"Do not start as a background service on Windows -- NOTE: This flag only works on the command line, not in the config file"`
Prune uint64 `long:"prune" description:"Prune already validated blocks from the database. Must specify a target size in MiB (minimum value of 550, default of 0 to disable pruning)"`
Prune uint64 `long:"prune" description:"Prune already validated blocks from the database. Must specify a target size in MiB (minimum value of 550, default of 550. Set to 0 to disable pruning.)"`

// Profiling options.
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
Expand Down Expand Up @@ -494,6 +494,7 @@ func loadConfig() (*config, []string, error) {
TxIndex: defaultTxIndex,
TTLIndex: defaultTTLIndex,
AddrIndex: defaultAddrIndex,
Prune: pruneMinSize,
}

// Service options which are only added on Windows.
Expand Down Expand Up @@ -1208,13 +1209,8 @@ func loadConfig() (*config, []string, error) {
cfg.NoUtreexo = true
}

// Set --prune=550 if the node is a utreexo node.
if !cfg.NoUtreexo {
if cfg.Prune == 0 {
cfg.Prune = pruneMinSize
}
} else {
// Set --noassumeutreexo if the node is not a utreexo node.
// Set --noassumeutreexo if the node is not a utreexo node.
if cfg.NoUtreexo {
cfg.NoAssumeUtreexo = true
}

Expand Down Expand Up @@ -1304,23 +1300,23 @@ func loadConfig() (*config, []string, error) {

if cfg.Prune != 0 && cfg.TxIndex {
err := fmt.Errorf("%s: the --prune and --txindex options may "+
"not be activated at the same time", funcName)
"not be activated at the same time. Set --prune=0 to disable pruning.", funcName)
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr, usageMessage)
return nil, nil, err
}

if cfg.Prune != 0 && cfg.AddrIndex {
err := fmt.Errorf("%s: the --prune and --addrindex options may "+
"not be activated at the same time", funcName)
"not be activated at the same time. Set --prune=0 to disable pruning.", funcName)
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr, usageMessage)
return nil, nil, err
}

if cfg.Prune != 0 && cfg.TTLIndex {
err := fmt.Errorf("%s: the --prune and --ttlindex options may "+
"not be activated at the same time", funcName)
"not be activated at the same time. Set --prune=0 to disable pruning.", funcName)
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr, usageMessage)
return nil, nil, err
Expand Down
2 changes: 2 additions & 0 deletions integration/getutreexoroots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestGetUtreexoRoots(t *testing.T) {
"--utreexoproofindex",
"--noutreexo",
"--nobdkwallet",
"--prune=0",
}
utreexoProofNode, err := rpctest.New(&chaincfg.RegressionNetParams, nil, utreexoProofIdxArgs, "")
if err != nil {
Expand All @@ -79,6 +80,7 @@ func TestGetUtreexoRoots(t *testing.T) {
"--flatutreexoproofindex",
"--noutreexo",
"--nobdkwallet",
"--prune=0",
}
flatUtreexoProofNode, err := rpctest.New(&chaincfg.RegressionNetParams, nil, flatUtreexoProofIdxArgs, "")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion integration/invalidate_reconsider_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestInvalidateAndReconsiderBlock(t *testing.T) {
// Set up regtest chain.
r, err := rpctest.New(&chaincfg.RegressionNetParams, nil, []string{"--flatutreexoproofindex", "--utreexoproofindex", "--nobdkwallet"}, "")
r, err := rpctest.New(&chaincfg.RegressionNetParams, nil, []string{"--flatutreexoproofindex", "--utreexoproofindex", "--nobdkwallet", "--prune=0"}, "")
if err != nil {
t.Fatalf("TestInvalidateAndReconsiderBlock fail. Unable to create primary harness: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions integration/utreexocompactstatenode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func TestUtreexoCSN(t *testing.T) {
"--flatutreexoproofindex",
"--noutreexo",
"--nobdkwallet",
"--prune=0",
}
// Set up regtest chain for the bridge node.
bridgeNode, err := rpctest.New(&chaincfg.RegressionNetParams, nil, bridgeNodeArgs, "")
Expand Down

0 comments on commit d40e352

Please sign in to comment.