-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherrors.go
More file actions
83 lines (60 loc) · 3.26 KB
/
errors.go
File metadata and controls
83 lines (60 loc) · 3.26 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package subtree
import "errors"
// Sentinel errors for the subtree package
// Range and bounds errors
var (
// ErrIndexOutOfRange is returned when an index is out of range
ErrIndexOutOfRange = errors.New("index out of range")
// ErrTxIndexOutOfBounds is returned when a transaction index is out of bounds
ErrTxIndexOutOfBounds = errors.New("transaction index out of bounds")
)
// Validation errors
var (
// ErrHeightNegative is returned when height is negative
ErrHeightNegative = errors.New("height must be at least 0")
// ErrNotPowerOfTwo is returned when the number of leaves must be a power of two
ErrNotPowerOfTwo = errors.New("numberOfLeaves must be a power of two")
// ErrSubtreeFull is returned when trying to add a node to a full subtree
ErrSubtreeFull = errors.New("subtree is full")
// ErrSubtreeNil is returned when the subtree is nil
ErrSubtreeNil = errors.New("subtree is nil")
// ErrSubtreeNotEmpty is returned when subtree should be empty before adding a coinbase node
ErrSubtreeNotEmpty = errors.New("subtree should be empty before adding a coinbase node")
// ErrSubtreeNodesEmpty is returned when subtree nodes slice is empty
ErrSubtreeNodesEmpty = errors.New("subtree nodes slice is empty")
// ErrNoSubtreesAvailable is returned when no subtrees are available
ErrNoSubtreesAvailable = errors.New("no subtrees available")
// ErrCoinbasePlaceholderMisuse is returned when coinbase placeholder node should be added with AddCoinbaseNode
ErrCoinbasePlaceholderMisuse = errors.New("coinbase placeholder node should be added with AddCoinbaseNode")
// ErrConflictingNodeNotInSubtree is returned when conflicting node is not in the subtree
ErrConflictingNodeNotInSubtree = errors.New("conflicting node is not in the subtree")
// ErrNodeNotFound is returned when a node is not found
ErrNodeNotFound = errors.New("node not found")
)
// Data mismatch errors
var (
// ErrParentTxHashesMismatch is returned when parent tx hashes and indexes length mismatch
ErrParentTxHashesMismatch = errors.New("parent tx hashes and indexes length mismatch")
// ErrTxHashMismatch is returned when transaction hash does not match subtree node hash
ErrTxHashMismatch = errors.New("transaction hash does not match subtree node hash")
// ErrSubtreeLengthMismatch is returned when subtree length does not match tx data length
ErrSubtreeLengthMismatch = errors.New("subtree length does not match tx data length")
)
// Serialization errors
var (
// ErrCannotSerializeSubtreeNotSet is returned when cannot serialize because subtree is not set
ErrCannotSerializeSubtreeNotSet = errors.New("cannot serialize, subtree is not set")
// ErrReadError is a generic read error for testing
ErrReadError = errors.New("read error")
// ErrTransactionNil is returned when a transaction is nil during serialization
ErrTransactionNil = errors.New("transaction is nil, cannot serialize")
// ErrTransactionWrite is returned when writing a transaction fails
ErrTransactionWrite = errors.New("error writing transaction")
// ErrTransactionRead is returned when reading a transaction fails
ErrTransactionRead = errors.New("error reading transaction")
)
// Mmap errors
var (
// ErrCapacityNotPositive is returned when mmap capacity is not positive
ErrCapacityNotPositive = errors.New("capacity must be positive")
)