1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Error types for postage operations.
use crate::BatchId;
use alloy_primitives::Address;
use thiserror::Error;
/// Errors that can occur when working with stamps.
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum StampError {
/// The owner recovered from the signature doesn't match the batch owner.
#[error("owner mismatch: expected {expected}, got {actual}")]
OwnerMismatch {
/// The expected owner address.
expected: Address,
/// The actual owner recovered from the signature.
actual: Address,
},
/// The stamp index exceeds the maximum allowed for the batch depth.
#[error("invalid index: index exceeds batch capacity")]
InvalidIndex,
/// The chunk address doesn't match the expected collision bucket.
#[error("bucket mismatch: chunk address doesn't belong to stamp bucket")]
BucketMismatch,
/// The batch was not found.
#[error("batch not found: {0}")]
BatchNotFound(BatchId),
/// The batch is not yet usable (needs more confirmations).
#[error(
"batch not usable: created at block {created}, current block {current}, need {threshold} confirmations"
)]
BatchNotUsable {
/// Block when batch was created.
created: u64,
/// Current block number.
current: u64,
/// Required confirmations.
threshold: u64,
},
/// The batch has expired.
#[error("batch expired: value {value} <= total_amount {total_amount}")]
BatchExpired {
/// Current batch value.
value: u128,
/// Total amount consumed.
total_amount: u128,
},
/// Invalid stamp data format.
#[error("invalid stamp data: {0}")]
InvalidData(&'static str),
/// The batch bucket is full and cannot accept more chunks.
#[error("bucket full: bucket {bucket} has reached capacity {capacity}")]
BucketFull {
/// The bucket that is full.
bucket: u32,
/// Maximum capacity of the bucket.
capacity: u32,
},
/// Signature verification failed.
#[error("invalid signature")]
InvalidSignature,
}