forked from ChainSafe/chainbridge-substrate-events
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtypes.go
37 lines (30 loc) · 763 Bytes
/
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
package events
import (
"fmt"
"github.com/Phala-Network/go-substrate-rpc-client/v3/types"
"github.com/vedhavyas/go-subkey/scale"
)
type BlockRewardInfo struct {
Seed types.U256 `json:"seed"`
OnlineTarget types.U256 `json:"onlineTarget"`
ComputeTarget types.U256 `json:"computeTarget"`
}
type PayoutReason byte
const (
OnlineReward PayoutReason = 0
ComputeReward PayoutReason = 1
)
func (v *PayoutReason) Decode(decoder scale.Decoder) error {
b, err := decoder.ReadOneByte()
vb := PayoutReason(b)
switch vb {
case OnlineReward, ComputeReward:
*v = vb
default:
return fmt.Errorf("unknown VoteThreshold enum: %v", vb)
}
return err
}
func (v PayoutReason) Encode(encoder scale.Encoder) error {
return encoder.PushByte(byte(v))
}