// SubscribeFromBufferEndOffset returns an observer which is initially notified of
// values in the replay buffer, starting from the replay buffer index which is
// equal to replayBufferSize - offset. After this range of the replay buffer is
// notified, the observer continues to be notified, in real-time, when the publishCh
// channel receives a value. It also returns the current replayBufferSize.
// If offset is greater than replayBufferSize or the number of elements it
// currently contains, the observer is notified of all elements in the replayBuffer,
// starting from the beginning. Passing 0 for offset is equivalent to calling
// Subscribe() on a non-replay observable.
SubscribeFromBufferEndOffset(ctx context.Context, offset int) (_ Observer[V], replayBufferSize int)
Goals
Support more explicit behavior when consuming replay observables.
Deliverables
[x] A PR which implements ReplayObservable#SubscribeFromBufferEndOffset()
647
[x] A PR which refactors RelayerSessionsManager#waitForBlock() to use it and ensure that the returned replayBufferSize is sufficient to include the pathBlock, erroring otherwise, e.g.:
648
blocksSinceClaimWindowStart := currentHeight - claimWindowStartHeight
observer, bufferLen := #SubscribeFromBufferEndOffset(ctx, blocksSinceClaimWindowStart)
if bufferlen < blocksSinceClaimWindowStart {
// query for blocks between `blocksSinceClaimWindowStart` & `replayBuffer[0]`...
}
Non-goals / Non-deliverables
...
General deliverables
[ ] Comments: Add/update TODOs and comments alongside the source code so it is easier to follow.
[ ] Testing: Add new tests (unit and/or E2E) to the test suite.
[ ] Makefile: Add new targets to the Makefile to make the new functionality easier to use.
[ ] Documentation: Update architectural or development READMEs; use mermaid diagrams where appropriate.
Objective
Explicitly support choosing how much of the replay buffer should be emitted when subscribing to the replay observable.
Origin Document
While working on #517:
Goals
Deliverables
ReplayObservable#SubscribeFromBufferEndOffset()
647
RelayerSessionsManager#waitForBlock()
to use it and ensure that the returnedreplayBufferSize
is sufficient to include thepathBlock
, erroring otherwise, e.g.:648
Non-goals / Non-deliverables
General deliverables
Creator: @bryanchriswhite Co-Owners: @red-0ne