Announcing Motoko library for a Sliding Window Buffer

We have published a new library that implements a sliding window buffer: Internet Computer Content Validation Bootstrap

It is a buffer that can dynamically grow at the end and shrink from the beginning. It provides random access to its elements by index like an array. The indices are permanent, i.e. they are not re-aligned to start at 0 again after deletion. This is why we call it a sliding window. The indices obtained by adding at the end are therefore ever-growing.

The application is to use this data structure in sliding window protocols (as in TCP). For example, it can be useful when sending a continuous stream of artefacts from one canister to another, over multiple calls, while handling situations in which some calls fail and the artefacts need to be resent. However, this library only provides a general purpose data structure. It is not an implementation of a sliding window protocol.

The current implementation internally uses two Vectors that are sometimes “rotated” to make sure the unused memory allocation does not grow indefinitely.

The library is benchmarked but not optimised to the full extent possible.

If you have requests to improve the API then please post here or in this OpenChat group.