0d6e35eea1d4a3533cf1943c407d85dc20460ceb
[NovacoinLibrary.git] / Novacoin / DatabaseInterfaces.cs
1 \feffusing System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 using SQLite.Net;
8 using SQLite.Net.Attributes;
9 using SQLite.Net.Interop;
10 using SQLite.Net.Platform.Generic;
11 using SQLiteNetExtensions.Attributes;
12 using System.Diagnostics.Contracts;
13
14 namespace Novacoin
15 {
16     /// <summary>
17     /// Block headers table
18     /// </summary>
19     public interface IBlockStorageItem
20     {
21         /// <summary>
22         /// Item ID in the database
23         /// </summary>
24         long ItemID { get; set; }
25
26         /// <summary>
27         /// PBKDF2+Salsa20 of block hash
28         /// </summary>
29         byte[] Hash { get; set; }
30
31         /// <summary>
32         /// Version of block schema
33         /// </summary>
34         uint nVersion { get; set; }
35
36         /// <summary>
37         /// Previous block hash.
38         /// </summary>
39         byte[] prevHash { get; set; }
40
41         /// <summary>
42         /// Merkle root hash.
43         /// </summary>
44         byte[] merkleRoot { get; set; }
45
46         /// <summary>
47         /// Block timestamp.
48         /// </summary>
49         uint nTime { get; set; }
50
51         /// <summary>
52         /// Compressed difficulty representation.
53         /// </summary>
54         uint nBits { get; set; }
55
56         /// <summary>
57         /// Nonce counter.
58         /// </summary>
59         uint nNonce { get; set; }
60
61         /// <summary>
62         /// Next block hash.
63         /// </summary>
64         byte[] nextHash { get; set; }
65
66         /// <summary>
67         /// Block type flags
68         /// </summary>
69         BlockType BlockTypeFlag { get; set; }
70
71         /// <summary>
72         /// Stake modifier
73         /// </summary>
74         long nStakeModifier { get; set; }
75
76         /// <summary>
77         /// Proof-of-Stake hash
78         /// </summary>
79         byte[] hashProofOfStake { get; set; }
80
81         /// <summary>
82         /// Stake generation outpoint.
83         /// </summary>
84         byte[] prevoutStake { get; set; }
85
86         /// <summary>
87         /// Stake generation time.
88         /// </summary>
89         uint nStakeTime { get; set; }
90
91         /// <summary>
92         /// Block height
93         /// </summary>
94         uint nHeight { get; set; }
95
96         /// <summary>
97         /// Block position in file
98         /// </summary>
99         byte[] BlockPos { get; set; }
100
101         /// <summary>
102         /// Block size in bytes
103         /// </summary>
104         byte[] BlockSize { get; set; }
105     };
106
107     public interface IMerkleNode
108     {
109         /// <summary>
110         /// Node identifier
111         /// </summary>
112         long nMerkleNodeID { get; set; }
113
114         /// <summary>
115         /// Reference to parent block database item.
116         /// </summary>
117         long nParentBlockID { get; set; }
118
119         /// <summary>
120         /// Transaction type flag
121         /// </summary>
122         TxFlags TransactionFlags { get; set; }
123
124         /// <summary>
125         /// Transaction hash
126         /// </summary>
127         byte[] TransactionHash { get; set; }
128
129         /// <summary>
130         /// Transaction offset from the beginning of block header, encoded in VarInt format.
131         /// </summary>
132         byte[] TxOffset { get; set; }
133
134         /// <summary>
135         /// Transaction size, encoded in VarInt format.
136         /// </summary>
137         byte[] TxSize { get; set; }
138     }
139
140     public interface ITxOutItem
141     {
142         /// <summary>
143         /// Reference to transaction item.
144         /// </summary>
145         long nMerkleNodeID { get; set; }
146
147         /// <summary>
148         /// Output flags
149         /// </summary>
150         OutputFlags outputFlags { get; set; }
151
152         /// <summary>
153         /// Output number in VarInt format.
154         /// </summary>
155         byte[] OutputNumber { get; set; }
156
157         /// <summary>
158         /// Output value in VarInt format.
159         /// </summary>
160         byte[] OutputValue { get; set; }
161
162         /// <summary>
163         /// Second half of script which contains spending instructions.
164         /// </summary>
165         byte[] scriptPubKey { get; set; }
166
167         /// <summary>
168         /// Getter for output number.
169         /// </summary>
170         uint nOut { get; }
171
172         /// <summary>
173         /// Getter for output value.
174         /// </summary>
175         ulong nValue { get; }
176
177         /// <summary>
178         /// Getter ans setter for IsSpent flag.
179         /// </summary>
180         bool IsSpent { get; set; }
181     }
182 }