-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1481: IBC MVP Refactor
in progress in progress fix all keeper/handler/types, start working on test finalize rebase fixing clients add linear_cli.go, refactor relayer cli fix examples add wire, msg naming format, fix examples in progress in progress add client/store in progress in progress cleanup finalize cleanup fix errors refactor ibc
- Loading branch information
Showing
39 changed files
with
1,397 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package lib | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/context" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/wire" | ||
) | ||
|
||
type linearCLIStore struct { | ||
ctx context.CoreContext | ||
storeName string | ||
prefix []byte | ||
} | ||
|
||
// Implements sdk.CacheWrapper | ||
func (store linearCLIStore) CacheWrap() sdk.CacheWrap { | ||
panic("Should not reach here") | ||
} | ||
|
||
// Implements sdk.KVStore | ||
func (store linearCLIStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) sdk.CacheWrap { | ||
panic("Should not reach here") | ||
} | ||
|
||
// Implements sdk.Store | ||
func (store linearCLIStore) GetStoreType() sdk.StoreType { | ||
panic("Should not reach here") | ||
} | ||
|
||
// Implements sdk.KVStore | ||
func (store linearCLIStore) Get(key []byte) []byte { | ||
bz, err := store.ctx.QueryStore(append(store.prefix, key...), store.storeName) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return bz | ||
} | ||
|
||
// Implements sdk.KVStore | ||
func (store linearCLIStore) Has(key []byte) bool { | ||
panic("Should not reach here") | ||
} | ||
|
||
// Implements sdk.KVStore | ||
func (store linearCLIStore) Set(key, value []byte) { | ||
panic("Should not reach here") | ||
} | ||
|
||
// Implements sdk.KVStore | ||
func (store linearCLIStore) Delete(key []byte) { | ||
panic("Should not reach here") | ||
} | ||
|
||
// Implements sdk.KVstore | ||
func (store linearCLIStore) Prefix(prefix []byte) sdk.KVStore { | ||
panic("Should not reach here") | ||
} | ||
|
||
// Implements sdk.KVStore | ||
func (store linearCLIStore) Iterator(start, end []byte) sdk.Iterator { | ||
panic("Should not reach here") | ||
} | ||
|
||
// Implements sdk.KVStore | ||
func (store linearCLIStore) ReverseIterator(start, end []byte) sdk.Iterator { | ||
panic("Should not reach here") | ||
} | ||
|
||
type linearClient struct { | ||
Linear | ||
} | ||
|
||
type LinearClient interface { | ||
Len() uint64 | ||
Get(uint64, interface{}) error | ||
Iterate(interface{}, func(uint64) bool) | ||
|
||
Peek(interface{}) error | ||
IsEmpty() bool | ||
} | ||
|
||
func NewLinearClient(ctx context.CoreContext, storeName string, cdc *wire.Codec, prefix []byte, keys *LinearKeys) LinearClient { | ||
if keys == nil { | ||
keys = cachedDefaultLinearKeys | ||
} | ||
if keys.LengthKey == nil || keys.ElemKey == nil || keys.TopKey == nil { | ||
panic("Invalid LinearKeys") | ||
} | ||
return linearClient{ | ||
Linear: Linear{ | ||
cdc: cdc, | ||
store: linearCLIStore{ | ||
ctx: ctx, | ||
storeName: storeName, | ||
prefix: prefix, | ||
}, | ||
keys: keys, | ||
}, | ||
} | ||
} | ||
|
||
func (cli linearClient) Iterate(ptr interface{}, fn func(uint64) bool) { | ||
top := cli.getTop() | ||
length := cli.Len() | ||
|
||
var i uint64 | ||
for i = top; i < length; i++ { | ||
if cli.Get(i, ptr) != nil { | ||
continue | ||
} | ||
if fn(i) { | ||
break | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package lib | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/wire" | ||
) | ||
|
||
type Value struct { | ||
store sdk.KVStore | ||
cdc *wire.Codec | ||
key []byte | ||
} | ||
|
||
func NewValue(store sdk.KVStore, cdc *wire.Codec, key []byte) Value { | ||
return Value{ | ||
store: store, | ||
cdc: cdc, | ||
key: key, | ||
} | ||
} | ||
|
||
func (v Value) MustGet(ptr interface{}) { | ||
bz := v.store.Get(v.key) | ||
v.cdc.MustUnmarshalBinary(bz, ptr) | ||
} | ||
|
||
func (v Value) Get(ptr interface{}) bool { | ||
bz := v.store.Get(v.key) | ||
if bz == nil { | ||
return false | ||
} | ||
v.cdc.MustUnmarshalBinary(bz, ptr) | ||
return true | ||
} | ||
|
||
func (v Value) Has() bool { | ||
bz := v.store.Get(v.key) | ||
return bz != nil | ||
} | ||
|
||
func (v Value) Set(val interface{}) { | ||
v.store.Set(v.key, v.cdc.MustMarshalBinary(val)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package cli | ||
|
||
const ( | ||
FlagTo = "to" | ||
FlagAmount = "amount" | ||
FlagDestChain = "dest-chain-id" | ||
) |
Oops, something went wrong.