Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

lightclient.gno

1.51 Kb · 38 lines
 1package types
 2
 3// ClientState is the marker interface a light client's client-state satisfies.
 4// Concrete client states (e.g. cometbls.ClientState) implement it so the
 5// lightclient.Interface can return them opaquely; callers downcast as needed.
 6type ClientState interface {
 7	ClientType() string
 8}
 9
10// Header is the marker interface for a light client update message — either a
11// header or a misbehaviour. Concrete update messages implement it so the
12// lightclient.Interface can accept them opaquely; the client downcasts to its
13// own concrete type.
14type Header interface {
15	ClientType() string
16}
17
18// StateUpdate is the result of a successful lightclient.Interface.VerifyHeader.
19//
20// It mirrors the Union (Rust) StateUpdate{height, client_state: Option,
21// consensus_state}. The field shape matches ConsensusStateUpdate so the caller
22// can persist it the same way. An empty ClientStateBytes means the client state
23// did not change as part of this update (Rust's None client_state).
24type StateUpdate struct {
25	Height              uint64
26	ConsensusStateBytes []byte
27	ClientStateBytes    []byte
28	StorageWrites       map[string][]byte
29}
30
31// ClientCreationResult is the result of lightclient.Interface.VerifyCreation,
32// mirroring Union's ClientCreationResult{client_state: Option, ...}. Empty
33// ClientStateBytes means state wasn't overwritten (e.g. CometBLS never
34// overwrites, though it may still validate input via ClientState.Validate).
35type ClientCreationResult struct {
36	ClientStateBytes []byte
37	StorageWrites    map[string][]byte
38}