post-rebase fixes, make ramtrie default
This commit is contained in:
parent
d46bedf5ef
commit
a1631880be
6 changed files with 19 additions and 18 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
|
||||
"github.com/btcsuite/btcd/claimtrie/block"
|
||||
|
@ -23,7 +22,6 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// ClaimTrie implements a Merkle Trie supporting linear history of commits.
|
||||
|
@ -90,15 +88,16 @@ func New(cfg config.Config) (*ClaimTrie, error) {
|
|||
nodeManager := node.NewNormalizingManager(baseManager)
|
||||
cleanups = append(cleanups, nodeManager.Close)
|
||||
|
||||
// Initialize repository for MerkleTrie.
|
||||
// The cleanup is delegated to MerkleTrie.
|
||||
trieRepo, err := merkletrierepo.NewPebble(filepath.Join(cfg.DataDir, cfg.MerkleTrieRepoPebble.Path))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("new trie repo: %w", err)
|
||||
}
|
||||
var trie merkletrie.MerkleTrie
|
||||
if cfg.RamTrie {
|
||||
trie = merkletrie.NewRamTrie(nodeManager)
|
||||
} else {
|
||||
|
||||
trie := merkletrie.New(nodeManager, trieRepo)
|
||||
cleanups = append(cleanups, trie.Close)
|
||||
// Initialize repository for MerkleTrie. The cleanup is delegated to MerkleTrie.
|
||||
trieRepo, err := merkletrierepo.NewPebble(filepath.Join(cfg.DataDir, cfg.MerkleTrieRepoPebble.Path))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("new trie repo: %w", err)
|
||||
}
|
||||
|
||||
persistentTrie := merkletrie.NewPersistentTrie(nodeManager, trieRepo)
|
||||
cleanups = append(cleanups, persistentTrie.Close)
|
||||
|
@ -404,8 +403,9 @@ func (ct *ClaimTrie) forwardNodeChange(chg change.Change) error {
|
|||
return fmt.Errorf("node manager handle change: %w", err)
|
||||
}
|
||||
|
||||
ct.changes = append(ct.changes, chg)
|
||||
|
||||
if ct.chainRepo != nil { // for debugging only
|
||||
ct.changes = append(ct.changes, chg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ func verifyBestIndex(t *testing.T, ct *ClaimTrie, name string, idx uint32, claim
|
|||
func TestRebuild(t *testing.T) {
|
||||
r := require.New(t)
|
||||
setup(t)
|
||||
ct, err := New(true)
|
||||
ct, err := New(cfg)
|
||||
r.NoError(err)
|
||||
r.NotNil(ct)
|
||||
defer func() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/btcsuite/btcd/claimtrie/change"
|
||||
"github.com/btcsuite/btcd/claimtrie/node"
|
||||
"github.com/btcsuite/btcd/claimtrie/node/noderepo"
|
||||
|
||||
|
@ -110,7 +111,7 @@ var nodeChildrenCmd = &cobra.Command{
|
|||
Args: cobra.RangeArgs(1, 1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
repo, err := noderepo.NewPebble(localConfig.NodeRepoPebble.Path)
|
||||
repo, err := noderepo.NewPebble(filepath.Join(cfg.DataDir, cfg.NodeRepoPebble.Path))
|
||||
if err != nil {
|
||||
return fmt.Errorf("open node repo: %w", err)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
var DefaultConfig = Config{
|
||||
Record: false,
|
||||
RamTrie: false,
|
||||
RamTrie: true, // as it stands the other trie uses more RAM, more time, and 40GB+ of disk space
|
||||
|
||||
DataDir: filepath.Join(btcutil.AppDataDir("chain", false), "data", "mainnet", "claim_dbs"),
|
||||
|
||||
|
|
|
@ -274,10 +274,10 @@ func (nm *BaseManager) aWorkaroundIsNeeded(n *Node, chg change.Change) bool {
|
|||
w := isInDelayPart2(chg)
|
||||
if w {
|
||||
if !needed {
|
||||
fmt.Printf("FALSE NEGATIVE! %d: %s: %t\n", chg.Height, chg.Name, needed)
|
||||
fmt.Printf("DELAY WORKAROUND FALSE NEGATIVE! %d: %s: %t\n", chg.Height, chg.Name, needed)
|
||||
}
|
||||
} else if needed {
|
||||
fmt.Printf("FALSE POSITIVE! %d: %s: %t\n", chg.Height, chg.Name, needed)
|
||||
fmt.Printf("DELAY WORKAROUND FALSE POSITIVE! %d: %s: %t\n", chg.Height, chg.Name, needed)
|
||||
}
|
||||
// return w // if you want to sync to 933294+
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ func TestSupportAmounts(t *testing.T) {
|
|||
|
||||
r := require.New(t)
|
||||
|
||||
param.SetNetwork(wire.TestNet, "")
|
||||
param.SetNetwork(wire.TestNet)
|
||||
repo, err := noderepo.NewPebble(t.TempDir())
|
||||
r.NoError(err)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue