Track store metrics by DB column (#6041)

* Track store metrics by DB column
This commit is contained in:
Lion - dapplion
2024-07-18 03:45:06 +02:00
committed by GitHub
parent 8a32df756d
commit b0b142c9b7
3 changed files with 57 additions and 22 deletions

View File

@@ -143,6 +143,13 @@ pub fn get_key_for_col(column: &str, key: &[u8]) -> Vec<u8> {
result
}
pub fn get_col_from_key(key: &[u8]) -> Option<String> {
if key.len() < 3 {
return None;
}
String::from_utf8(key[0..3].to_vec()).ok()
}
#[must_use]
#[derive(Clone)]
pub enum KeyValueStoreOp {
@@ -412,4 +419,11 @@ mod tests {
assert!(!store.exists::<StorableThing>(&key).unwrap());
}
#[test]
fn test_get_col_from_key() {
let key = get_key_for_col(DBColumn::BeaconBlock.into(), &[1u8; 32]);
let col = get_col_from_key(&key).unwrap();
assert_eq!(col, "blk");
}
}