forked from SOLES-io/EnergyChain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eecoin_data.go
50 lines (41 loc) · 785 Bytes
/
eecoin_data.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
package eecoin
import (
"bytes"
"github.com/tendermint/basecoin/types"
wire "github.com/tendermint/go-wire"
)
type EECoinState struct {
Bankers [][]byte
}
func (s *EECoinState) AddBanker(addr []byte) {
if !s.IsBanker(addr) {
s.Bankers = append(s.Bankers, addr)
}
}
func (s *EECoinState) RemoveBanker(addr []byte) {
b := s.Bankers
for i := range b {
if bytes.Equal(addr, b[i]) {
s.Bankers = append(b[:i], b[i+1:]...)
return
}
}
}
func (s *EECoinState) IsBanker(addr []byte) bool {
for _, b := range s.Bankers {
if bytes.Equal(b, addr) {
return true
}
}
return false
}
type EECoinTx struct {
Receivers []Receiver
}
type Receiver struct {
Addr []byte
Amount types.Coins
}
func (tx EECoinTx) Serialize() []byte {
return wire.BinaryBytes(tx)
}