From 99de2f83660b2345d5c53abb0abe589cd6e330d9 Mon Sep 17 00:00:00 2001 From: codchen Date: Fri, 17 Nov 2023 11:58:57 +0800 Subject: [PATCH] Expose parent on CacheKV (#352) ## Describe your changes and provide context For EVM getProof endpoint, we'd need to call functions on the underlying iavl store, so we'd need a way to expose the parent store from a cachekv ## Testing performed to validate your change --- store/cachekv/store.go | 4 ++++ store/cachekv/store_test.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/store/cachekv/store.go b/store/cachekv/store.go index 06d491d04..e4177f767 100644 --- a/store/cachekv/store.go +++ b/store/cachekv/store.go @@ -359,3 +359,7 @@ func (store *Store) isDeleted(key string) bool { _, ok := store.deleted.Load(key) return ok } + +func (store *Store) GetParent() types.KVStore { + return store.parent +} diff --git a/store/cachekv/store_test.go b/store/cachekv/store_test.go index 3a6d5ab53..65c3f4eaa 100644 --- a/store/cachekv/store_test.go +++ b/store/cachekv/store_test.go @@ -62,6 +62,9 @@ func TestCacheKVStore(t *testing.T) { st.Write() require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty") require.Empty(t, mem.Get(keyFmt(1)), "Expected `key1` to be empty") + + // GetParent returns parent store + require.NotNil(t, st.GetParent()) } func TestCacheKVStoreNoNilSet(t *testing.T) {