neo-project / neo-modules

MIT License
60 stars 100 forks source link

ISnapshot Interface TryGet functionally on LevelDB #806

Closed cschuchardt88 closed 1 year ago

cschuchardt88 commented 1 year ago

Can anyone tell why ISnapshot Interface on method TryGet doesn't get the data from snapshot? Why does it get the Data from IStore Interface. This is for leveldb storage.

https://github.com/neo-project/neo-modules/blob/99ffc846e4df93491d1d812cb4c6ef6ee875e056/src/LevelDBStore/Plugins/Storage/Snapshot.cs#L65

shargon commented 1 year ago

https://github.com/neo-project/neo-modules/blob/99ffc846e4df93491d1d812cb4c6ef6ee875e056/src/LevelDBStore/Plugins/Storage/Snapshot.cs#L29

Options set the snapshot, so get use the snapshot

cschuchardt88 commented 1 year ago

@shargon Thank You for your time. Second question Im using bare ISnapshot interface like this

        public void StartBatch()
        {
            _snapshot?.Dispose();
            _snapshot = _store.GetSnapshot();
        }
_store = NeoSystem.LoadStore(@"C:\Temp\UT_HelloWorld");

But the snapshot is private, no way to access it? Is there a better way of getting what was written to the snapshot?

I want to be able to do

_snapshot.TryGet(new byte[1]);

and get that key's value from snapshot when i insert the data to snapshot before committing to store.

if there is no solution, i guess i could just cache the data in my class before writing it to the store.

cschuchardt88 commented 1 year ago

Ill just cache before committing