-
Notifications
You must be signed in to change notification settings - Fork 328
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
[factory] implement versioned stateDB to support archive mode #4520
base: master
Are you sure you want to change the base?
Conversation
sdb.daoVersioned = daoVersioned | ||
} else { | ||
sdb.dao = dao | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or we can add a new struct/file to implement statedb for archive-mode, like
struct stateDBArchive {
*stateDB
xxx
}
but after checking, that would entail duplicating almost all the codes, and in the future, any changes would need to go to 2 files. Let me know if you have good suggestion.
return nil, ErrEmptyDBPath | ||
} | ||
cfg.DbPath = dbPath | ||
return NewKVStoreWithVersion(cfg, VersionedNamespaceOption(vns...)), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix ci
state/factory/statedb.go
Outdated
@@ -111,23 +131,30 @@ func NewStateDB(cfg Config, dao db.KVStore, opts ...StateDBOption) (Factory, err | |||
return &sdb, nil | |||
} | |||
|
|||
func (sdb *stateDB) DAO(height uint64) db.KVStore { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this a public function?
state/factory/statedb.go
Outdated
if err != nil { | ||
return 0, errors.Wrap(err, "failed to get factory's height from underlying DB") | ||
} | ||
return byteutil.BytesToUint64(height), nil | ||
} | ||
|
||
func (sdb *stateDB) putHeight(h uint64) error { | ||
return sdb.DAO(h).Put(sdb.metadataNS(), []byte(CurrentHeightKey), byteutil.Uint64ToBytes(h)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getHeight from dao(0) but putHeight into dao(h) is misleading and confusing
state/factory/statedb.go
Outdated
@@ -158,24 +185,46 @@ func (sdb *stateDB) Stop(ctx context.Context) error { | |||
sdb.mutex.Lock() | |||
defer sdb.mutex.Unlock() | |||
sdb.workingsets.Clear() | |||
return sdb.dao.Stop(ctx) | |||
return sdb.DAO(0).Stop(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stop only dao(0) is also hard to read
ac0fbeb
to
1c93d4f
Compare
1c93d4f
to
b49bdc5
Compare
Quality Gate passedIssues Measures |
Description
as title.
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: