forked from gitchain/gitchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bat.go
51 lines (39 loc) · 948 Bytes
/
bat.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
//// Block Allocation Transaction (BAT)
package transaction
import (
"encoding/gob"
"encoding/json"
"github.com/gitchain/gitchain/types"
)
func init() {
gob.Register(&BlockAttribution{})
}
//// Block Allocation Transaction (BAT)
const (
BLOCK_ATTRIBUTION_VERSION = 1
)
type BlockAttribution struct {
Version uint32
}
func (tx *BlockAttribution) MarshalJSON() ([]byte, error) {
return json.Marshal(map[string]interface{}{
"Type": "Block Attribution Tranasction",
"Version": tx.Version,
})
}
func NewBlockAttribution() (*BlockAttribution, error) {
return &BlockAttribution{
Version: BLOCK_ATTRIBUTION_VERSION}, nil
}
func (txn *BlockAttribution) Valid() bool {
return (txn.Version == BLOCK_ATTRIBUTION_VERSION)
}
func (txn *BlockAttribution) Encode() ([]byte, error) {
return encode(txn)
}
func (txn *BlockAttribution) Hash() types.Hash {
return hash(txn)
}
func (*BlockAttribution) String() string {
return "BAT"
}