09-localhost 轻客户端模块通过单个哨兵 localhost 连接与核心 IBC 集成。 哨兵 ConnectionEnd 默认存储在核心 IBC 存储中。 这使得通道握手可以开箱即用地发起,只需在 MsgChannelOpenInit 的 connectionHops 参数中提供 localhost 连接标识符 connection-localhost。 ConnectionEnd 通过核心 IBC 中 03-connection 子模块的 InitGenesis 处理器创建并写入存储。 ConnectionEnd 及其 Counterparty 都引用 09-localhost 客户端标识符,并共享 localhost 连接标识符 connection-localhost。
/ CreateSentinelLocalhostConnection creates and sets the sentinel localhost connection end in the IBC store.
func (k Keeper)

CreateSentinelLocalhostConnection(ctx sdk.Context) {
    counterparty := types.NewCounterparty(exported.LocalhostClientID, exported.LocalhostConnectionID, commitmenttypes.NewMerklePrefix(k.GetCommitmentPrefix().Bytes()))
    connectionEnd := types.NewConnectionEnd(types.OPEN, exported.LocalhostClientID, counterparty, types.GetCompatibleVersions(), 0)

k.SetConnection(ctx, exported.LocalhostConnectionID, connectionEnd)
}
请注意,使用 09-localhost 客户端类型时,不允许进行连接握手。
The 09-localhost light client module integrates with core IBC through a single sentinel localhost connection. The sentinel ConnectionEnd is stored by default in the core IBC store. This enables channel handshakes to be initiated out of the box by supplying the localhost connection identifier (connection-localhost) in the connectionHops parameter of MsgChannelOpenInit. The ConnectionEnd is created and set in store via the InitGenesis handler of the 03-connection submodule in core IBC. The ConnectionEnd and its Counterparty both reference the 09-localhost client identifier, and share the localhost connection identifier connection-localhost.
/ CreateSentinelLocalhostConnection creates and sets the sentinel localhost connection end in the IBC store.
func (k Keeper)

CreateSentinelLocalhostConnection(ctx sdk.Context) {
    counterparty := types.NewCounterparty(exported.LocalhostClientID, exported.LocalhostConnectionID, commitmenttypes.NewMerklePrefix(k.GetCommitmentPrefix().Bytes()))
    connectionEnd := types.NewConnectionEnd(types.OPEN, exported.LocalhostClientID, counterparty, types.GetCompatibleVersions(), 0)

k.SetConnection(ctx, exported.LocalhostConnectionID, connectionEnd)
}
Note that connection handshakes are disallowed when using the 09-localhost client type.