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 {
|
2020-01-14 17:15:26 -08:00
|
|
|
/// Block did not have enough ticks or was not marked full
|
|
|
|
#[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,
|
|
|
|
|
2019-10-31 13:38:50 -07:00
|
|
|
/// Blocks can not have extra ticks or missing ticks
|
2019-12-02 14:42:05 -08:00
|
|
|
#[error("invalid tick count")]
|
2019-10-31 13:38:50 -07:00
|
|
|
InvalidTickCount,
|
|
|
|
|
|
|
|
/// 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
|
|
|
}
|