-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: contested unique indexes can only be on non mutable document types
- Loading branch information
1 parent
4dd34e2
commit d82025a
Showing
6 changed files
with
122 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...rs/consensus/basic/data_contract/contested_unique_index_on_mutable_document_type_error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use crate::consensus::basic::BasicError; | ||
use crate::consensus::ConsensusError; | ||
use crate::errors::ProtocolError; | ||
use bincode::{Decode, Encode}; | ||
use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; | ||
use thiserror::Error; | ||
|
||
#[derive( | ||
Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, | ||
)] | ||
#[error( | ||
"Document type '{document_type}' has a contested unique index '{contested_unique_index_name}'" | ||
)] | ||
#[platform_serialize(unversioned)] | ||
pub struct ContestedUniqueIndexOnMutableDocumentTypeError { | ||
/* | ||
DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION | ||
*/ | ||
document_type: String, | ||
contested_unique_index_name: String, | ||
} | ||
|
||
impl ContestedUniqueIndexOnMutableDocumentTypeError { | ||
pub fn new(document_type: String, contested_unique_index_name: String) -> Self { | ||
Self { | ||
document_type, | ||
contested_unique_index_name, | ||
} | ||
} | ||
|
||
pub fn document_type(&self) -> &str { | ||
&self.document_type | ||
} | ||
|
||
pub fn contested_unique_index_name(&self) -> &str { | ||
&self.contested_unique_index_name | ||
} | ||
} | ||
|
||
impl From<ContestedUniqueIndexOnMutableDocumentTypeError> for ConsensusError { | ||
fn from(err: ContestedUniqueIndexOnMutableDocumentTypeError) -> Self { | ||
Self::BasicError(BasicError::ContestedUniqueIndexOnMutableDocumentTypeError( | ||
err, | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters