-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Validation Checks - Message, Timestamp and Block Sig (#219)
* Added check msg function * Added message check * Added required funds method to message trait * Added sequence and balance methods to actor state * check msg implemented * Added check message functionality for message validation * Added initial validation checks * timestamp check * message state transition checks * Added block signature check * made requested changes * Moved timestamps validation to header.rs
- Loading branch information
1 parent
fdf6c50
commit 67ebaae
Showing
11 changed files
with
230 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
// Copyright 2020 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use std::fmt; | ||
use std::{fmt, time::SystemTimeError as TimeErr}; | ||
|
||
#[derive(Debug, PartialEq)] | ||
pub enum Error { | ||
/// Tipset contains invalid data, as described by the string parameter. | ||
InvalidTipSet(String), | ||
/// The given tipset has no blocks | ||
NoBlocks, | ||
/// Invalid signature | ||
InvalidSignature(String), | ||
/// Error in validating arbitrary data | ||
Validation(String), | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Error::InvalidTipSet(msg) => write!(f, "Invalid tipset: {}", msg), | ||
Error::NoBlocks => write!(f, "No blocks for tipset"), | ||
Error::InvalidSignature(msg) => write!(f, "Invalid signature: {}", msg), | ||
Error::Validation(msg) => write!(f, "Error validating data: {}", msg), | ||
} | ||
} | ||
} | ||
|
||
impl From<TimeErr> for Error { | ||
fn from(e: TimeErr) -> Error { | ||
Error::Validation(e.to_string()) | ||
} | ||
} |
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
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
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
Oops, something went wrong.