Skip to content

Commit

Permalink
channel: store virtual packet
Browse files Browse the repository at this point in the history
  • Loading branch information
nicopernas committed Apr 30, 2024
1 parent a485548 commit f204504
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions modules/core/04-channel/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,20 @@ func (k Keeper) deletePacketCommitment(ctx sdk.Context, portID, channelID string
store.Delete(host.PacketCommitmentKey(portID, channelID, sequence))
}

func (k Keeper) SetVirtualPacket(ctx sdk.Context, portID, channelID string, sequence uint64, packet types.Packet) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&packet)
func (k Keeper) SetVirtualPacket(ctx sdk.Context, portID, channelID string, sequence uint64, packet exported.PacketI) {
timeoutHeight := packet.GetTimeoutHeight()
p := types.NewPacket(
packet.GetData(),
packet.GetSequence(),
packet.GetSourcePort(),
packet.GetSourceChannel(),
packet.GetDestPort(),
packet.GetDestChannel(),
clienttypes.NewHeight(timeoutHeight.GetRevisionNumber(), timeoutHeight.GetRevisionHeight()),
packet.GetTimeoutTimestamp(),
)
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&p)
store.Set(host.VirtualPacketKey(portID, channelID, sequence), bz)
}

Expand Down
1 change: 1 addition & 0 deletions modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ func (k Keeper) RecvPacket(

// emit an event that the relayer can query for
EmitRecvPacketEvent(ctx, packet, channel)
k.SetVirtualPacket(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), packet)

return nil
}
Expand Down

0 comments on commit f204504

Please sign in to comment.