-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
66 lines (57 loc) · 1.53 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
package types
import (
"fmt"
"strings"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
/*
// Seed -
type Seed struct {
Height string `json:"height"`
SeedHashes []string `json:"seed_hashes"`
SealedSeedHashes []string `json:"sealed_seed_hashes"`
ValidatorPubKey string `jsong:"validator_pub_key"`
}
func (s Seed) String() string {
return strings.TrimSpace(fmt.Sprintf(`Height: %s
SeedHashes: %v
SealedSeedHashes: %v
ValidatorPubKey: %s
`, s.Height, s.SeedHashes, s.SealedSeedHashes, s.ValidatorPubKey))
}
*/
// Round -
type Round struct {
ID string `json:"id"`
Difficulty uint8 `json:"difficulty"`
Owner sdk.AccAddress `json:"owner"`
Nonce string `json:"nonce"`
NonceHash string `json:"nonce_hash"`
Targets []string `json:"targets"`
DepositCoin sdk.Coin `jsong:"deposit_coin"`
ScheduledTime time.Time `json:"scheduled_time"`
}
func (r Round) String() string {
timeString := r.ScheduledTime.Local()
return strings.TrimSpace(fmt.Sprintf(`Owner: %s
Difficulty: %d
Nonce: %s
NonceHash: %s
Targets: %v
DepositCoint: %s
ScheduledTime: %s
`, r.Owner, r.Difficulty, r.Nonce, r.NonceHash, r.Targets, r.DepositCoin, timeString.Format("2006-01-02 15:04:05 +0900")))
}
// Rounds -
type Rounds []*Round
// Nonce -
type Nonce struct {
Nonce string `json:"nonce"`
NonceHash string `json:"nonce_hash"`
}
func (n Nonce) String() string {
return strings.TrimSpace((fmt.Sprintf(`Nonce: %s
NonceHash: %s
`, n.Nonce, n.NonceHash)))
}