pokt-network / poktroll

The official Shannon upgrade implementation of the Pocket Network Protocol implemented using Rollkit.dev
MIT License
15 stars 6 forks source link

[Relayminer] Add `ReplayObservable#SubscribeFromBufferEndOffset()` method #553

Open bryanchriswhite opened 1 month ago

bryanchriswhite commented 1 month ago

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:

image

See: https://github.com/pokt-network/poktroll/pull/546#discussion_r1612053839.

    // 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

Deliverables

Non-goals / Non-deliverables

General deliverables


Creator: @bryanchriswhite Co-Owners: @red-0ne