/
client_state.go
124 lines (104 loc) · 3.64 KB
/
client_state.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package types
import (
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
)
var _ exported.ClientState = (*ClientState)(nil)
func (c ClientState) ClientType() string {
return ""
}
func (c ClientState) GetLatestHeight() exported.Height {
return c.LatestHeight
}
func (c ClientState) Validate() error {
return nil
}
func (c ClientState) Status(ctx sdk.Context, store storetypes.KVStore, cdc codec.BinaryCodec) exported.Status {
return exported.Active
}
func (c ClientState) ExportMetadata(store storetypes.KVStore) []exported.GenesisMetadata {
return []exported.GenesisMetadata{}
}
func (c ClientState) ZeroCustomFields() exported.ClientState {
return &c
}
func (c ClientState) GetTimestampAtHeight(
ctx sdk.Context,
clientStore storetypes.KVStore,
cdc codec.BinaryCodec,
height exported.Height,
) (uint64, error) {
return 0, nil
}
func (c ClientState) Initialize(context sdk.Context, marshaler codec.BinaryCodec, store storetypes.KVStore, state exported.ConsensusState) error {
return nil
}
func (c ClientState) VerifyMembership(
ctx sdk.Context,
clientStore storetypes.KVStore,
cdc codec.BinaryCodec,
height exported.Height,
delayTimePeriod uint64,
delayBlockPeriod uint64,
proof []byte,
path exported.Path,
value []byte,
) error {
return nil
}
func (c ClientState) VerifyNonMembership(
ctx sdk.Context,
clientStore storetypes.KVStore,
cdc codec.BinaryCodec,
height exported.Height,
delayTimePeriod uint64,
delayBlockPeriod uint64,
proof []byte,
path exported.Path,
) error {
return nil
}
// VerifyClientMessage must verify a ClientMessage. A ClientMessage could be a Header, Misbehaviour, or batch update.
// It must handle each type of ClientMessage appropriately. Calls to CheckForMisbehaviour, UpdateState, and UpdateStateOnMisbehaviour
// will assume that the content of the ClientMessage has been verified and can be trusted. An error should be returned
// if the ClientMessage fails to verify.
func (c ClientState) VerifyClientMessage(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) error {
return nil
}
func (c ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, msg exported.ClientMessage) bool {
return true
}
// UpdateStateOnMisbehaviour should perform appropriate state changes on a client state given that misbehaviour has been detected and verified
func (c ClientState) UpdateStateOnMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) {
}
func (c ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) []exported.Height {
return []exported.Height{c.LatestHeight}
}
func (c ClientState) CheckSubstituteAndUpdateState(
ctx sdk.Context, cdc codec.BinaryCodec, subjectClientStore,
substituteClientStore storetypes.KVStore, substituteClient exported.ClientState,
) error {
return nil
}
func (c ClientState) VerifyUpgradeAndUpdateState(
ctx sdk.Context,
cdc codec.BinaryCodec,
store storetypes.KVStore,
newClient exported.ClientState,
newConsState exported.ConsensusState,
proofUpgradeClient,
proofUpgradeConsState []byte,
) error {
return nil
}
// NewClientState creates a new ClientState instance.
func NewClientState(latestSequence uint64, consensusState *ConsensusState) *ClientState {
return &ClientState{
Data: []byte{0},
Checksum: []byte{},
LatestHeight: clienttypes.Height{},
}
}