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

Fast Cache Migration #9

Merged
merged 9 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/confio/ics23/go v0.6.6
github.com/gogo/gateway v1.1.0
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.2
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down
17 changes: 13 additions & 4 deletions immutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func (t *ImmutableTree) Version() int64 {
return t.version
}

// IsLatestVersion returns true if curren tree is of the latest version, false otherwise.
func (t *ImmutableTree) IsLatestVersion() bool {
// IsLatestTreeVersion returns true if curren tree is of the latest version, false otherwise.
func (t *ImmutableTree) IsLatestTreeVersion() bool {
return t.version == t.ndb.getLatestVersion()
}

Expand Down Expand Up @@ -236,8 +236,7 @@ func (t *ImmutableTree) Iterate(fn func(key []byte, value []byte) bool) bool {

// Iterator returns an iterator over the immutable tree.
func (t *ImmutableTree) Iterator(start, end []byte, ascending bool) dbm.Iterator {
isFastTraversal := t.IsLatestVersion()
if isFastTraversal {
if t.IsFastCacheEnabled() {
return NewFastIterator(start, end, ascending, t.ndb)
} else {
return NewIterator(start, end, ascending, t)
Expand All @@ -259,6 +258,16 @@ func (t *ImmutableTree) IterateRange(start, end []byte, ascending bool, fn func(
})
}

// GetStorageVersion returns the version of the underlying storage.
func (t *ImmutableTree) GetStorageVersion() (string) {
return t.ndb.getStorageVersion()
}

// IsFastCacheEnabled returns true if fast storage is enabled, false otherwise.
func (t *ImmutableTree) IsFastCacheEnabled() bool {
return t.IsLatestTreeVersion() && t.ndb.isFastStorageEnabled()
}

// IterateRangeInclusive makes a callback for all nodes with key between start and end inclusive.
// If either are nil, then it is open on that side (nil, nil is the same as Iterate). The keys and
// values must not be modified, since they may point to data stored within IAVL.
Expand Down
Loading