-
Notifications
You must be signed in to change notification settings - Fork 251
/
global_consts.go
100 lines (75 loc) · 3.59 KB
/
global_consts.go
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package appconsts
import (
"math"
"github.com/celestiaorg/rsmt2d"
"github.com/tendermint/tendermint/pkg/consts"
)
// These constants were originally sourced from:
// https://github.com/celestiaorg/celestia-specs/blob/master/src/specs/consensus.md#constants
//
// They can not change throughout the lifetime of a network.
const (
// NamespaceVersionSize is the size of a namespace version in bytes.
NamespaceVersionSize = 1
// NamespaceVersionMaxValue is the maximum value a namespace version can be.
// This const must be updated if NamespaceVersionSize is changed.
NamespaceVersionMaxValue = math.MaxUint8
// NamespaceIDSize is the size of a namespace ID in bytes.
NamespaceIDSize = 28
// NamespaceSize is the size of a namespace (version + ID) in bytes.
NamespaceSize = NamespaceVersionSize + NamespaceIDSize
// ShareSize is the size of a share in bytes.
ShareSize = 512
// ShareInfoBytes is the number of bytes reserved for information. The info
// byte contains the share version and a sequence start idicator.
ShareInfoBytes = 1
// SequenceLenBytes is the number of bytes reserved for the sequence length
// that is present in the first share of a sequence.
SequenceLenBytes = 4
// ShareVersionZero is the first share version format.
ShareVersionZero = uint8(0)
// DefaultShareVersion is the defacto share version. Use this if you are
// unsure of which version to use.
DefaultShareVersion = ShareVersionZero
// CompactShareReservedBytes is the number of bytes reserved for the location of
// the first unit (transaction, ISR) in a compact share.
CompactShareReservedBytes = 4
// FirstCompactShareContentSize is the number of bytes usable for data in
// the first compact share of a sequence.
FirstCompactShareContentSize = ShareSize - NamespaceSize - ShareInfoBytes - SequenceLenBytes - CompactShareReservedBytes
// ContinuationCompactShareContentSize is the number of bytes usable for
// data in a continuation compact share of a sequence.
ContinuationCompactShareContentSize = ShareSize - NamespaceSize - ShareInfoBytes - CompactShareReservedBytes
// FirstSparseShareContentSize is the number of bytes usable for data in the
// first sparse share of a sequence.
FirstSparseShareContentSize = ShareSize - NamespaceSize - ShareInfoBytes - SequenceLenBytes
// ContinuationSparseShareContentSize is the number of bytes usable for data
// in a continuation sparse share of a sequence.
ContinuationSparseShareContentSize = ShareSize - NamespaceSize - ShareInfoBytes
// MinSquareSize is the smallest original square width.
MinSquareSize = 1
// MinshareCount is the minimum number of shares allowed in the original
// data square.
MinShareCount = MinSquareSize * MinSquareSize
// MaxShareVersion is the maximum value a share version can be.
MaxShareVersion = 127
// BondDenom defines the native staking denomination
BondDenom = "utia"
)
var (
// DataCommitmentBlocksLimit is the maximnum number of blocks that a data commitment can span
DataCommitmentBlocksLimit = consts.DataCommitmentBlocksLimit
// NewBaseHashFunc is the base hash function used by NMT. Change accordingly
// if another hash.Hash should be used as a base hasher in the NMT.
NewBaseHashFunc = consts.NewBaseHashFunc
// hashLength is the length of a hash in bytes.
hashLength = NewBaseHashFunc().Size()
// DefaultCodec is the default codec creator used for data erasure.
DefaultCodec = rsmt2d.NewLeoRSCodec
// SupportedShareVersions is a list of supported share versions.
SupportedShareVersions = []uint8{ShareVersionZero}
)
// HashLength returns the length of a hash in bytes.
func HashLength() int {
return hashLength
}