forked from elastos/Elastos.ELA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coinbase.go
38 lines (29 loc) · 790 Bytes
/
coinbase.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
// Copyright (c) 2017-2019 The Elastos Foundation
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
//
package payload
import (
"io"
"github.com/elastos/Elastos.ELA/common"
)
const (
// MaxPayloadDataSize is the maximum allowed length of payload data.
MaxPayloadDataSize = 1024 * 1024 // 1MB
)
const CoinBaseVersion byte = 0x04
type CoinBase struct {
Content []byte
}
func (a *CoinBase) Data(version byte) []byte {
return a.Content
}
func (a *CoinBase) Serialize(w io.Writer, version byte) error {
return common.WriteVarBytes(w, a.Content)
}
func (a *CoinBase) Deserialize(r io.Reader, version byte) error {
temp, err := common.ReadVarBytes(r, MaxPayloadDataSize,
"payload coinbase data")
a.Content = temp
return err
}