forked from celestiaorg/rsmt2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleopard.go
54 lines (40 loc) · 1.18 KB
/
leopard.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
//go:build leopard
// Note that if the build tag leopard is used, liblibleopard.a
// has to be present where the linker will find it.
// Otherwise go-leopard won't build.
package rsmt2d
import "github.com/celestiaorg/go-leopard"
var _ Codec = leoRSFF8Codec{}
var _ Codec = leoRSFF16Codec{}
func init() {
registerCodec(LeopardFF8, newLeoRSFF8Codec())
registerCodec(LeopardFF16, newLeoRSFF16Codec())
}
type leoRSFF8Codec struct{}
func (l leoRSFF8Codec) Encode(data [][]byte) ([][]byte, error) {
return leopard.Encode(data)
}
func (l leoRSFF8Codec) Decode(data [][]byte) ([][]byte, error) {
half := len(data) / 2
return leopard.Decode(data[:half], data[half:])
}
func (l leoRSFF8Codec) maxChunks() int {
return 128 * 128
}
func newLeoRSFF8Codec() leoRSFF8Codec {
return leoRSFF8Codec{}
}
type leoRSFF16Codec struct{}
func (leo leoRSFF16Codec) Encode(data [][]byte) ([][]byte, error) {
return leopard.Encode(data)
}
func (leo leoRSFF16Codec) Decode(data [][]byte) ([][]byte, error) {
half := len(data) / 2
return leopard.Decode(data[:half], data[half:])
}
func (leo leoRSFF16Codec) maxChunks() int {
return 32768 * 32768
}
func newLeoRSFF16Codec() leoRSFF16Codec {
return leoRSFF16Codec{}
}