-
Notifications
You must be signed in to change notification settings - Fork 30
/
signing_info.go
45 lines (40 loc) · 1.31 KB
/
signing_info.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
package types
import (
"fmt"
"time"
"github.com/Finschia/finschia-sdk/codec"
sdk "github.com/Finschia/finschia-sdk/types"
)
// NewValidatorSigningInfo creates a new ValidatorSigningInfo instance
//
//nolint:interfacer
func NewValidatorSigningInfo(
condAddr sdk.ConsAddress, startHeight, indexOffset int64,
jailedUntil time.Time, tombstoned bool, missedBlocksCounter int64,
) ValidatorSigningInfo {
return ValidatorSigningInfo{
Address: condAddr.String(),
StartHeight: startHeight,
IndexOffset: indexOffset,
JailedUntil: jailedUntil,
Tombstoned: tombstoned,
MissedBlocksCounter: missedBlocksCounter,
}
}
// String implements the stringer interface for ValidatorSigningInfo
func (i ValidatorSigningInfo) String() string {
return fmt.Sprintf(`Validator Signing Info:
Address: %s
Start Height: %d
Index Offset: %d
Jailed Until: %v
Tombstoned: %t
Missed Blocks Counter: %d`,
i.Address, i.StartHeight, i.IndexOffset, i.JailedUntil,
i.Tombstoned, i.MissedBlocksCounter)
}
// unmarshal a validator signing info from a store value
func UnmarshalValSigningInfo(cdc codec.Codec, value []byte) (signingInfo ValidatorSigningInfo, err error) {
err = cdc.Unmarshal(value, &signingInfo)
return signingInfo, err
}