1
1
use chrono:: { DateTime , Utc } ;
2
2
3
3
use mithril_common:: entities:: {
4
- CardanoDbBeacon , Certificate , CertificateMetadata , CertificateSignature , Epoch ,
5
- HexEncodedAggregateVerificationKey , HexEncodedKey , ImmutableFileNumber , ProtocolMessage ,
6
- ProtocolParameters , ProtocolVersion , SignedEntityType , StakeDistributionParty ,
4
+ Certificate , CertificateMetadata , CertificateSignature , Epoch ,
5
+ HexEncodedAggregateVerificationKey , HexEncodedKey , ProtocolMessage , ProtocolParameters ,
6
+ ProtocolVersion , SignedEntityType , StakeDistributionParty ,
7
7
} ;
8
- use mithril_common:: era_deprecate;
9
8
use mithril_common:: messages:: {
10
9
CertificateListItemMessage , CertificateListItemMessageMetadata , CertificateMessage ,
11
10
CertificateMetadataMessagePart ,
12
11
} ;
13
12
#[ cfg( test) ]
14
- use mithril_common:: test_utils:: { fake_data, fake_keys} ;
13
+ use mithril_common:: {
14
+ entities:: { CardanoDbBeacon , ImmutableFileNumber } ,
15
+ test_utils:: { fake_data, fake_keys} ,
16
+ } ;
15
17
use mithril_persistence:: {
16
18
database:: Hydrator ,
17
19
sqlite:: { HydrationError , Projection , SqLiteEntity } ,
18
20
} ;
19
21
20
- era_deprecate ! ( "Remove immutable_file_number" ) ;
21
22
/// Certificate record is the representation of a stored certificate.
22
23
#[ derive( Debug , PartialEq , Clone ) ]
23
24
pub struct CertificateRecord {
@@ -44,9 +45,6 @@ pub struct CertificateRecord {
44
45
/// Cardano network of the certificate.
45
46
pub network : String ,
46
47
47
- /// Immutable file number at the time the certificate was created
48
- pub immutable_file_number : ImmutableFileNumber ,
49
-
50
48
/// Signed entity type of the message
51
49
pub signed_entity_type : SignedEntityType ,
52
50
@@ -71,21 +69,11 @@ pub struct CertificateRecord {
71
69
72
70
#[ cfg( test) ]
73
71
impl CertificateRecord {
74
- pub fn dummy_genesis (
75
- id : & str ,
76
- epoch : Epoch ,
77
- immutable_file_number : ImmutableFileNumber ,
78
- ) -> Self {
72
+ pub fn dummy_genesis ( id : & str , epoch : Epoch ) -> Self {
79
73
Self {
80
74
parent_certificate_id : None ,
81
75
signature : fake_keys:: genesis_signature ( ) [ 0 ] . to_owned ( ) ,
82
- ..Self :: dummy (
83
- id,
84
- "" ,
85
- epoch,
86
- immutable_file_number,
87
- SignedEntityType :: genesis ( epoch) ,
88
- )
76
+ ..Self :: dummy ( id, "" , epoch, SignedEntityType :: genesis ( epoch) )
89
77
}
90
78
}
91
79
@@ -99,7 +87,6 @@ impl CertificateRecord {
99
87
id,
100
88
parent_id,
101
89
epoch,
102
- immutable_file_number,
103
90
SignedEntityType :: CardanoImmutableFilesFull ( CardanoDbBeacon :: new (
104
91
fake_data:: network ( ) . to_string ( ) ,
105
92
* epoch,
@@ -108,17 +95,11 @@ impl CertificateRecord {
108
95
)
109
96
}
110
97
111
- pub fn dummy_msd (
112
- id : & str ,
113
- parent_id : & str ,
114
- epoch : Epoch ,
115
- immutable_file_number : ImmutableFileNumber ,
116
- ) -> Self {
98
+ pub fn dummy_msd ( id : & str , parent_id : & str , epoch : Epoch ) -> Self {
117
99
Self :: dummy (
118
100
id,
119
101
parent_id,
120
102
epoch,
121
- immutable_file_number,
122
103
SignedEntityType :: MithrilStakeDistribution ( epoch) ,
123
104
)
124
105
}
@@ -127,7 +108,6 @@ impl CertificateRecord {
127
108
id : & str ,
128
109
parent_id : & str ,
129
110
epoch : Epoch ,
130
- immutable_file_number : ImmutableFileNumber ,
131
111
signed_entity_type : SignedEntityType ,
132
112
) -> Self {
133
113
Self {
@@ -138,7 +118,6 @@ impl CertificateRecord {
138
118
aggregate_verification_key : fake_keys:: aggregate_verification_key ( ) [ 0 ] . to_owned ( ) ,
139
119
epoch,
140
120
network : fake_data:: network ( ) . to_string ( ) ,
141
- immutable_file_number,
142
121
signed_entity_type,
143
122
protocol_version : "protocol_version" . to_string ( ) ,
144
123
protocol_parameters : ProtocolParameters {
@@ -158,20 +137,6 @@ impl CertificateRecord {
158
137
}
159
138
}
160
139
161
- impl CertificateRecord {
162
- era_deprecate ! (
163
- "remove this method when the immutable_file_number is removed from the metadata"
164
- ) ;
165
- /// Deduce a [CardanoDbBeacon] from this record values.
166
- fn as_cardano_db_beacon ( & self ) -> CardanoDbBeacon {
167
- CardanoDbBeacon :: new (
168
- self . network . clone ( ) ,
169
- * self . epoch ,
170
- self . immutable_file_number ,
171
- )
172
- }
173
- }
174
-
175
140
impl From < Certificate > for CertificateRecord {
176
141
fn from ( other : Certificate ) -> Self {
177
142
let signed_entity_type = other. signed_entity_type ( ) ;
@@ -182,7 +147,6 @@ impl From<Certificate> for CertificateRecord {
182
147
}
183
148
} ;
184
149
185
- #[ allow( deprecated) ]
186
150
CertificateRecord {
187
151
certificate_id : other. hash ,
188
152
parent_certificate_id,
@@ -191,7 +155,6 @@ impl From<Certificate> for CertificateRecord {
191
155
aggregate_verification_key : other. aggregate_verification_key . to_json_hex ( ) . unwrap ( ) ,
192
156
epoch : other. epoch ,
193
157
network : other. metadata . network ,
194
- immutable_file_number : other. metadata . immutable_file_number ,
195
158
signed_entity_type,
196
159
protocol_version : other. metadata . protocol_version ,
197
160
protocol_parameters : other. metadata . protocol_parameters ,
@@ -207,7 +170,6 @@ impl From<CertificateRecord> for Certificate {
207
170
fn from ( other : CertificateRecord ) -> Self {
208
171
let certificate_metadata = CertificateMetadata :: new (
209
172
other. network ,
210
- other. immutable_file_number ,
211
173
other. protocol_version ,
212
174
other. protocol_parameters ,
213
175
other. initiated_at ,
@@ -243,7 +205,6 @@ impl From<CertificateRecord> for Certificate {
243
205
244
206
impl From < CertificateRecord > for CertificateMessage {
245
207
fn from ( value : CertificateRecord ) -> Self {
246
- let beacon = Some ( value. as_cardano_db_beacon ( ) ) ;
247
208
let metadata = CertificateMetadataMessagePart {
248
209
network : value. network ,
249
210
protocol_version : value. protocol_version ,
@@ -258,13 +219,11 @@ impl From<CertificateRecord> for CertificateMessage {
258
219
( value. signature , String :: new ( ) )
259
220
} ;
260
221
261
- #[ allow( deprecated) ]
262
222
CertificateMessage {
263
223
hash : value. certificate_id ,
264
224
previous_hash : value. parent_certificate_id . unwrap_or_default ( ) ,
265
225
epoch : value. epoch ,
266
226
signed_entity_type : value. signed_entity_type ,
267
- beacon,
268
227
metadata,
269
228
protocol_message : value. protocol_message ,
270
229
signed_message : value. message ,
@@ -277,7 +236,6 @@ impl From<CertificateRecord> for CertificateMessage {
277
236
278
237
impl From < CertificateRecord > for CertificateListItemMessage {
279
238
fn from ( value : CertificateRecord ) -> Self {
280
- let beacon = Some ( value. as_cardano_db_beacon ( ) ) ;
281
239
let metadata = CertificateListItemMessageMetadata {
282
240
network : value. network ,
283
241
protocol_version : value. protocol_version ,
@@ -287,13 +245,11 @@ impl From<CertificateRecord> for CertificateListItemMessage {
287
245
total_signers : value. signers . len ( ) ,
288
246
} ;
289
247
290
- #[ allow( deprecated) ]
291
248
CertificateListItemMessage {
292
249
hash : value. certificate_id ,
293
250
previous_hash : value. parent_certificate_id . unwrap_or_default ( ) ,
294
251
epoch : value. epoch ,
295
252
signed_entity_type : value. signed_entity_type ,
296
- beacon,
297
253
metadata,
298
254
protocol_message : value. protocol_message ,
299
255
signed_message : value. message ,
@@ -314,15 +270,14 @@ impl SqLiteEntity for CertificateRecord {
314
270
let aggregate_verification_key = row. read :: < & str , _ > ( 4 ) . to_string ( ) ;
315
271
let epoch_int = row. read :: < i64 , _ > ( 5 ) ;
316
272
let network = row. read :: < & str , _ > ( 6 ) . to_string ( ) ;
317
- let immutable_file_number = row. read :: < i64 , _ > ( 7 ) ;
318
- let signed_entity_type_id = row. read :: < i64 , _ > ( 8 ) ;
319
- let signed_entity_beacon_string = Hydrator :: read_signed_entity_beacon_column ( & row, 9 ) ;
320
- let protocol_version = row. read :: < & str , _ > ( 10 ) . to_string ( ) ;
321
- let protocol_parameters_string = row. read :: < & str , _ > ( 11 ) ;
322
- let protocol_message_string = row. read :: < & str , _ > ( 12 ) ;
323
- let signers_string = row. read :: < & str , _ > ( 13 ) ;
324
- let initiated_at = row. read :: < & str , _ > ( 14 ) ;
325
- let sealed_at = row. read :: < & str , _ > ( 15 ) ;
273
+ let signed_entity_type_id = row. read :: < i64 , _ > ( 7 ) ;
274
+ let signed_entity_beacon_string = Hydrator :: read_signed_entity_beacon_column ( & row, 8 ) ;
275
+ let protocol_version = row. read :: < & str , _ > ( 9 ) . to_string ( ) ;
276
+ let protocol_parameters_string = row. read :: < & str , _ > ( 10 ) ;
277
+ let protocol_message_string = row. read :: < & str , _ > ( 11 ) ;
278
+ let signers_string = row. read :: < & str , _ > ( 12 ) ;
279
+ let initiated_at = row. read :: < & str , _ > ( 13 ) ;
280
+ let sealed_at = row. read :: < & str , _ > ( 14 ) ;
326
281
327
282
let certificate_record = Self {
328
283
certificate_id,
@@ -336,11 +291,6 @@ impl SqLiteEntity for CertificateRecord {
336
291
) )
337
292
} ) ?) ,
338
293
network,
339
- immutable_file_number : immutable_file_number. try_into ( ) . map_err ( |e| {
340
- HydrationError :: InvalidData ( format ! (
341
- "Could not cast i64 ({immutable_file_number}) to u64. Error: '{e}'"
342
- ) )
343
- } ) ?,
344
294
signed_entity_type : Hydrator :: hydrate_signed_entity_type (
345
295
signed_entity_type_id. try_into ( ) . map_err ( |e| {
346
296
HydrationError :: InvalidData ( format ! (
@@ -407,11 +357,6 @@ impl SqLiteEntity for CertificateRecord {
407
357
) ;
408
358
projection. add_field ( "epoch" , "{:certificate:}.epoch" , "integer" ) ;
409
359
projection. add_field ( "network" , "{:certificate:}.network" , "text" ) ;
410
- projection. add_field (
411
- "immutable_file_number" ,
412
- "{:certificate:}.immutable_file_number" ,
413
- "integer" ,
414
- ) ;
415
360
projection. add_field (
416
361
"signed_entity_type_id" ,
417
362
"{:certificate:}.signed_entity_type_id" ,
@@ -468,7 +413,7 @@ mod tests {
468
413
#[ test]
469
414
fn converting_certificate_record_to_certificate_should_not_recompute_hash ( ) {
470
415
let expected_hash = "my_hash" ;
471
- let record = CertificateRecord :: dummy_genesis ( expected_hash, Epoch ( 1 ) , 1 ) ;
416
+ let record = CertificateRecord :: dummy_genesis ( expected_hash, Epoch ( 1 ) ) ;
472
417
let certificate: Certificate = record. into ( ) ;
473
418
474
419
assert_eq ! ( expected_hash, & certificate. hash) ;
0 commit comments