mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
Track store metrics by DB column (#6041)
* Track store metrics by DB column
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user