mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
Add DebugAPI to Node, fix StateDB
- Allow starting the DebugAPI from the node via config
- In StateDB:
- Make checkpoints when ProcessTxs() succeeds
- Remove extra hardcoded `statedb` path that was redundant
- Replace hardcoded `[:4]` by `[:]` when parsing idx, which failed because
idx is 6 bytes length now.
- Extra: In node, use waitgroup instead of `stoppedXXX` channels to wait for
syncrhonizer goroutines to finish.
This commit is contained in:
@@ -48,8 +48,6 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
// PathStateDB defines the subpath of the StateDB
|
||||
PathStateDB = "/statedb"
|
||||
// PathBatchNum defines the subpath of the Batch Checkpoint in the
|
||||
// subpath of the StateDB
|
||||
PathBatchNum = "/BatchNum"
|
||||
@@ -88,7 +86,7 @@ type StateDB struct {
|
||||
func NewStateDB(path string, typ TypeStateDB, nLevels int) (*StateDB, error) {
|
||||
var sto *pebble.PebbleStorage
|
||||
var err error
|
||||
sto, err = pebble.NewPebbleStorage(path+PathStateDB+PathCurrent, false)
|
||||
sto, err = pebble.NewPebbleStorage(path+PathCurrent, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -105,7 +103,7 @@ func NewStateDB(path string, typ TypeStateDB, nLevels int) (*StateDB, error) {
|
||||
}
|
||||
|
||||
sdb := &StateDB{
|
||||
path: path + PathStateDB,
|
||||
path: path,
|
||||
db: sto,
|
||||
mt: mt,
|
||||
typ: typ,
|
||||
@@ -163,6 +161,7 @@ func (s *StateDB) setCurrentBatch() error {
|
||||
func (s *StateDB) MakeCheckpoint() error {
|
||||
// advance currentBatch
|
||||
s.currentBatch++
|
||||
log.Debugw("Making StateDB checkpoint", "batch", s.currentBatch, "type", s.typ)
|
||||
|
||||
checkpointPath := s.path + PathBatchNum + strconv.Itoa(int(s.currentBatch))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user