fix(events): handle subscribe and get/fill cases separately #12586
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After reviewing #12585 I realised the remaining problem was this:
But we only have one "excludeReverted" argument to
Install()
. My first go at this was changing that argument tosubscribe
and using that to differentiate the behaviour and doing thetipsetKeyCid == cid.Undef
check just forprefillFilter
. But then I realised that for the non-subscribe calls we only ever install+remove the filter immediately, so the logic is kind of unnecessary if we just introduce a second method to deal with that case.So now we have a
Fill()
in addition to anInstall()
, with the former not installing the filter, it just fills it if there's anything to fill and applies thetipsetKeyCid == cid.Undef
directly itself. ThenInstall()
can useFill()
for its historic stuff and then install the filter and ignore the reversion exclusion entirely because you always want those reverts in that case.eth_subscribe
can't get historic events, so it doesn't touchprefillFilter
SubscribeActorEventsRaw()
can get historic events, but you can also specify a tipset (!) which is kind of silly, but perhaps you want to subscribe to the next tipset, which you have, but there aren't events for it yet .. that should work now, including reversions of it.eth_newFilter
is the interesting case because it's a hybrid API that can be used a bit likeeth_subscribe
but for polling, but it can also be used for just getting historic events likeeth_getLogs
so it needs this dual functionality supplied byInstall()
.