#circular-buffer #time-series #store #cosmwasm #contracts #astroport #data

astroport-circular-buffer

用于在CosmWasm合约中存储时间序列数据的循环缓冲区

2个不稳定版本

0.2.0 2024年3月26日
0.1.0 2023年10月23日

#25 in #astroport

Download history 446/week @ 2024-03-13 473/week @ 2024-03-20 370/week @ 2024-03-27 377/week @ 2024-04-03 219/week @ 2024-04-10 286/week @ 2024-04-17 329/week @ 2024-04-24 495/week @ 2024-05-01 411/week @ 2024-05-08 239/week @ 2024-05-15 305/week @ 2024-05-22 402/week @ 2024-05-29 822/week @ 2024-06-05 619/week @ 2024-06-12 691/week @ 2024-06-19 709/week @ 2024-06-26

2,994 每月下载量
34 个crate中使用 (3直接使用)

Apache-2.0

15KB
286

Item 和 [Map] 上构建的循环缓冲区。可能有助于在合约中存储时间序列数据。

示例

use cosmwasm_std::testing::MockStorage;
use astroport_circular_buffer::{BufferManager, CircularBuffer};

const CIRCULAR_BUFFER: CircularBuffer<u128> = CircularBuffer::new("buffer_state", "buffer");

let mut store = MockStorage::new();
BufferManager::init(&mut store, CIRCULAR_BUFFER, 10).unwrap();
let mut buffer = BufferManager::new(&store, CIRCULAR_BUFFER).unwrap();

let data = (1..=10u128).collect::<Vec<_>>();
buffer.push_many(&data);
buffer.commit(&mut store).unwrap();

let values = buffer.read(&store, 0u32..=9, true).unwrap();
let all_values = buffer.read_all(&store).unwrap();

依赖项

~4.5–6MB
~134K SLoC