@@ -49,6 +49,7 @@ pub enum Error {
4949 FailedToUnlock ( H256 ) ,
5050 /// Returned when the sum of the transaction's inputs is different from the sum of outputs.
5151 InconsistentTransactionInOut ,
52+ InvalidShardNonce ( Mismatch < u64 > ) ,
5253}
5354
5455const ERROR_ID_INVALID_PAYMENT_SENDER : u8 = 1u8 ;
@@ -62,6 +63,7 @@ const ERROR_ID_SCRIPT_HASH_MISMATCH: u8 = 8u8;
6263const ERROR_ID_INVALID_SCRIPT : u8 = 9u8 ;
6364const ERROR_ID_FAILED_TO_UNLOCK : u8 = 10u8 ;
6465const ERROR_ID_INCONSISTENT_TRANSACTION_IN_OUT : u8 = 11u8 ;
66+ const ERROR_ID_INVALID_SHARD_NONCE : u8 = 12u8 ;
6567
6668impl Encodable for Error {
6769 fn rlp_append ( & self , s : & mut RlpStream ) {
@@ -91,6 +93,9 @@ impl Encodable for Error {
9193 Error :: InvalidScript => s. begin_list ( 1 ) . append ( & ERROR_ID_INVALID_SCRIPT ) ,
9294 Error :: FailedToUnlock ( hash) => s. begin_list ( 1 ) . append ( & ERROR_ID_FAILED_TO_UNLOCK ) . append ( hash) ,
9395 Error :: InconsistentTransactionInOut => s. begin_list ( 1 ) . append ( & ERROR_ID_INCONSISTENT_TRANSACTION_IN_OUT ) ,
96+ Error :: InvalidShardNonce ( mismatch) => {
97+ s. begin_list ( 2 ) . append ( & ERROR_ID_INVALID_SHARD_NONCE ) . append ( mismatch)
98+ }
9499 } ;
95100 }
96101}
@@ -118,6 +123,12 @@ impl Decodable for Error {
118123 ERROR_ID_INVALID_SCRIPT => Error :: InvalidScript ,
119124 ERROR_ID_FAILED_TO_UNLOCK => Error :: FailedToUnlock ( rlp. val_at ( 1 ) ?) ,
120125 ERROR_ID_INCONSISTENT_TRANSACTION_IN_OUT => Error :: InconsistentTransactionInOut ,
126+ ERROR_ID_INVALID_SHARD_NONCE => {
127+ if rlp. item_count ( ) ? != 2 {
128+ return Err ( DecoderError :: RlpInvalidLength )
129+ }
130+ Error :: InvalidShardNonce ( rlp. val_at ( 1 ) ?)
131+ }
121132 _ => return Err ( DecoderError :: Custom ( "Invalid transaction error" ) ) ,
122133 } )
123134 }
@@ -153,6 +164,7 @@ impl Display for Error {
153164 Error :: InconsistentTransactionInOut => {
154165 write ! ( f, "The sum of the transaction's inputs is different from the sum of the transaction's outputs" )
155166 }
167+ Error :: InvalidShardNonce ( mismatch) => write ! ( f, "The shard nonce {}" , mismatch) ,
156168 }
157169 }
158170}
0 commit comments