To clean up the product team's demands, here is a list of the required features:
- Save a transaction's timestamp in a list
- Access the elements quickly by index, in any order
- Iterate the items in the order they were saved
A dynamic array utilizes an expanding array underneath and works really quickly, for accessing indices directly while still supporting iteration—great for saving a numbered list of noteworthy timestamps. The direct index access provides a way to fetch the stored data without having to go through the entire list, and since transaction timestamps are basically u64 numbers (milliseconds), the data structure can be a dynamic array of multiple u64.
Other than previous lists, this time, a node only stores data and can therefore be a type alias as well:
type Node = Option<u64>;
Making the node an Option type is necessary, since the capacity and actual length of the internal slice may differ—which means that an "empty...