loadInBlock tries to load an entity from some kind of a cache that persists for the time a specific block is being indexed. The entity will be present in the cache only if it was created or updated in that block.
For example event A occurs in block 123, in our handler we create an entity B with ID the address (0x0...1) of the emitter contract C. Later in that block another event A is emitted by contract C. If we try to load the entity using B.loadInBlock("0x0...1") we should get the entity we have created during the first occurrence of the event A.
But if in block 124, contract C has once again emitted event A and we try to load the entity using B.loadInBlock("0x0...1"), the function will return null because the entity is no more in the cache and instead we should try to load it from the database.
Matchstick implementation:
My proposed solution would be to:
Have the default loadInBlock behaviour to return null
Add a mock cashe store
Add a function that mocks the entity in the cache store with user defined
loadInBlock
Description:
loadInBlock
tries to load an entity from some kind of a cache that persists for the time a specific block is being indexed. The entity will be present in the cache only if it was created or updated in that block.For example event
A
occurs in block 123, in our handler we create an entityB
with ID the address (0x0...1) of the emitter contractC
. Later in that block another eventA
is emitted by contractC
. If we try to load the entity usingB.loadInBlock("0x0...1")
we should get the entity we have created during the first occurrence of the eventA
.But if in block 124, contract
C
has once again emitted eventA
and we try to load the entity usingB.loadInBlock("0x0...1")
, the function will returnnull
because the entity is no more in the cache and instead we should try to load it from the database.Matchstick implementation:
My proposed solution would be to:
loadInBlock
behaviour to returnnull