-
Notifications
You must be signed in to change notification settings - Fork 151
/
database_prefixes.go
93 lines (72 loc) · 2.66 KB
/
database_prefixes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package utxo
const (
UTXOStoreKeyPrefixLedgerMilestoneIndex byte = 0
// UTXOStoreKeyPrefixOutput defines the prefix for Output and Spent storage.
UTXOStoreKeyPrefixOutput byte = 1
// UTXOStoreKeyPrefixOutputSpent defines the prefix for Track spent/unspent Outputs.
UTXOStoreKeyPrefixOutputSpent byte = 2
UTXOStoreKeyPrefixOutputUnspent byte = 3
// UTXOStoreKeyPrefixMilestoneDiffs defines the prefix for Milestone diffs.
UTXOStoreKeyPrefixMilestoneDiffs byte = 4
// UTXOStoreKeyPrefixTreasuryOutput defines the prefix for the Treasury Output.
UTXOStoreKeyPrefixTreasuryOutput byte = 5
UTXOStoreKeyPrefixReceipts byte = 6
)
/*
UTXO Database
MilestoneIndex:
===============
Key:
UTXOStoreKeyPrefixLedgerMilestoneIndex
1 byte
Value:
iotago.MilestoneIndex
4 bytes
Output:
=======
Key:
UTXOStoreKeyPrefixOutput + iotago.OutputID
1 byte + 34 bytes
Value:
BlockID + MilestoneIndex + MilestoneTimestamp + iotago.Output.Serialized()
32 bytes + 4 bytes + 4 bytes + 1 byte type + X bytes
Spent Output:
================
Key:
UTXOStoreKeyPrefixSpent + iotago.OutputID
1 byte + 34 bytes
Value:
TargetTransactionID (iotago.TransactionID) + ConfirmationIndex (iotago.MilestoneIndex) + ConfirmationTimestamp
32 bytes + 4 bytes + 4 bytes
Unspent Output:
===============
Key:
UTXOStoreKeyPrefixUnspent + iotago.OutputID
1 byte + 34 bytes
Value:
Empty
Milestone diffs:
================
Key:
UTXOStoreKeyPrefixMilestoneDiffs + iotago.MilestoneIndex
1 byte + 4 bytes
Value:
OutputCount + OutputCount * iotago.OutputID + SpentCount + SpentCount * iotago.OutputID + has treasury + TreasuryOutputMilestoneID + SpentTreasuryOutputMilestoneID
4 bytes + (OutputCount * 34 bytes) + 4 bytes + (SpentCount * 34 bytes) + 1 byte + 32 bytes + 32 bytes
Treasury Output:
=======
Key:
UTXOStoreKeyPrefixTreasuryOutput + spent + iotago.MilestoneID
1 byte + 1 byte + 32 bytes
Value:
Amount
8 bytes
Receipts:
=======
Key:
UTXOStoreKeyPrefixReceipts + migrated_at_index + milestone_index
1 byte + 4 byte + 4 bytes
Value:
Receipt (iotago.ReceiptMilestoneOpt.Serialized())
1 byte type + X bytes
*/