@@ -107,7 +107,7 @@ impl MithrilSignedEntityService {
107
107
}
108
108
}
109
109
110
- async fn create_artifact_impl (
110
+ async fn create_artifact_task (
111
111
& self ,
112
112
signed_entity_type : SignedEntityType ,
113
113
certificate : & Certificate ,
@@ -118,11 +118,6 @@ impl MithrilSignedEntityService {
118
118
"certificate_hash" => & certificate. hash
119
119
) ;
120
120
121
- println ! (
122
- "MithrilSignedEntityService::create_artifact: signed_entity_type: {:?}, certificate_hash: {}" ,
123
- signed_entity_type, certificate. hash
124
- ) ;
125
-
126
121
let mut remaining_retries = 2 ;
127
122
let artifact = loop {
128
123
remaining_retries -= 1 ;
@@ -156,47 +151,6 @@ impl MithrilSignedEntityService {
156
151
Ok ( ( ) )
157
152
}
158
153
159
- async fn create_artifact_return_join_handle (
160
- & self ,
161
- signed_entity_type : SignedEntityType ,
162
- certificate : & Certificate ,
163
- ) -> StdResult < JoinHandle < StdResult < ( ) > > > {
164
- if self
165
- . signed_entity_type_lock
166
- . is_locked ( & signed_entity_type)
167
- . await
168
- {
169
- return Err ( anyhow ! (
170
- "Signed entity type '{:?}' is already locked" ,
171
- signed_entity_type
172
- ) ) ;
173
- }
174
-
175
- let service = self . clone ( ) ;
176
- let certificate_cloned = certificate. clone ( ) ;
177
- service
178
- . signed_entity_type_lock
179
- . lock ( & signed_entity_type)
180
- . await ;
181
-
182
- Ok ( tokio:: task:: spawn ( async move {
183
- let signed_entity_type_clone = signed_entity_type. clone ( ) ;
184
- let service_clone = service. clone ( ) ;
185
- let result = tokio:: task:: spawn ( async move {
186
- service_clone
187
- . create_artifact_impl ( signed_entity_type_clone, & certificate_cloned)
188
- . await
189
- } )
190
- . await ;
191
- service
192
- . signed_entity_type_lock
193
- . release ( signed_entity_type)
194
- . await ;
195
-
196
- result. unwrap ( )
197
- } ) )
198
- }
199
-
200
154
/// Compute artifact from signed entity type
201
155
async fn compute_artifact (
202
156
& self ,
@@ -285,7 +239,7 @@ impl SignedEntityService for MithrilSignedEntityService {
285
239
let service_clone = service. clone ( ) ;
286
240
let result = tokio:: task:: spawn ( async move {
287
241
service_clone
288
- . create_artifact_impl ( signed_entity_type_clone, & certificate_cloned)
242
+ . create_artifact_task ( signed_entity_type_clone, & certificate_cloned)
289
243
. await
290
244
} )
291
245
. await ;
@@ -544,12 +498,6 @@ mod tests {
544
498
}
545
499
}
546
500
547
- fn mock_immutable_files_processing ( & mut self , artifact : Snapshot ) {
548
- self . mock_artifact_processing ( artifact, & |mock_injector| {
549
- & mut mock_injector. mock_cardano_immutable_files_full_artifact_builder
550
- } ) ;
551
- }
552
-
553
501
fn mock_stake_distribution_processing ( & mut self , artifact : MithrilStakeDistribution ) {
554
502
self . mock_artifact_processing ( artifact, & |mock_injector| {
555
503
& mut mock_injector. mock_mithril_stake_distribution_artifact_builder
@@ -705,40 +653,11 @@ mod tests {
705
653
let error_message_str = error_message. as_str ( ) ;
706
654
707
655
artifact_builder_service
708
- . create_artifact_impl ( signed_entity_type, & certificate)
656
+ . create_artifact_task ( signed_entity_type, & certificate)
709
657
. await
710
658
. expect ( error_message_str) ;
711
659
}
712
660
713
- // TODO: Verify the relevance of this test
714
- #[ tokio:: test]
715
- async fn create_artifact_for_two_signed_entity_types_in_sequence ( ) {
716
- let signed_entity_type_service = {
717
- let mut mock_container = MockDependencyInjector :: new ( ) ;
718
- mock_container. mock_immutable_files_processing (
719
- fake_data:: snapshots ( 1 ) . first ( ) . unwrap ( ) . to_owned ( ) ,
720
- ) ;
721
- mock_container
722
- . mock_stake_distribution_processing ( create_stake_distribution ( Epoch ( 1 ) , 5 ) ) ;
723
-
724
- mock_container. build_artifact_builder_service ( )
725
- } ;
726
- let certificate = fake_data:: certificate ( "hash" . to_string ( ) ) ;
727
-
728
- let signed_entity_type_immutable =
729
- SignedEntityType :: CardanoImmutableFilesFull ( CardanoDbBeacon :: default ( ) ) ;
730
- signed_entity_type_service
731
- . create_artifact_impl ( signed_entity_type_immutable, & certificate)
732
- . await
733
- . unwrap ( ) ;
734
-
735
- let signed_entity_type_msd = SignedEntityType :: MithrilStakeDistribution ( Epoch ( 1 ) ) ;
736
- signed_entity_type_service
737
- . create_artifact_impl ( signed_entity_type_msd, & certificate)
738
- . await
739
- . unwrap ( ) ;
740
- }
741
-
742
661
#[ tokio:: test]
743
662
async fn create_artifact_for_two_signed_entity_types_in_sequence_not_blocking ( ) {
744
663
let atomic_stop = Arc :: new ( AtomicBool :: new ( false ) ) ;
@@ -756,13 +675,13 @@ mod tests {
756
675
let signed_entity_type_immutable =
757
676
SignedEntityType :: CardanoImmutableFilesFull ( CardanoDbBeacon :: default ( ) ) ;
758
677
let first_task_that_never_finished = signed_entity_type_service
759
- . create_artifact_return_join_handle ( signed_entity_type_immutable, & certificate)
678
+ . create_artifact ( signed_entity_type_immutable, & certificate)
760
679
. await
761
680
. unwrap ( ) ;
762
681
763
682
let signed_entity_type_msd = SignedEntityType :: MithrilStakeDistribution ( Epoch ( 1 ) ) ;
764
683
let second_task_that_finish_first = signed_entity_type_service
765
- . create_artifact_return_join_handle ( signed_entity_type_msd, & certificate)
684
+ . create_artifact ( signed_entity_type_msd, & certificate)
766
685
. await
767
686
. unwrap ( ) ;
768
687
@@ -788,7 +707,7 @@ mod tests {
788
707
. await
789
708
) ;
790
709
let join_handle = signed_entity_type_service
791
- . create_artifact_return_join_handle ( signed_entity_type_immutable. clone ( ) , & certificate)
710
+ . create_artifact ( signed_entity_type_immutable. clone ( ) , & certificate)
792
711
. await
793
712
. unwrap ( ) ;
794
713
@@ -831,7 +750,7 @@ mod tests {
831
750
SignedEntityType :: CardanoImmutableFilesFull ( CardanoDbBeacon :: default ( ) ) ;
832
751
833
752
let join_handle = signed_entity_type_service
834
- . create_artifact_return_join_handle ( signed_entity_type_immutable. clone ( ) , & certificate)
753
+ . create_artifact ( signed_entity_type_immutable. clone ( ) , & certificate)
835
754
. await
836
755
. unwrap ( ) ;
837
756
@@ -855,7 +774,7 @@ mod tests {
855
774
SignedEntityType :: CardanoImmutableFilesFull ( CardanoDbBeacon :: default ( ) ) ;
856
775
857
776
let join_handle = signed_entity_type_service
858
- . create_artifact_return_join_handle ( signed_entity_type_immutable. clone ( ) , & certificate)
777
+ . create_artifact ( signed_entity_type_immutable. clone ( ) , & certificate)
859
778
. await
860
779
. unwrap ( ) ;
861
780
@@ -879,12 +798,12 @@ mod tests {
879
798
SignedEntityType :: CardanoImmutableFilesFull ( CardanoDbBeacon :: default ( ) ) ;
880
799
881
800
signed_entity_service
882
- . create_artifact_return_join_handle ( signed_entity_type_immutable. clone ( ) , & certificate)
801
+ . create_artifact ( signed_entity_type_immutable. clone ( ) , & certificate)
883
802
. await
884
803
. unwrap ( ) ;
885
804
886
805
signed_entity_service
887
- . create_artifact_return_join_handle ( signed_entity_type_immutable, & certificate)
806
+ . create_artifact ( signed_entity_type_immutable, & certificate)
888
807
. await
889
808
. expect_err ( "Should return error when signed entity type is already locked" ) ;
890
809
0 commit comments