From 83f0ee31aff637c0ac0e2c04f12c1311ff5e062b Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Wed, 24 Jan 2018 01:04:44 -0800 Subject: [PATCH] Split dummy into 2 files. (#371) * Update examples/basecoin glide.lock * Split dummy file --- examples/basecoin/glide.lock | 13 +++---- examples/dummy/main.go | 64 --------------------------------- examples/dummy/tx.go | 70 ++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 70 deletions(-) create mode 100644 examples/dummy/tx.go diff --git a/examples/basecoin/glide.lock b/examples/basecoin/glide.lock index a847d85b4..3b4115908 100644 --- a/examples/basecoin/glide.lock +++ b/examples/basecoin/glide.lock @@ -1,14 +1,15 @@ hash: 80794a3459988a7eb794baf7688c71dad4f6c26653d7b707ac0ada93f21e0776 -updated: 2018-01-20T22:01:39.658469011-08:00 +updated: 2018-01-23T19:03:56.956668196-08:00 imports: - name: github.com/btcsuite/btcd version: 2e60448ffcc6bf78332d1fe590260095f554dd78 subpackages: - btcec - name: github.com/cosmos/cosmos-sdk - version: 633eaa87b38d9c5b0e938fe6b4f1dfd016247e76 + version: 8650fd70c92686a192585e95413915b4302156b7 subpackages: - baseapp + - examples/basecoin/types - store - types - x/auth @@ -80,17 +81,17 @@ imports: - edwards25519 - extra25519 - name: github.com/tendermint/go-crypto - version: 32741be2126500d600cede1e2016bbbe2754cb46 + version: 12142af1cb4e3479ea4ac98a3171debff87519c6 subpackages: - keys - name: github.com/tendermint/go-wire - version: 90af61ec85415e05c7777cd50ff93ba40d34b1e8 + version: c7801c1586f51bb28028cd420c599516d7ac9c36 subpackages: - data - name: github.com/tendermint/iavl - version: 1dfe265ab4b491418e88e1da6577a8ad594fc989 + version: ae2ea4a62f60c72dae81ca6642944ca28cf59889 - name: github.com/tendermint/tmlibs - version: 7a52d47a1676a9fe61d07fde0a48a733cce564c6 + version: 80029abc6e20f85079cd751e659a05508773288c subpackages: - cli - cli/flags diff --git a/examples/dummy/main.go b/examples/dummy/main.go index f4b343e4f..27abb4079 100644 --- a/examples/dummy/main.go +++ b/examples/dummy/main.go @@ -1,12 +1,10 @@ package main import ( - "bytes" "fmt" "os" "github.com/tendermint/abci/server" - crypto "github.com/tendermint/go-crypto" cmn "github.com/tendermint/tmlibs/common" bam "github.com/cosmos/cosmos-sdk/baseapp" @@ -52,68 +50,6 @@ func main() { return } -type dummyTx struct { - key []byte - value []byte - - bytes []byte -} - -func (tx dummyTx) Get(key interface{}) (value interface{}) { - switch k := key.(type) { - case string: - switch k { - case "key": - return tx.key - case "value": - return tx.value - } - } - return nil -} - -func (tx dummyTx) Type() string { - return "dummy" -} - -func (tx dummyTx) GetSignBytes() []byte { - return tx.bytes -} - -// Should the app be calling this? Or only handlers? -func (tx dummyTx) ValidateBasic() error { - return nil -} - -func (tx dummyTx) GetSigners() []crypto.Address { - return nil -} - -func (tx dummyTx) GetSignatures() []sdk.StdSignature { - return nil -} - -func (tx dummyTx) GetFeePayer() crypto.Address { - return nil -} - -func decodeTx(txBytes []byte) (sdk.Tx, error) { - var tx sdk.Tx - - split := bytes.Split(txBytes, []byte("=")) - if len(split) == 1 { - k := split[0] - tx = dummyTx{k, k, txBytes} - } else if len(split) == 2 { - k, v := split[0], split[1] - tx = dummyTx{k, v, txBytes} - } else { - return nil, fmt.Errorf("too many =") - } - - return tx, nil -} - func DummyHandler(storeKey sdk.StoreKey) sdk.Handler { return func(ctx sdk.Context, tx sdk.Tx) sdk.Result { // tx is already unmarshalled diff --git a/examples/dummy/tx.go b/examples/dummy/tx.go new file mode 100644 index 000000000..63343abc6 --- /dev/null +++ b/examples/dummy/tx.go @@ -0,0 +1,70 @@ +package main + +import ( + "bytes" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + crypto "github.com/tendermint/go-crypto" +) + +type dummyTx struct { + key []byte + value []byte + bytes []byte +} + +func (tx dummyTx) Get(key interface{}) (value interface{}) { + switch k := key.(type) { + case string: + switch k { + case "key": + return tx.key + case "value": + return tx.value + } + } + return nil +} + +func (tx dummyTx) Type() string { + return "dummy" +} + +func (tx dummyTx) GetSignBytes() []byte { + return tx.bytes +} + +// Should the app be calling this? Or only handlers? +func (tx dummyTx) ValidateBasic() error { + return nil +} + +func (tx dummyTx) GetSigners() []crypto.Address { + return nil +} + +func (tx dummyTx) GetSignatures() []sdk.StdSignature { + return nil +} + +func (tx dummyTx) GetFeePayer() crypto.Address { + return nil +} + +func decodeTx(txBytes []byte) (sdk.Tx, error) { + var tx sdk.Tx + + split := bytes.Split(txBytes, []byte("=")) + if len(split) == 1 { + k := split[0] + tx = dummyTx{k, k, txBytes} + } else if len(split) == 2 { + k, v := split[0], split[1] + tx = dummyTx{k, v, txBytes} + } else { + return nil, fmt.Errorf("too many =") + } + + return tx, nil +}