host

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 7 Imported by: 21

Documentation

Index

Constants

View Source
const (
	// ModuleName is the name of the TIBC module
	ModuleName = "tibc"

	// StoreKey is the string store representation
	StoreKey string = ModuleName

	// QuerierRoute is the querier route for the TIBC module
	QuerierRoute string = ModuleName

	// RouterKey is the msg router key for the TIBC module
	RouterKey string = ModuleName
)
View Source
const (
	KeyClientState                 = "clientState"
	KeyConsensusStatePrefix        = "consensusStates"
	KeyPortPrefix                  = "ports"
	KeySequencePrefix              = "sequences"
	KeyNextSeqSendPrefix           = "nextSequenceSend"
	KeyNextSeqRecvPrefix           = "nextSequenceRecv"
	KeyNextSeqAckPrefix            = "nextSequenceAck"
	KeyPacketCommitmentPrefix      = "commitments"
	KeyPacketAckPrefix             = "acks"
	KeyPacketReceiptPrefix         = "receipts"
	KeyCleanPacketCommitmentPrefix = "clean"
)

KVStore key prefixes for TIBC

View Source
const DefaultMaxCharacterLength = 64

DefaultMaxCharacterLength defines the default maximum character length used in validation of identifiers including the client, connection, port and channel identifiers.

NOTE: this restriction is specific to this golang implementation of TIBC. If your use case demands a higher limit, please open an issue and we will consider adjusting this restriction.

View Source
const SubModuleName = "host"

SubModuleName defines the TICS 24 host

Variables

View Source
var (
	ErrInvalidID     = sdkerrors.Register(moduleName, 2, "invalid identifier")
	ErrInvalidPath   = sdkerrors.Register(moduleName, 3, "invalid path")
	ErrInvalidPacket = sdkerrors.Register(moduleName, 4, "invalid packet")
	ErrInvalidRule   = sdkerrors.Register(moduleName, 5, "invalid routing rule")
)

TIBC client sentinel errors

View Source
var IsValidID = regexp.MustCompile(`^[a-zA-Z0-9\.\_\+\-\#\[\]\<\>]+$`).MatchString

IsValidID defines regular expression to check if the string consist of characters in one of the following categories only: - Alphanumeric - `.`, `_`, `+`, `-`, `#` - `[`, `]`, `<`, `>`

View Source
var IsValidRule = regexp.MustCompile(`^(([a-zA-Z0-9\.\_\+\-\#\[\]\<\>]{1,64}|[*]),){2}([a-zA-Z0-9\.\_\+\-\#\[\]\<\>]{1,64}|[*])$`).MatchString
View Source
var (
	KeyClientStorePrefix = []byte("clients")
)

KVStore key prefixes for TIBC

Functions

func CleanPacketCommitmentKey

func CleanPacketCommitmentKey(sourceChain, destinationChain string) []byte

CleanPacketCommitmentKey returns the store key of under which a clean packet commitment is stored

func CleanPacketCommitmentPath

func CleanPacketCommitmentPath(sourceChain, destinationChain string) string

CleanPacketCommitmentPath defines the path for commitments to clean packet data fields store path.

func ClientIdentifierValidator

func ClientIdentifierValidator(id string) error

ClientIdentifierValidator is the default validator function for Client identifiers. A valid Identifier must be between 9-64 characters and only contain alphanumeric and some allowed special characters (see IsValidID).

func ClientStateKey

func ClientStateKey() []byte

ClientStateKey returns a store key under which a particular client state is stored in a client prefixed store

func ConsensusStateKey

func ConsensusStateKey(height exported.Height) (key []byte)

ConsensusStateKey returns the store key for a the consensus state of a particular client stored in a client prefixed store.

func ConsensusStatePath

func ConsensusStatePath(height exported.Height) string

ConsensusStatePath returns the suffix store key for the consensus state at a particular height stored in a client prefixed store.

func DestChainValidator

func DestChainValidator(id string) error

ChannelIdentifierValidator is the default validator function for Channel identifiers. A valid Identifier must be between 8-64 characters and only contain alphanumeric and some allowed special characters (see IsValidID).

func FullClientKey

func FullClientKey(chainName string, path []byte) []byte

FullClientKey returns the full path of specific client path in the format: "clients/{chainName}/{path}" as a byte array.

func FullClientPath

func FullClientPath(chainName string, path string) string

FullClientPath returns the full path of a specific client path in the format: "clients/{chainName}/{path}" as a string.

func FullClientStateKey

func FullClientStateKey(chainName string) []byte

FullClientStateKey takes a client identifier and returns a Key under which to store a particular client state.

func FullClientStatePath

func FullClientStatePath(chainName string) string

FullClientStatePath takes a client identifier and returns a Path under which to store a particular client state

func FullConsensusStateKey

func FullConsensusStateKey(chainName string, height exported.Height) (key []byte)

FullConsensusStateKey returns the store key for the consensus state of a particular client.

func FullConsensusStatePath

func FullConsensusStatePath(chainName string, height exported.Height) string

FullConsensusStatePath takes a client identifier and returns a Path under which to store the consensus state of a client.

func MaxAckSeqKey added in v0.2.0

func MaxAckSeqKey(sourceChain, destinationChain string) []byte

MaxAckHeightKey returns the store key of current max ack height is stored

func MaxAckSeqPath added in v0.2.0

func MaxAckSeqPath(sourceChain, destinationChain string) string

MaxAckHeightPath defines the path of current max ack height

func NextSequenceSendKey

func NextSequenceSendKey(sourceChain, destChain string) []byte

NextSequenceSendKey returns the store key for the send sequence of a particular channel binded to a specific port.

func NextSequenceSendPath

func NextSequenceSendPath(sourceChain, destChain string) string

NextSequenceSendPath defines the next send sequence counter store path

func PacketAcknowledgementKey

func PacketAcknowledgementKey(sourceChain, destinationChain string, sequence uint64) []byte

PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored

func PacketAcknowledgementPath

func PacketAcknowledgementPath(sourceChain, destinationChain string, sequence uint64) string

PacketAcknowledgementPath defines the packet acknowledgement store path

func PacketAcknowledgementPrefixPath

func PacketAcknowledgementPrefixPath(sourceChain, destinationChain string) string

PacketAcknowledgementPrefixPath defines the prefix for commitments to packet data fields store path.

func PacketCommitmentKey

func PacketCommitmentKey(sourceChain, destinationChain string, sequence uint64) []byte

PacketCommitmentKey returns the store key of under which a packet commitment is stored

func PacketCommitmentPath

func PacketCommitmentPath(sourceChain, destinationChain string, sequence uint64) string

PacketCommitmentPath defines the commitments to packet data fields store path

func PacketCommitmentPrefixPath

func PacketCommitmentPrefixPath(sourceChain, destinationChain string) string

PacketCommitmentPrefixPath defines the prefix for commitments to packet data fields store path.

func PacketReceiptKey

func PacketReceiptKey(sourceChain, destinationChain string, sequence uint64) []byte

PacketReceiptKey returns the store key of under which a packet receipt is stored

func PacketReceiptPath

func PacketReceiptPath(sourceChain, destinationChain string, sequence uint64) string

PacketReceiptPath defines the packet receipt store path

func PacketReceiptPrefixPath

func PacketReceiptPrefixPath(sourceChain, destinationChain string) string

PacketReceiptKey returns the store key of under which a packet receipt is stored

func ParseChannelPath

func ParseChannelPath(path string) (string, string, error)

ParseChannelPath returns the port and channel ID from a full path. It returns an error if the provided path is invalid.

func ParseIdentifier

func ParseIdentifier(identifier, prefix string) (uint64, error)

ParseIdentifier parses the sequence from the identifier using the provided prefix. This function does not need to be used by counterparty chains. SDK generated connection and channel identifiers are required to use this format.

func RoutingRulesKey added in v0.2.0

func RoutingRulesKey() []byte

RoutingRulesKey defines the routing rules store key

func RoutingRulesPath added in v0.2.0

func RoutingRulesPath() string

RoutingRulesPath defines the routing rules store path

func RoutingRulesValidator added in v0.2.0

func RoutingRulesValidator(rules []string) error

RoutingRulesValidator is the default validator function for routing rules. A valid rule must contain two dot.

func SourceChainValidator

func SourceChainValidator(id string) error

SourceChainValidator is the default validator function for SourceChain name. A valid Identifier must be between 2-64 characters and only contain alphanumeric and some allowed special characters (see IsValidID).

Types

type ValidateFn

type ValidateFn func(string) error

ValidateFn function type to validate path and identifier bytestrings

func NewPathValidator

func NewPathValidator(idValidator ValidateFn) ValidateFn

NewPathValidator takes in a Identifier Validator function and returns a Path Validator function which requires path to consist of `/`-separated valid identifiers, where a valid identifier is between 1-64 characters, contains only alphanumeric and some allowed special characters (see IsValidID), and satisfies the custom `idValidator` function.

Jump to

Keyboard shortcuts

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