lightclient

package
v1.0.8-0...-01620ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ProofOpMultiStore = "multistore"

the multi-store proof operation constant value

Variables

This section is empty.

Functions

func DefaultProofRuntime

func DefaultProofRuntime() (prt *merkle.ProofRuntime)

XXX: This should be managed by the rootMultiStore which may want to register more proof ops?

func MultiStoreProofOpDecoder

func MultiStoreProofOpDecoder(pop merkle.ProofOp) (merkle.ProofOperator, error)

MultiStoreProofOpDecoder returns a multi-store merkle proof operator from a given proof operation.

func QueryKeyWithProof

func QueryKeyWithProof(node rpcclient.Client, key []byte, storeName string, height int64) ([]byte, []byte, []byte, error)

func RequireProof

func RequireProof(subpath string) bool

RequireProof return whether proof is require for the subpath

Types

type Codec

type Codec = amino.Codec
var Cdc *Codec

type CommitID

type CommitID struct {
	Version int64
	Hash    []byte
}

CommitID contains the tree version number and its merkle root.

func (CommitID) IsZero

func (cid CommitID) IsZero() bool

func (CommitID) String

func (cid CommitID) String() string

type CommitInfo

type CommitInfo struct {

	// Version
	Version int64

	// Store info for
	StoreInfos []StoreInfo
}

NOTE: Keep CommitInfo a simple immutable struct.

func (CommitInfo) CommitID

func (ci CommitInfo) CommitID() CommitID

func (CommitInfo) Hash

func (ci CommitInfo) Hash() []byte

Hash returns the simple merkle root hash of the stores sorted by name.

type ConsensusState

type ConsensusState struct {
	ChainID             string
	Height              uint64
	AppHash             []byte
	CurValidatorSetHash []byte
	NextValidatorSet    *tmtypes.ValidatorSet
}

func DecodeConsensusState

func DecodeConsensusState(input []byte) (ConsensusState, error)

input: | chainID | height | appHash | curValidatorSetHash | [{validator pubkey, voting power}] | | 32 bytes | 8 bytes | 32 bytes | 32 bytes | [{32 bytes, 8 bytes}] |

func GetInitConsensusState

func GetInitConsensusState(node rpcclient.Client, height int64) (*ConsensusState, error)

func (*ConsensusState) ApplyHeader

func (cs *ConsensusState) ApplyHeader(header *Header) (bool, error)

func (ConsensusState) EncodeConsensusState

func (cs ConsensusState) EncodeConsensusState() ([]byte, error)

output: | chainID | height | appHash | curValidatorSetHash | [{validator pubkey, voting power}] | | 32 bytes | 8 bytes | 32 bytes | 32 bytes | [{32 bytes, 8 bytes}] |

type Header struct {
	tmtypes.SignedHeader
	ValidatorSet     *tmtypes.ValidatorSet `json:"validator_set"`
	NextValidatorSet *tmtypes.ValidatorSet `json:"next_validator_set"`
}

func DecodeHeader

func DecodeHeader(input []byte) (*Header, error)

func QueryTendermintHeader

func QueryTendermintHeader(node rpcclient.Client, height int64) (*Header, error)

func (*Header) EncodeHeader

func (h *Header) EncodeHeader() ([]byte, error)

func (*Header) Validate

func (h *Header) Validate(chainID string) error

type KeyValueMerkleProof

type KeyValueMerkleProof struct {
	Key       []byte
	Value     []byte
	StoreName string
	AppHash   []byte
	Proof     *merkle.Proof
}

func DecodeKeyValueMerkleProof

func DecodeKeyValueMerkleProof(input []byte) (*KeyValueMerkleProof, error)

input: | storeName | key length | key | value length | value | appHash | proof | | 32 bytes | 32 bytes | | 32 bytes | | 32 bytes | |

func (*KeyValueMerkleProof) Validate

func (kvmp *KeyValueMerkleProof) Validate() bool

type MultiStoreProof

type MultiStoreProof struct {
	StoreInfos []StoreInfo
}

MultiStoreProof defines a collection of store proofs in a multi-store

func NewMultiStoreProof

func NewMultiStoreProof(storeInfos []StoreInfo) *MultiStoreProof

func (*MultiStoreProof) ComputeRootHash

func (proof *MultiStoreProof) ComputeRootHash() []byte

ComputeRootHash returns the root hash for a given multi-store proof.

type MultiStoreProofOp

type MultiStoreProofOp struct {

	// To encode in ProofOp.Data.
	Proof *MultiStoreProof `json:"proof"`
	// contains filtered or unexported fields
}

TODO: document

func NewMultiStoreProofOp

func NewMultiStoreProofOp(key []byte, proof *MultiStoreProof) MultiStoreProofOp

func (MultiStoreProofOp) GetKey

func (op MultiStoreProofOp) GetKey() []byte

GetKey returns the key for a multi-store proof operation.

func (MultiStoreProofOp) ProofOp

func (op MultiStoreProofOp) ProofOp() merkle.ProofOp

ProofOp return a merkle proof operation from a given multi-store proof operation.

func (MultiStoreProofOp) Run

func (op MultiStoreProofOp) Run(args [][]byte) ([][]byte, error)

Run executes a multi-store proof operation for a given value. It returns the root hash if the value matches all the store's commitID's hash or an error otherwise.

func (MultiStoreProofOp) String

func (op MultiStoreProofOp) String() string

String implements the Stringer interface for a mult-store proof operation.

type StoreCore

type StoreCore struct {
	// StoreType StoreType
	CommitID CommitID
}

type StoreInfo

type StoreInfo struct {
	Name string
	Core StoreCore
}

StoreInfo contains the name and core reference for an underlying store. It is the leaf of the rootMultiStores top level simple merkle tree.

func (StoreInfo) Hash

func (si StoreInfo) Hash() []byte

Implements merkle.Hasher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL