Add state sync support (#7166)
* Add state sync support * fix incorrect test tempdir * proto: move and update Protobuf schemas * proto: lint fixes * comment tweaks * don't use type aliasing * don't call .Error() when logging errors * use create terminology instead of take for snapshots * reuse chunk hasher * simplify key encoding code * track chunk index in Manager * add restoreDone message for Manager * add a ready channel to Snapshotter.Restore() * add comment on streaming IO API * use sdkerrors for error handling * fix incorrect error * tweak changelog * syntax fix * update test code after merge
This commit is contained in:
@@ -4,9 +4,11 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/snapshots"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -173,6 +175,16 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
|
||||
panic(err)
|
||||
}
|
||||
|
||||
snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots")
|
||||
snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return simapp.NewSimApp(
|
||||
logger, db, traceStore, true, skipUpgradeHeights,
|
||||
cast.ToString(appOpts.Get(flags.FlagHome)),
|
||||
@@ -185,6 +197,9 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
|
||||
baseapp.SetInterBlockCache(cache),
|
||||
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
|
||||
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
|
||||
baseapp.SetSnapshotStore(snapshotStore),
|
||||
baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))),
|
||||
baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user