IBC module

This commit is contained in:
Adrian Brink 2018-03-15 14:54:44 +01:00
parent 829f0f32fc
commit c409455150
No known key found for this signature in database
GPG Key ID: F61053D3FBD06353
4 changed files with 32 additions and 16 deletions

View File

@ -24,7 +24,6 @@
# go-tests = true
# unused-packages = true
[[constraint]]
name = "github.com/bgentry/speakeasy"
version = "0.1.0"
@ -41,10 +40,6 @@
name = "github.com/pkg/errors"
version = "0.8.0"
# [[constraint]]
# branch = "master"
# name = "github.com/rigelrozanski/common"
[[constraint]]
name = "github.com/spf13/cobra"
version = "0.0.1"

View File

@ -1,14 +1,17 @@
# IBC Spec
*This is a living document and should be edited as the IBC spec and implementation change*
*This is a living document and should be edited as the IBC spec and
implementation change*
## MVP1
The initial implementation of IBC will include just enough for simple coin transfers between chains, with safety features such as ACK messages being added later.
The initial implementation of IBC will include just enough for simple coin
transfers between chains, with safety features such as ACK messages being added
later.
### IBC Module
```golang
```go
// User facing API
type IBCPacket struct {
@ -47,12 +50,14 @@ type EgressKey struct {
DestChain string
Index int64
}
```
`egressKey` stores the outgoing `IBCTransfer`s as a list. Its getter takes an `EgressKey` and returns the length if `egressKey.Index == -1`, an element if `egressKey.Index > 0`.
`egressKey` stores the outgoing `IBCTransfer`s as a list. Its getter takes an
`EgressKey` and returns the length if `egressKey.Index == -1`, an element if
`egressKey.Index > 0`.
`ingressKey` stores the last income `IBCTransfer`'s sequence. Its getter takes an `IngressKey`.
`ingressKey` stores the latest income `IBCTransfer`'s sequence. It's getter
takes an `IngressKey`.
## Relayer

View File

@ -10,8 +10,7 @@ import (
type IBCMapper struct {
ibcKey sdk.StoreKey
cdc *wire.Codec
cdc *wire.Codec
}
func NewIBCMapper(ibcKey sdk.StoreKey) IBCMapper {

View File

@ -6,6 +6,11 @@ import (
wire "github.com/cosmos/cosmos-sdk/wire"
)
// ------------------------------
// IBCPacket
// IBCPacket defines a piece of data that can be send between two separate
// blockchains.
type IBCPacket struct {
SrcAddr sdk.Address
DestAddr sdk.Address
@ -14,10 +19,10 @@ type IBCPacket struct {
DestChain string
}
func newCodec() *wire.Codec {
return wire.NewCodec()
}
// ----------------------------------
// IBCTransferMsg
// IBCTransferMsg defines how another module can send an IBCPacket.
type IBCTransferMsg struct {
IBCPacket
}
@ -48,6 +53,11 @@ func (msg IBCTransferMsg) GetSigners() []sdk.Address {
return []sdk.Address{msg.SrcAddr}
}
// ----------------------------------
// IBCReceiveMsg
// IBCReceiveMsg defines the message that a relayer uses to post an IBCPacket
// to the destination chain.
type IBCReceiveMsg struct {
IBCPacket
Relayer sdk.Address
@ -79,3 +89,10 @@ func (msg IBCReceiveMsg) ValidateBasic() sdk.Error {
func (msg IBCReceiveMsg) GetSigners() []sdk.Address {
return []sdk.Address{msg.Relayer}
}
// -------------------------
// Helpers
func newCodec() *wire.Codec {
return wire.NewCodec()
}