mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
mvcc: Hash to return Revision
This commit is contained in:
parent
a8139e2b0e
commit
7a6d9ea01a
@ -70,9 +70,9 @@ type KV interface {
|
||||
// Compact frees all superseded keys with revisions less than rev.
|
||||
Compact(rev int64) (<-chan struct{}, error)
|
||||
|
||||
// Hash retrieves the hash of KV state.
|
||||
// Hash retrieves the hash of KV state and revision.
|
||||
// This method is designed for consistency checking purpose.
|
||||
Hash() (uint32, error)
|
||||
Hash() (hash uint32, revision int64, err error)
|
||||
|
||||
// Commit commits txns into the underlying backend.
|
||||
Commit()
|
||||
|
@ -620,7 +620,7 @@ func TestKVHash(t *testing.T) {
|
||||
kv := NewStore(b, &lease.FakeLessor{}, nil)
|
||||
kv.Put([]byte("foo0"), []byte("bar0"), lease.NoLease)
|
||||
kv.Put([]byte("foo1"), []byte("bar0"), lease.NoLease)
|
||||
hashes[i], err = kv.Hash()
|
||||
hashes[i], _, err = kv.Hash()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get hash: %v", err)
|
||||
}
|
||||
|
@ -293,9 +293,15 @@ func (s *store) Compact(rev int64) (<-chan struct{}, error) {
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
func (s *store) Hash() (uint32, error) {
|
||||
func (s *store) Hash() (uint32, int64, error) {
|
||||
s.b.ForceCommit()
|
||||
return s.b.Hash()
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
h, err := s.b.Hash()
|
||||
rev := s.currentRev.main
|
||||
return h, rev, err
|
||||
}
|
||||
|
||||
func (s *store) Commit() { s.b.ForceCommit() }
|
||||
|
Loading…
x
Reference in New Issue
Block a user