kaspa_database/
registry.rs1use enum_primitive_derive::Primitive;
2
3pub const SEPARATOR: u8 = u8::MAX;
6
7#[derive(Primitive, Debug, Clone, Copy)]
8#[repr(u8)]
9pub enum DatabaseStorePrefixes {
10 AcceptanceData = 1,
12 BlockTransactions = 2,
13 NonDaaMergeset = 3,
14 BlockDepth = 4,
15 Ghostdag = 5,
16 GhostdagCompact = 6,
17 HeadersSelectedTip = 7,
18 Headers = 8,
20 HeadersCompact = 9,
21 PastPruningPoints = 10,
22 PruningUtxoset = 11,
23 PruningUtxosetPosition = 12,
24 PruningPoint = 13,
25 RetentionCheckpoint = 14,
26 Reachability = 15,
27 ReachabilityReindexRoot = 16,
28 ReachabilityRelations = 17,
29 RelationsParents = 18,
30 RelationsChildren = 19,
31 ChainHashByIndex = 20,
32 ChainIndexByHash = 21,
33 ChainHighestIndex = 22,
34 Statuses = 23,
35 Tips = 24,
36 UtxoDiffs = 25,
37 UtxoMultisets = 26,
38 VirtualUtxoset = 27,
39 VirtualState = 28,
40 PruningSamples = 29,
41
42 ReachabilityTreeChildren = 30,
44 ReachabilityFutureCoveringSet = 31,
45
46 CompressedHeaders = 32,
48
49 PruningProofDescriptor = 33,
51
52 TempGhostdag = 40,
54 TempGhostdagCompact = 41,
55 TempRelationsParents = 42,
56 TempRelationsChildren = 43,
57
58 RetentionPeriodRoot = 50,
60
61 PruningUtxosetSyncFlag = 60,
63 BodyMissingAnticone = 61,
64
65 MultiConsensusMetadata = 124,
67 ConsensusEntries = 125,
68
69 Addresses = 128,
71 BannedAddresses = 129,
72
73 UtxoIndex = 192,
75 UtxoIndexTips = 193,
76 CirculatingSupply = 194,
77
78 SmtBranchVersions = 71,
80 SmtLaneVersions = 73,
81 SmtScoreIndex = 74,
82 SmtSyncFlag = 75,
83 SmtSeqCommitMeta = 76,
84
85 Separator = SEPARATOR,
88}
89
90impl From<DatabaseStorePrefixes> for Vec<u8> {
91 fn from(value: DatabaseStorePrefixes) -> Self {
92 [value as u8].to_vec()
93 }
94}
95
96impl From<DatabaseStorePrefixes> for u8 {
97 fn from(value: DatabaseStorePrefixes) -> Self {
98 value as u8
99 }
100}
101
102impl AsRef<[u8]> for DatabaseStorePrefixes {
103 fn as_ref(&self) -> &[u8] {
104 std::slice::from_ref(unsafe { &*(self as *const Self as *const u8) })
106 }
107}
108
109impl IntoIterator for DatabaseStorePrefixes {
110 type Item = u8;
111 type IntoIter = <[u8; 1] as IntoIterator>::IntoIter;
112 fn into_iter(self) -> Self::IntoIter {
113 [self as u8].into_iter()
114 }
115}
116
117#[cfg(test)]
118mod tests {
119 use super::*;
120
121 #[test]
122 fn test_as_ref() {
123 let prefix = DatabaseStorePrefixes::AcceptanceData;
124 assert_eq!(&[prefix as u8], prefix.as_ref());
125 assert_eq!(
126 size_of::<u8>(),
127 size_of::<DatabaseStorePrefixes>(),
128 "DatabaseStorePrefixes is expected to have the same memory layout of u8"
129 );
130 }
131}