-
Notifications
You must be signed in to change notification settings - Fork 203
/
types.go
82 lines (69 loc) · 2.22 KB
/
types.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
// Copyright (C) 2017 go-nebulas authors
//
// This file is part of the go-nebulas library.
//
// the go-nebulas library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// the go-nebulas library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with the go-nebulas library. If not, see <http://www.gnu.org/licenses/>.
//
package dip
import (
"encoding/json"
"errors"
"github.com/nebulasio/go-nebulas/core"
"github.com/nebulasio/go-nebulas/neblet/pb"
)
// Error types
var (
ErrDipNotFound = errors.New("dip not found")
ErrInvalidDipAddress = errors.New("invalid dip reward address")
ErrUnsupportedTransactionFromDipAddress = errors.New("unsupported transaction from dip address")
)
// const types
const (
CacheSize = 128
// DipRewardAddressPrivate dip reward rewardAddress:n1c6y4ctkMeZk624QWBTXuywmNpCWmJZiBq
DipRewardAddressPrivate = "42f0c8b5feb72301619046ca87e6cf2c605e94dae0e24c9cb3a0101dbb60337c"
// DipRewardAddressPassphrase
DipRewardAddressPassphrase = "passphrase"
)
type Neblet interface {
Config() *nebletpb.Config
AccountManager() core.AccountManager
BlockChain() *core.BlockChain
}
type DipReward struct {
DipRewards []string `json:"dip_rewards"`
}
type DIPItem struct {
Address string `json:"address"`
Contract string `json:"contract"`
Reward string `json:"reward"`
}
type DIPData struct {
StartHeight uint64 `json:"start_height,string"`
EndHeight uint64 `json:"end_height,string"`
Version uint64 `json:"version,string"`
Dips []*DIPItem `json:"dips"`
Err string `json:"err"`
}
// ToBytes serialize data
func (d *DIPData) ToBytes() ([]byte, error) {
return json.Marshal(d)
}
// FromBytes
func (d *DIPData) FromBytes(data []byte) error {
if err := json.Unmarshal(data, d); err != nil {
return err
}
return nil
}