use freezer db
This commit is contained in:
parent
b8a0923250
commit
5ed3e92469
@ -60,9 +60,11 @@ func stateSnapshot() {
|
||||
func init() {
|
||||
rootCmd.AddCommand(stateSnapshotCmd)
|
||||
|
||||
stateSnapshotCmd.PersistentFlags().String("leveldb-path", "", "path to leveldb")
|
||||
stateSnapshotCmd.PersistentFlags().String("leveldb-path", "", "path to primary datastore")
|
||||
stateSnapshotCmd.PersistentFlags().String("ancient-path", "", "path to ancient datastore")
|
||||
stateSnapshotCmd.PersistentFlags().String("block-height", "", "blockheight to extract state at")
|
||||
|
||||
viper.BindPFlag("leveldb.path", stateSnapshotCmd.PersistentFlags().Lookup("leveldb-path"))
|
||||
viper.BindPFlag("leveldb.ancient", stateSnapshotCmd.PersistentFlags().Lookup("ancient-path"))
|
||||
viper.BindPFlag("snapshot.blockHeight", stateSnapshotCmd.PersistentFlags().Lookup("block-height"))
|
||||
}
|
||||
|
@ -23,17 +23,19 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
LVL_DB_PATH = "LVL_DB_PATH"
|
||||
ETH_NODE_ID = "ETH_NODE_ID"
|
||||
ANCIENT_DB_PATH = "ANCIENT_DB_PATH"
|
||||
ETH_CLIENT_NAME = "ETH_CLIENT_NAME"
|
||||
ETH_GENESIS_BLOCK = "ETH_GENESIS_BLOCK"
|
||||
ETH_NETWORK_ID = "ETH_NETWORK_ID"
|
||||
ETH_NODE_ID = "ETH_NODE_ID"
|
||||
LVL_DB_PATH = "LVL_DB_PATH"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
LevelDBPath string
|
||||
Node core.Node
|
||||
DBConfig config.Database
|
||||
LevelDBPath string
|
||||
AncientDBPath string
|
||||
Node core.Node
|
||||
DBConfig config.Database
|
||||
}
|
||||
|
||||
func (c *Config) Init() {
|
||||
@ -43,6 +45,7 @@ func (c *Config) Init() {
|
||||
viper.BindEnv("ethereum.clientName", ETH_CLIENT_NAME)
|
||||
viper.BindEnv("ethereum.genesisBlock", ETH_GENESIS_BLOCK)
|
||||
viper.BindEnv("ethereum.networkID", ETH_NETWORK_ID)
|
||||
viper.BindEnv("leveldb.ancient", ANCIENT_DB_PATH)
|
||||
|
||||
c.Node = core.Node{
|
||||
ID: viper.GetString("ethereum.nodeID"),
|
||||
@ -51,4 +54,5 @@ func (c *Config) Init() {
|
||||
NetworkID: viper.GetString("ethereum.networkID"),
|
||||
}
|
||||
c.LevelDBPath = viper.GetString("leveldb.path")
|
||||
c.AncientDBPath = viper.GetString("leveldb.ancient")
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func NewSnapshotService(con Config) (*Service, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
edb, err := rawdb.NewLevelDBDatabase(con.LevelDBPath, 256, 1024, "eth-pg-ipfs-state-snapshot")
|
||||
edb, err := rawdb.NewLevelDBDatabaseWithFreezer(con.LevelDBPath, 1024, 256, con.AncientDBPath, "eth-pg-ipfs-state-snapshot")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -173,7 +173,7 @@ func (s *Service) createSnapshot(it trie.NodeIterator, trieDB *trie.Database, he
|
||||
return errors.New("unexpected node type")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return it.Error()
|
||||
}
|
||||
|
||||
func (s *Service) storageSnapshot(sr common.Hash, stateID int64) error {
|
||||
@ -228,5 +228,5 @@ func (s *Service) storageSnapshot(sr common.Hash, stateID int64) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return it.Error()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user