@@ -102,7 +102,7 @@ const OPTIMISTIC_SLOTS_CF: &str = "optimistic_slots";
102
102
/// Column family for merkle roots
103
103
const MERKLE_ROOT_META_CF : & str = "merkle_root_meta" ;
104
104
105
- macro_rules! concat_key_bytes {
105
+ macro_rules! convert_column_index_to_key_bytes {
106
106
( $key: ident, $( $range: expr => $bytes: expr) ,* $( , ) ?) => { {
107
107
let mut key = [ 0u8 ; std:: mem:: size_of:: <Self :: $key>( ) ] ;
108
108
debug_assert_eq!( 0 $( +$bytes. len( ) ) * , key. len( ) ) ;
@@ -111,7 +111,7 @@ macro_rules! concat_key_bytes {
111
111
} } ;
112
112
}
113
113
114
- macro_rules! convert_key_bytes {
114
+ macro_rules! convert_column_key_bytes_to_index {
115
115
( $k: ident, $( $a: literal..$b: literal => $f: expr) ,* $( , ) ?) => { {
116
116
( $( $f( <[ u8 ; $b-$a] >:: try_from( & $k[ $a..$b] ) . unwrap( ) ) ) ,* )
117
117
} } ;
@@ -852,7 +852,7 @@ impl<T: SlotColumn> Column for T {
852
852
853
853
/// Converts a RocksDB key to its u64 Index.
854
854
fn index ( key : & [ u8 ] ) -> Self :: Index {
855
- convert_key_bytes ! ( key, 0 ..8 => Slot :: from_be_bytes)
855
+ convert_column_key_bytes_to_index ! ( key, 0 ..8 => Slot :: from_be_bytes)
856
856
}
857
857
858
858
fn slot ( index : Self :: Index ) -> Slot {
@@ -901,7 +901,7 @@ impl Column for columns::TransactionStatus {
901
901
902
902
#[ inline]
903
903
fn key ( ( signature, slot) : & Self :: Index ) -> Self :: Key {
904
- concat_key_bytes ! ( Key ,
904
+ convert_column_index_to_key_bytes ! ( Key ,
905
905
..64 => signature. as_ref( ) ,
906
906
64 .. => & slot. to_be_bytes( ) ,
907
907
)
@@ -934,7 +934,7 @@ impl ColumnIndexDeprecation for columns::TransactionStatus {
934
934
type DeprecatedKey = [ u8 ; 80 ] ;
935
935
936
936
fn deprecated_key ( ( index, signature, slot) : Self :: DeprecatedIndex ) -> Self :: DeprecatedKey {
937
- concat_key_bytes ! ( DeprecatedKey ,
937
+ convert_column_index_to_key_bytes ! ( DeprecatedKey ,
938
938
..8 => & index. to_be_bytes( ) ,
939
939
8 ..72 => signature. as_ref( ) ,
940
940
72 .. => & slot. to_be_bytes( ) ,
@@ -945,7 +945,7 @@ impl ColumnIndexDeprecation for columns::TransactionStatus {
945
945
if key. len ( ) != std:: mem:: size_of :: < Self :: DeprecatedKey > ( ) {
946
946
return Err ( IndexError :: UnpackError ) ;
947
947
}
948
- Ok ( convert_key_bytes ! ( key,
948
+ Ok ( convert_column_key_bytes_to_index ! ( key,
949
949
0 ..8 => u64 :: from_be_bytes, // primary index
950
950
8 ..72 => Signature :: from,
951
951
72 ..80 => Slot :: from_be_bytes,
@@ -956,7 +956,7 @@ impl ColumnIndexDeprecation for columns::TransactionStatus {
956
956
if key. len ( ) != Self :: CURRENT_INDEX_LEN {
957
957
return Err ( IndexError :: UnpackError ) ;
958
958
}
959
- Ok ( convert_key_bytes ! ( key,
959
+ Ok ( convert_column_key_bytes_to_index ! ( key,
960
960
0 ..64 => Signature :: from,
961
961
64 ..72 => Slot :: from_be_bytes,
962
962
) )
@@ -977,7 +977,7 @@ impl Column for columns::AddressSignatures {
977
977
978
978
#[ inline]
979
979
fn key ( ( pubkey, slot, transaction_index, signature) : & Self :: Index ) -> Self :: Key {
980
- concat_key_bytes ! ( Key ,
980
+ convert_column_index_to_key_bytes ! ( Key ,
981
981
..32 => pubkey. as_ref( ) ,
982
982
32 ..40 => & slot. to_be_bytes( ) ,
983
983
40 ..44 => & transaction_index. to_be_bytes( ) ,
@@ -1011,7 +1011,7 @@ impl ColumnIndexDeprecation for columns::AddressSignatures {
1011
1011
fn deprecated_key (
1012
1012
( primary_index, pubkey, slot, signature) : Self :: DeprecatedIndex ,
1013
1013
) -> Self :: DeprecatedKey {
1014
- concat_key_bytes ! ( DeprecatedKey ,
1014
+ convert_column_index_to_key_bytes ! ( DeprecatedKey ,
1015
1015
..8 => & primary_index. to_be_bytes( ) ,
1016
1016
8 ..40 => pubkey. as_ref( ) ,
1017
1017
40 ..48 => & slot. to_be_bytes( ) ,
@@ -1023,7 +1023,7 @@ impl ColumnIndexDeprecation for columns::AddressSignatures {
1023
1023
if key. len ( ) != std:: mem:: size_of :: < Self :: DeprecatedKey > ( ) {
1024
1024
return Err ( IndexError :: UnpackError ) ;
1025
1025
}
1026
- Ok ( convert_key_bytes ! ( key,
1026
+ Ok ( convert_column_key_bytes_to_index ! ( key,
1027
1027
0 ..8 => u64 :: from_be_bytes, // primary index
1028
1028
8 ..40 => Pubkey :: from,
1029
1029
40 ..48 => Slot :: from_be_bytes,
@@ -1035,7 +1035,7 @@ impl ColumnIndexDeprecation for columns::AddressSignatures {
1035
1035
if key. len ( ) != Self :: CURRENT_INDEX_LEN {
1036
1036
return Err ( IndexError :: UnpackError ) ;
1037
1037
}
1038
- Ok ( convert_key_bytes ! ( key,
1038
+ Ok ( convert_column_key_bytes_to_index ! ( key,
1039
1039
0 ..32 => Pubkey :: from,
1040
1040
32 ..40 => Slot :: from_be_bytes,
1041
1041
40 ..44 => u32 :: from_be_bytes, // transaction index
@@ -1055,7 +1055,7 @@ impl Column for columns::TransactionMemos {
1055
1055
1056
1056
#[ inline]
1057
1057
fn key ( ( signature, slot) : & Self :: Index ) -> Self :: Key {
1058
- concat_key_bytes ! ( Key ,
1058
+ convert_column_index_to_key_bytes ! ( Key ,
1059
1059
..64 => signature. as_ref( ) ,
1060
1060
64 .. => & slot. to_be_bytes( ) ,
1061
1061
)
@@ -1094,7 +1094,7 @@ impl ColumnIndexDeprecation for columns::TransactionMemos {
1094
1094
if key. len ( ) != Self :: CURRENT_INDEX_LEN {
1095
1095
return Err ( IndexError :: UnpackError ) ;
1096
1096
}
1097
- Ok ( convert_key_bytes ! ( key,
1097
+ Ok ( convert_column_key_bytes_to_index ! ( key,
1098
1098
0 ..64 => Signature :: from,
1099
1099
64 ..72 => Slot :: from_be_bytes,
1100
1100
) )
@@ -1115,7 +1115,7 @@ impl Column for columns::TransactionStatusIndex {
1115
1115
}
1116
1116
1117
1117
fn index ( key : & [ u8 ] ) -> Self :: Index {
1118
- convert_key_bytes ! ( key, 0 ..8 => u64 :: from_be_bytes)
1118
+ convert_column_key_bytes_to_index ! ( key, 0 ..8 => u64 :: from_be_bytes)
1119
1119
}
1120
1120
1121
1121
fn slot ( _index : Self :: Index ) -> Slot {
@@ -1175,7 +1175,7 @@ impl Column for columns::ProgramCosts {
1175
1175
}
1176
1176
1177
1177
fn index ( key : & [ u8 ] ) -> Self :: Index {
1178
- convert_key_bytes ! ( key, 0 ..32 => Pubkey :: from)
1178
+ convert_column_key_bytes_to_index ! ( key, 0 ..32 => Pubkey :: from)
1179
1179
}
1180
1180
1181
1181
fn slot ( _index : Self :: Index ) -> Slot {
@@ -1219,14 +1219,14 @@ impl Column for columns::ShredData {
1219
1219
1220
1220
#[ inline]
1221
1221
fn key ( ( slot, index) : & Self :: Index ) -> Self :: Key {
1222
- concat_key_bytes ! ( Key ,
1222
+ convert_column_index_to_key_bytes ! ( Key ,
1223
1223
..8 => & slot. to_be_bytes( ) ,
1224
1224
8 .. => & index. to_be_bytes( ) ,
1225
1225
)
1226
1226
}
1227
1227
1228
1228
fn index ( key : & [ u8 ] ) -> Self :: Index {
1229
- convert_key_bytes ! ( key,
1229
+ convert_column_key_bytes_to_index ! ( key,
1230
1230
0 ..8 => Slot :: from_be_bytes,
1231
1231
8 ..16 => u64 :: from_be_bytes, // shred index
1232
1232
)
@@ -1328,14 +1328,14 @@ impl Column for columns::ErasureMeta {
1328
1328
1329
1329
#[ inline]
1330
1330
fn key ( ( slot, fec_set_index) : & Self :: Index ) -> Self :: Key {
1331
- concat_key_bytes ! ( Key ,
1331
+ convert_column_index_to_key_bytes ! ( Key ,
1332
1332
..8 => & slot. to_be_bytes( ) ,
1333
1333
8 .. => & fec_set_index. to_be_bytes( ) ,
1334
1334
)
1335
1335
}
1336
1336
1337
1337
fn index ( key : & [ u8 ] ) -> Self :: Index {
1338
- convert_key_bytes ! ( key,
1338
+ convert_column_key_bytes_to_index ! ( key,
1339
1339
0 ..8 => Slot :: from_be_bytes,
1340
1340
8 ..16 => u64 :: from_be_bytes, // fec_set_index
1341
1341
)
@@ -1370,14 +1370,14 @@ impl Column for columns::MerkleRootMeta {
1370
1370
1371
1371
#[ inline]
1372
1372
fn key ( ( slot, fec_set_index) : & Self :: Index ) -> Self :: Key {
1373
- concat_key_bytes ! ( Key ,
1373
+ convert_column_index_to_key_bytes ! ( Key ,
1374
1374
..8 => & slot. to_be_bytes( ) ,
1375
1375
8 .. => & fec_set_index. to_be_bytes( ) ,
1376
1376
)
1377
1377
}
1378
1378
1379
1379
fn index ( key : & [ u8 ] ) -> Self :: Index {
1380
- convert_key_bytes ! ( key,
1380
+ convert_column_key_bytes_to_index ! ( key,
1381
1381
0 ..8 => Slot :: from_be_bytes,
1382
1382
8 ..12 => u32 :: from_be_bytes, // fec_set_index
1383
1383
)
0 commit comments