Skip to content

adpthegreat/Stores-and-Deltas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

this repo contains a near canonical implementation of the stores and deltas in the substreams pipeline

in the stores we are simply using a HashMap<String, Vec<(u64, Vec<u8>)>> to map key value pairs and for the deltas we are

using ___________

Closing Remarks

In the substreams pacakge looking at them implementing all the StoreSet and StoreGet traits individually looked repititive and verbose, so i decided to use macros to reduce the amound of code, but this involves checking the type passed in and serializing and deserializing byte arrays Vec<u8> to their right form , maybe eliminating this step was the tradeoff for verbosity that substreams devs gladly took , because if they followed this approach they would be doing that twice - serializing and deserializing at the macro trait generation level and then doing byte conversion and memory allocation at the state level, then the wasmbindings executed , anyways its still a fun experiment which can surely be improved

https://docs.substreams.dev/reference-material/substreams-components/modules/keys-in-stores

Milestones

Phantom data suggestions when you create generic type for struct but dont use it 
error[E0063]: missing field `phantom` in initializer of `MockProtoStore<{type error}>`
   --> src/mock_store/store.rs:282:9
    |
282 |         Self { data: Rc::new(RefCell::new(HashMap::new())) }
    |         ^^^^ missing `phantom`

error[E0063]: missing field `phantom` in initializer of `MockProtoStore<T>`
   --> src/mock_store/store.rs:298:9
    |
298 |         Self { data: Rc::new(RefCell::new(HashMap::new())) }
    |         ^^^^ missing `phantom
Wanted to use just Cursor in the `StoreGetArray` like the canonical implementation, but its unstable and i need nightly lol 
https://github.com/rust-lang/rust/issues/86369

About

A canonical implementation of the substream stores and deltas for mock testing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages