@@ -85,7 +85,7 @@ impl DocumentTypeV1 {
8585 token_configurations : & BTreeMap < TokenContractPosition , TokenConfiguration > ,
8686 data_contact_config : & DataContractConfig ,
8787 full_validation : bool , // we don't need to validate if loaded from state
88- validation_operations : & mut Vec < ProtocolValidationOperation > ,
88+ validation_operations : & mut impl Extend < ProtocolValidationOperation > ,
8989 platform_version : & PlatformVersion ,
9090 ) -> Result < Self , ProtocolError > {
9191 // Create a full root JSON Schema from shorten contract document type schema
@@ -99,9 +99,7 @@ impl DocumentTypeV1 {
9999 if full_validation {
100100 // TODO we are silently dropping this error when we shouldn't be
101101 // but returning this error causes tests to fail; investigate more.
102- ProtocolError :: CorruptedCodeExecution (
103- "validation is not enabled but is being called on try_from_schema" . to_string ( ) ,
104- ) ;
102+ "validation is not enabled but is being called on try_from_schema" . to_string ( ) ;
105103 }
106104
107105 #[ cfg( feature = "validation" ) ]
@@ -129,18 +127,18 @@ impl DocumentTypeV1 {
129127
130128 let schema_size = result. into_data ( ) ?. size ;
131129
132- validation_operations. push (
130+ validation_operations. extend ( std :: iter :: once (
133131 ProtocolValidationOperation :: DocumentTypeSchemaValidationForSize ( schema_size) ,
134- ) ;
132+ ) ) ;
135133
136134 return Err ( ProtocolError :: ConsensusError ( Box :: new ( error) ) ) ;
137135 }
138136
139137 let schema_size = result. into_data ( ) ?. size ;
140138
141- validation_operations. push (
139+ validation_operations. extend ( std :: iter :: once (
142140 ProtocolValidationOperation :: DocumentTypeSchemaValidationForSize ( schema_size) ,
143- ) ;
141+ ) ) ;
144142
145143 // Make sure JSON Schema is compilable
146144 let root_json_schema = root_schema. try_to_validating_json ( ) . map_err ( |e| {
@@ -217,11 +215,11 @@ impl DocumentTypeV1 {
217215
218216 #[ cfg( feature = "validation" ) ]
219217 if full_validation {
220- validation_operations. push (
218+ validation_operations. extend ( std :: iter :: once (
221219 ProtocolValidationOperation :: DocumentTypeSchemaPropertyValidation (
222220 property_values. values ( ) . len ( ) as u64 ,
223221 ) ,
224- ) ;
222+ ) ) ;
225223
226224 // We should validate that the positions are continuous
227225 for ( pos, value) in property_values. values ( ) . enumerate ( ) {
@@ -319,12 +317,12 @@ impl DocumentTypeV1 {
319317
320318 #[ cfg( feature = "validation" ) ]
321319 if full_validation {
322- validation_operations. push (
320+ validation_operations. extend ( std :: iter :: once (
323321 ProtocolValidationOperation :: DocumentTypeSchemaIndexValidation (
324322 index. properties . len ( ) as u64 ,
325323 index. unique ,
326324 ) ,
327- ) ;
325+ ) ) ;
328326
329327 // Unique indices produces significant load on the system during state validation
330328 // so we need to limit their number to prevent of spikes and DoS attacks
0 commit comments