Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init: fast query DB #229

Closed
wants to merge 18 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip: fast query service
emidev98 committed Dec 19, 2023
commit b27da2d7b818d8fb27e878691320774707261599
24 changes: 9 additions & 15 deletions app/fast_query/fast_query_service.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fast_query

import (
"fmt"

log "github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/store/types"
"github.com/terra-money/core/v2/app/fast_query/db/driver"
@@ -38,8 +40,6 @@ func NewFastQueryService(homedir string, logger log.Logger, storeKeys map[string
return nil, err
}

// store.LoadLatestVersion()

return &FastQueryService{
Store: store,
safeBatchDBCloser: safeBatchDBCloser,
@@ -54,18 +54,12 @@ func (fqs *FastQueryService) CommitChanges(blockHeight int64, changeSet []types.
fqs.fastQueryDb.SetWriteHeight(blockHeight)
fqs.safeBatchDBCloser.Open()

for _, kv := range changeSet {
key := fqs.Store.StoreKeysByName()[kv.StoreKey]
ckvs := fqs.Store.GetCommitKVStore(key)
if kv.Delete {
ckvs.Delete(kv.Key)
} else {
ckvs.Set(kv.Key, kv.Value)
}
}

if _, err := fqs.safeBatchDBCloser.Flush(); err != nil {
return err
}
lastCommitId := fqs.Store.Commit()
fmt.Print("FQS last_block_height ", lastCommitId.Version)
// if rollback, err := fqs.safeBatchDBCloser.Flush(); err != nil {
// return err
// } else if rollback != nil {
// rollback.Close()
// }
return nil
}