Skip to content

Commit

Permalink
Merge PR: watchdb mv deleteAccount (#1575)
Browse files Browse the repository at this point in the history
* replay add fast-query

* DeleteAccount

* ut

Co-authored-by: xiangjianmeng <805442788@qq.com>
  • Loading branch information
chengzhinei and xiangjianmeng authored Feb 22, 2022
1 parent b5c21eb commit f7c2235
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmd/exchaind/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func replayCmd(ctx *server.Context) *cobra.Command {
cmd.Flags().Int(types.FlagRedisExpire, 300, "delta expiration time. unit is second")
cmd.Flags().Int(types.FlagRedisDB, 0, "delta db num")
cmd.Flags().Int(types.FlagDeltaVersion, types.DeltaVersion, "Specify delta version")
cmd.Flags().Bool(types.FlagFastQuery, false, "enable watch db or not")

cmd.Flags().String(server.FlagPruning, storetypes.PruningOptionNothing, "Pruning strategy (default|nothing|everything|custom)")
cmd.Flags().Uint64(server.FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node")
Expand Down
7 changes: 4 additions & 3 deletions x/evm/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,10 @@ func (w *Watcher) DeleteAccount(addr sdk.AccAddress) {
if !w.Enabled() {
return
}
w.store.Delete(GetMsgAccountKey(addr.Bytes()))
key := append(prefixRpcDb, GetMsgAccountKey(addr.Bytes())...)
w.delayEraseKey = append(w.delayEraseKey, key)
key1 := GetMsgAccountKey(addr.Bytes())
key2 := append(prefixRpcDb, key1...)
w.delayEraseKey = append(w.delayEraseKey, key1)
w.delayEraseKey = append(w.delayEraseKey, key2)
}

func (w *Watcher) AddDirtyAccount(addr *sdk.AccAddress) {
Expand Down
4 changes: 2 additions & 2 deletions x/evm/watcher/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ func testWatchData(t *testing.T, w *WatcherTestSt) {
wd, err := wdFunc()
require.Nil(t, err)
require.NotEmpty(t, wd)
err = delDirtyAccount(wd, w)
require.Nil(t, err)
w.app.EvmKeeper.Watcher.ExecuteDelayEraseKey()

store := watcher.InstanceOfWatchStore()
pWd := getDBKV(store)
Expand All @@ -134,6 +133,7 @@ func testWatchData(t *testing.T, w *WatcherTestSt) {
wData, err := w.app.EvmKeeper.Watcher.UnmarshalWatchData(wd)
require.Nil(t, err)
w.app.EvmKeeper.Watcher.UseWatchData(wData)
w.app.EvmKeeper.Watcher.ExecuteDelayEraseKey()
time.Sleep(time.Second * 1)

cWd := getDBKV(store)
Expand Down

0 comments on commit f7c2235

Please sign in to comment.