keeper

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper defines the TIBC packet keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec, key storetypes.StoreKey,
	clientKeeper types.ClientKeeper,
	routingKeeper types.RoutingKeeper,
) Keeper

NewKeeper creates a new tibc packet Keeper instance

func (Keeper) AcknowledgePacket

func (k Keeper) AcknowledgePacket(
	ctx sdk.Context,
	packet exported.PacketI,
	acknowledgement []byte,
	proof []byte,
	proofHeight exported.Height,
) error

AcknowledgePacket is called by a module to process the acknowledgement of a packet previously sent by the calling module on a port to a counterparty module on the counterparty chain. Its intended usage is within the ante handler. AcknowledgePacket will clean up the packet commitment, which is no longer necessary since the packet has been received and acted upon.

func (Keeper) CleanPacket

func (k Keeper) CleanPacket(ctx sdk.Context, cleanPacket exported.CleanPacketI) error

CleanPacket is called by users to send an TIBC clean packet to clean ack and receipt whose sequence smaller than the sequence in clean packet.

func (Keeper) CleanPacketCommitment added in v0.2.0

CleanPacketCommitment implements the Query/PacketCommitment gRPC method

func (Keeper) GetAllPacketAckSeqs

func (k Keeper) GetAllPacketAckSeqs(ctx sdk.Context) (seqs []types.PacketSequence)

GetAllPacketAckSeqs returns all stored next acknowledgements sequences.

func (Keeper) GetAllPacketAcks

func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketState)

GetAllPacketAcks returns all stored PacketAcknowledgements objects.

func (Keeper) GetAllPacketCommitments

func (k Keeper) GetAllPacketCommitments(ctx sdk.Context) (commitments []types.PacketState)

GetAllPacketCommitments returns all stored PacketCommitments objects.

func (Keeper) GetAllPacketCommitmentsAtChannel

func (k Keeper) GetAllPacketCommitmentsAtChannel(
	ctx sdk.Context,
	sourceChain, destChain string,
) (commitments []types.PacketState)

GetAllPacketCommitmentsAtChannel returns all stored PacketCommitments objects for a specified port ID and channel ID.

func (Keeper) GetAllPacketReceipts

func (k Keeper) GetAllPacketReceipts(ctx sdk.Context) (receipts []types.PacketState)

GetAllPacketReceipts returns all stored PacketReceipt objects.

func (Keeper) GetAllPacketRecvSeqs

func (k Keeper) GetAllPacketRecvSeqs(ctx sdk.Context) (seqs []types.PacketSequence)

GetAllPacketRecvSeqs returns all stored next recv sequences.

func (Keeper) GetAllPacketSendSeqs

func (k Keeper) GetAllPacketSendSeqs(ctx sdk.Context) (seqs []types.PacketSequence)

GetAllPacketSendSeqs returns all stored next send sequences.

func (Keeper) GetCleanPacketCommitment

func (k Keeper) GetCleanPacketCommitment(ctx sdk.Context, sourceChain, destChain string) []byte

GetCleanPacketCommitment gets the packet commitment hash from the store

func (Keeper) GetMaxAckSequence added in v0.2.0

func (k Keeper) GetMaxAckSequence(ctx sdk.Context, sourceChain, destChain string) uint64

GetMaxAckSequence gets the max ack height from the store

func (Keeper) GetNextSequenceSend

func (k Keeper) GetNextSequenceSend(ctx sdk.Context, sourceChain, destChain string) uint64

GetNextSequenceSend gets a channel's next send sequence from the store

func (Keeper) GetPacketAcknowledgement

func (k Keeper) GetPacketAcknowledgement(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
) ([]byte, bool)

GetPacketAcknowledgement gets the packet ack hash from the store

func (Keeper) GetPacketCommitment

func (k Keeper) GetPacketCommitment(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
) []byte

GetPacketCommitment gets the packet commitment hash from the store

func (Keeper) GetPacketReceipt

func (k Keeper) GetPacketReceipt(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
) (string, bool)

GetPacketReceipt gets a packet receipt from the store

func (Keeper) HasPacketAcknowledgement

func (k Keeper) HasPacketAcknowledgement(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
) bool

HasPacketAcknowledgement check if the packet ack hash is already on the store

func (Keeper) HasPacketCommitment

func (k Keeper) HasPacketCommitment(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
) bool

HasPacketCommitment returns true if the packet commitment exists

func (Keeper) HasPacketReceipt

func (k Keeper) HasPacketReceipt(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
) bool

HasPacketAcknowledgement check if the packet ack hash is already on the store

func (Keeper) IteratePacketAcknowledgement

func (k Keeper) IteratePacketAcknowledgement(
	ctx sdk.Context,
	cb func(sourceChain, destChain string, sequence uint64, hash []byte) bool,
)

IteratePacketAcknowledgement provides an iterator over all PacketAcknowledgement objects. For each acknowledgement, cb will be called. If the cb returns true, the iterator will close and stop.

func (Keeper) IteratePacketCommitment

func (k Keeper) IteratePacketCommitment(
	ctx sdk.Context,
	cb func(sourceChain, destChain string, sequence uint64, hash []byte) bool,
)

IteratePacketCommitment provides an iterator over all PacketCommitment objects. For each packet commitment, cb will be called. If the cb returns true, the iterator will close and stop.

func (Keeper) IteratePacketCommitmentAtChannel

func (k Keeper) IteratePacketCommitmentAtChannel(
	ctx sdk.Context,
	sourceChain, destChain string,
	cb func(_, _ string, sequence uint64, hash []byte) bool,
)

IteratePacketCommitmentAtChannel provides an iterator over all PacketCommmitment objects at a specified channel. For each packet commitment, cb will be called. If the cb returns true, the iterator will close and stop.

func (Keeper) IteratePacketReceipt

func (k Keeper) IteratePacketReceipt(
	ctx sdk.Context,
	cb func(sourceChain, destChain string, sequence uint64, receipt []byte) bool,
)

IteratePacketReceipt provides an iterator over all PacketReceipt objects. For each receipt, cb will be called. If the cb returns true, the iterator will close and stop.

func (Keeper) IteratePacketSequence

func (k Keeper) IteratePacketSequence(
	ctx sdk.Context,
	iterator db.Iterator,
	cb func(sourceChain, destChain string, sequence uint64) bool,
)

IteratePacketSequence provides an iterator over all send, receive or ack sequences. For each sequence, cb will be called. If the cb returns true, the iterator will close and stop.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) PacketAcknowledgement

PacketAcknowledgement implements the Query/PacketAcknowledgement gRPC method

func (Keeper) PacketAcknowledgements

PacketAcknowledgements implements the Query/PacketAcknowledgements gRPC method

func (Keeper) PacketCommitment

PacketCommitment implements the Query/PacketCommitment gRPC method

func (Keeper) PacketCommitments

PacketCommitments implements the Query/PacketCommitments gRPC method

func (Keeper) PacketReceipt

PacketReceipt implements the Query/PacketReceipt gRPC method

func (Keeper) RecvCleanPacket

func (k Keeper) RecvCleanPacket(
	ctx sdk.Context,
	cleanPacket exported.CleanPacketI,
	proof []byte,
	proofHeight exported.Height,
) error

RecvCleanPacket is called by relayer to receive & process an TIBC clean packet sent on the counterparty chain.

func (Keeper) RecvPacket

func (k Keeper) RecvPacket(
	ctx sdk.Context,
	packet exported.PacketI,
	proof []byte,
	proofHeight exported.Height,
) error

RecvPacket is called by a module to receive & process an TIBC packet sent on the corresponding port on the counterparty chain.

func (Keeper) SendPacket

func (k Keeper) SendPacket(ctx sdk.Context, packet exported.PacketI) error

SendPacket is called by a module to send an TIBC packet on a port owned by the calling module to the corresponding module on the counterparty chain.

func (Keeper) SetCleanPacketCommitment

func (k Keeper) SetCleanPacketCommitment(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
)

SetCleanPacketCommitment sets the packet commitment hash to the store

func (Keeper) SetMaxAckSequence added in v0.2.0

func (k Keeper) SetMaxAckSequence(ctx sdk.Context, sourceChain, destChain string, sequence uint64)

SetMaxAckSequence sets the max ack height to the store

func (Keeper) SetNextSequenceSend

func (k Keeper) SetNextSequenceSend(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
)

SetNextSequenceSend sets a channel's next send sequence to the store

func (Keeper) SetPacketAcknowledgement

func (k Keeper) SetPacketAcknowledgement(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
	ackHash []byte,
)

SetPacketAcknowledgement sets the packet ack hash to the store

func (Keeper) SetPacketCommitment

func (k Keeper) SetPacketCommitment(
	ctx sdk.Context,
	sourceChain, destChain string,
	sequence uint64,
	commitmentHash []byte,
)

SetPacketCommitment sets the packet commitment hash to the store

func (Keeper) SetPacketReceipt

func (k Keeper) SetPacketReceipt(ctx sdk.Context, sourceChain, destChain string, sequence uint64)

SetPacketReceipt sets an empty packet receipt to the store

func (Keeper) UnreceivedAcks

UnreceivedAcks implements the Query/UnreceivedAcks gRPC method. Given a list of counterparty packet acknowledgements, the querier checks if the packet has already been received by checking if the packet commitment still exists on this chain (original sender) for the packet sequence. All acknowledgmeents that haven't been received yet are returned in the response. Usage: To use this method correctly, first query all packet acknowledgements on the original receiving chain (ie the chain that wrote the acks) using the Query/PacketAcknowledgements gRPC method. Then input the returned sequences into the QueryUnreceivedAcksRequest and send the request to this Query/UnreceivedAcks on the **original sending** chain. This gRPC method will then return the list of packet sequences whose acknowledgements are already written on the receiving chain but haven't yet been received back to the sending chain.

NOTE: The querier makes the assumption that the provided list of packet acknowledgements is correct and will not function properly if the list is not up to date. Ideally the query height should equal the latest height on the counterparty's client which represents this chain.

func (Keeper) UnreceivedPackets

UnreceivedPackets implements the Query/UnreceivedPackets gRPC method. Given a list of counterparty packet commitments, the querier checks if the packet has already been received by checking if a receipt exists on this chain for the packet sequence. All packets that haven't been received yet are returned in the response Usage: To use this method correctly, first query all packet commitments on the sending chain using the Query/PacketCommitments gRPC method. Then input the returned sequences into the QueryUnreceivedPacketsRequest and send the request to this Query/UnreceivedPackets on the **receiving** chain. This gRPC method will then return the list of packet sequences that are yet to be received on the receiving chain.

NOTE: The querier makes the assumption that the provided list of packet commitments is correct and will not function properly if the list is not up to date. Ideally the query height should equal the latest height on the counterparty's client which represents this chain.

func (Keeper) ValidateCleanPacket

func (k Keeper) ValidateCleanPacket(ctx sdk.Context, cleanPacket exported.CleanPacketI) error

ValidateCleanPacket validates clean packet legal or not

func (Keeper) ValidatePacket added in v0.2.0

func (k Keeper) ValidatePacket(ctx sdk.Context, packet exported.PacketI) error

ValidatePacket validates packet sequence

func (Keeper) WriteAcknowledgement

func (k Keeper) WriteAcknowledgement(
	ctx sdk.Context,
	packet exported.PacketI,
	acknowledgement []byte,
) error

WriteAcknowledgement writes the packet execution acknowledgement to the state, which will be verified by the counterparty chain using AcknowledgePacket.

CONTRACT:

1) For synchronous execution, this function is be called in the TIBC handler . For async handling, it needs to be called directly by the module which originally processed the packet.

2) Assumes that packet receipt has been written. previously by RecvPacket.

Jump to

Keyboard shortcuts

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