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.60 Kb · 40 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//
33// It mirrors the Union (Rust) ClientCreationResult{client_state: Option, ...}.
34// An empty ClientStateBytes means the client state was not overwritten during
35// creation. CometBLS performs no creation-time validation and writes nothing,
36// so its result is empty; the type is kept for symmetry with other clients.
37type ClientCreationResult struct {
38	ClientStateBytes []byte
39	StorageWrites    map[string][]byte
40}