2019-12-02 14:42:05 -08:00
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
#[derive(Error, Debug, PartialEq)]
|
2019-10-31 13:38:50 -07:00
|
|
|
pub enum BlockError {
|
2021-03-01 14:57:37 -08:00
|
|
|
/// Block did not have enough ticks was not marked full
|
|
|
|
/// and no shred with is_last was seen.
|
2020-01-14 17:15:26 -08:00
|
|
|
#[error("incomplete block")]
|
|
|
|
Incomplete,
|
|
|
|
|
2019-10-31 13:38:50 -07:00
|
|
|
/// Block entries hashes must all be valid
|
2019-12-02 14:42:05 -08:00
|
|
|
#[error("invalid entry hash")]
|
2019-10-31 13:38:50 -07:00
|
|
|
InvalidEntryHash,
|
|
|
|
|
2019-11-08 17:21:54 -08:00
|
|
|
/// Blocks must end in a tick that has been marked as the last tick.
|
2019-12-02 14:42:05 -08:00
|
|
|
#[error("invalid last tick")]
|
2019-11-08 17:21:54 -08:00
|
|
|
InvalidLastTick,
|
|
|
|
|
2021-03-01 14:57:37 -08:00
|
|
|
/// Blocks can not have missing ticks
|
2022-02-10 19:43:44 -08:00
|
|
|
/// Usually indicates that the node was interrupted with a more valuable block during
|
2021-03-01 14:57:37 -08:00
|
|
|
/// production and abandoned it for that more-favorable block. Leader sent data to indicate
|
|
|
|
/// the end of the block.
|
|
|
|
#[error("too few ticks")]
|
|
|
|
TooFewTicks,
|
|
|
|
|
|
|
|
/// Blocks can not have extra ticks
|
|
|
|
#[error("too many ticks")]
|
|
|
|
TooManyTicks,
|
2019-10-31 13:38:50 -07:00
|
|
|
|
|
|
|
/// All ticks must contain the same number of hashes within a block
|
2019-12-02 14:42:05 -08:00
|
|
|
#[error("invalid tick hash count")]
|
2019-10-31 13:38:50 -07:00
|
|
|
InvalidTickHashCount,
|
|
|
|
|
|
|
|
/// Blocks must end in a tick entry, trailing transaction entries are not allowed to guarantee
|
|
|
|
/// that each block has the same number of hashes
|
2019-12-02 14:42:05 -08:00
|
|
|
#[error("trailing entry")]
|
2019-10-31 13:38:50 -07:00
|
|
|
TrailingEntry,
|
2020-12-09 23:14:31 -08:00
|
|
|
|
|
|
|
#[error("duplicate block")]
|
|
|
|
DuplicateBlock,
|
2019-10-31 13:38:50 -07:00
|
|
|
}
|