From 9f29af8e14fa39d36973bdeadb7f58a1da69e655 Mon Sep 17 00:00:00 2001 From: ardocrat Date: Sun, 17 May 2026 13:43:27 +0300 Subject: [PATCH] store: bring back old key methods to reproduce data migration --- store/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/store/src/lib.rs b/store/src/lib.rs index 5814bf6c..b2408ca5 100644 --- a/store/src/lib.rs +++ b/store/src/lib.rs @@ -32,6 +32,39 @@ pub mod pmmr; pub mod prune_list; pub mod types; +const SEP: u8 = b':'; + +use byteorder::{BigEndian, WriteBytesExt}; + +/// Build a db key from a prefix and a byte vector identifier. +pub fn to_key>(prefix: u8, k: K) -> Vec { + let k = k.as_ref(); + let mut res = Vec::with_capacity(k.len() + 2); + res.push(prefix); + res.push(SEP); + res.extend_from_slice(k); + res +} + +/// Build a db key from a prefix and a byte vector identifier and numeric identifier +pub fn to_key_u64>(prefix: u8, k: K, val: u64) -> Vec { + let k = k.as_ref(); + let mut res = Vec::with_capacity(k.len() + 10); + res.push(prefix); + res.push(SEP); + res.extend_from_slice(k); + res.write_u64::(val).unwrap(); + res +} +/// Build a db key from a prefix and a numeric identifier. +pub fn u64_to_key(prefix: u8, val: u64) -> Vec { + let mut res = Vec::with_capacity(10); + res.push(prefix); + res.push(SEP); + res.write_u64::(val).unwrap(); + res +} + pub use crate::lmdb::*; use std::ffi::OsStr;