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"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/claimtrie/block"
|
"github.com/btcsuite/btcd/claimtrie/block"
|
||||||
|
@ -23,7 +22,6 @@ import (
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"sort"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ClaimTrie implements a Merkle Trie supporting linear history of commits.
|
// ClaimTrie implements a Merkle Trie supporting linear history of commits.
|
||||||
|
@ -90,16 +88,17 @@ func New(cfg config.Config) (*ClaimTrie, error) {
|
||||||
nodeManager := node.NewNormalizingManager(baseManager)
|
nodeManager := node.NewNormalizingManager(baseManager)
|
||||||
cleanups = append(cleanups, nodeManager.Close)
|
cleanups = append(cleanups, nodeManager.Close)
|
||||||
|
|
||||||
// Initialize repository for MerkleTrie.
|
var trie merkletrie.MerkleTrie
|
||||||
// The cleanup is delegated to MerkleTrie.
|
if cfg.RamTrie {
|
||||||
|
trie = merkletrie.NewRamTrie(nodeManager)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// Initialize repository for MerkleTrie. The cleanup is delegated to MerkleTrie.
|
||||||
trieRepo, err := merkletrierepo.NewPebble(filepath.Join(cfg.DataDir, cfg.MerkleTrieRepoPebble.Path))
|
trieRepo, err := merkletrierepo.NewPebble(filepath.Join(cfg.DataDir, cfg.MerkleTrieRepoPebble.Path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("new trie repo: %w", err)
|
return nil, fmt.Errorf("new trie repo: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
trie := merkletrie.New(nodeManager, trieRepo)
|
|
||||||
cleanups = append(cleanups, trie.Close)
|
|
||||||
|
|
||||||
persistentTrie := merkletrie.NewPersistentTrie(nodeManager, trieRepo)
|
persistentTrie := merkletrie.NewPersistentTrie(nodeManager, trieRepo)
|
||||||
cleanups = append(cleanups, persistentTrie.Close)
|
cleanups = append(cleanups, persistentTrie.Close)
|
||||||
trie = persistentTrie
|
trie = persistentTrie
|
||||||
|
@ -404,8 +403,9 @@ func (ct *ClaimTrie) forwardNodeChange(chg change.Change) error {
|
||||||
return fmt.Errorf("node manager handle change: %w", err)
|
return fmt.Errorf("node manager handle change: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ct.chainRepo != nil { // for debugging only
|
||||||
ct.changes = append(ct.changes, chg)
|
ct.changes = append(ct.changes, chg)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ func verifyBestIndex(t *testing.T, ct *ClaimTrie, name string, idx uint32, claim
|
||||||
func TestRebuild(t *testing.T) {
|
func TestRebuild(t *testing.T) {
|
||||||
r := require.New(t)
|
r := require.New(t)
|
||||||
setup(t)
|
setup(t)
|
||||||
ct, err := New(true)
|
ct, err := New(cfg)
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
r.NotNil(ct)
|
r.NotNil(ct)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/claimtrie/change"
|
||||||
"github.com/btcsuite/btcd/claimtrie/node"
|
"github.com/btcsuite/btcd/claimtrie/node"
|
||||||
"github.com/btcsuite/btcd/claimtrie/node/noderepo"
|
"github.com/btcsuite/btcd/claimtrie/node/noderepo"
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ var nodeChildrenCmd = &cobra.Command{
|
||||||
Args: cobra.RangeArgs(1, 1),
|
Args: cobra.RangeArgs(1, 1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("open node repo: %w", err)
|
return fmt.Errorf("open node repo: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
var DefaultConfig = Config{
|
var DefaultConfig = Config{
|
||||||
Record: false,
|
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"),
|
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)
|
w := isInDelayPart2(chg)
|
||||||
if w {
|
if w {
|
||||||
if !needed {
|
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 {
|
} 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+
|
// return w // if you want to sync to 933294+
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ func TestSupportAmounts(t *testing.T) {
|
||||||
|
|
||||||
r := require.New(t)
|
r := require.New(t)
|
||||||
|
|
||||||
param.SetNetwork(wire.TestNet, "")
|
param.SetNetwork(wire.TestNet)
|
||||||
repo, err := noderepo.NewPebble(t.TempDir())
|
repo, err := noderepo.NewPebble(t.TempDir())
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue