commit
0fc1b98525
16
app/app.go
16
app/app.go
|
@ -5,9 +5,10 @@ import (
|
|||
"strings"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
. "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/go-wire"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
eyes "github.com/tendermint/merkleeyes/client"
|
||||
. "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
sm "github.com/tendermint/basecoin/state"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
|
@ -24,6 +25,7 @@ type Basecoin struct {
|
|||
state *sm.State
|
||||
cacheState *sm.State
|
||||
plugins *types.Plugins
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
func NewBasecoin(eyesCli *eyes.Client) *Basecoin {
|
||||
|
@ -34,9 +36,15 @@ func NewBasecoin(eyesCli *eyes.Client) *Basecoin {
|
|||
state: state,
|
||||
cacheState: nil,
|
||||
plugins: plugins,
|
||||
logger: log.NewNopLogger(),
|
||||
}
|
||||
}
|
||||
|
||||
func (app *Basecoin) SetLogger(l log.Logger) {
|
||||
app.logger = l
|
||||
app.state.SetLogger(l.With("module", "state"))
|
||||
}
|
||||
|
||||
// XXX For testing, not thread safe!
|
||||
func (app *Basecoin) GetState() *sm.State {
|
||||
return app.state.CacheWrap()
|
||||
|
@ -60,7 +68,7 @@ func (app *Basecoin) SetOption(key string, value string) string {
|
|||
if plugin == nil {
|
||||
return "Invalid plugin name: " + pluginName
|
||||
}
|
||||
log.Notice("SetOption on plugin", "plugin", pluginName, "key", key, "value", value)
|
||||
app.logger.Info("SetOption on plugin", "plugin", pluginName, "key", key, "value", value)
|
||||
return plugin.SetOption(app.state, key, value)
|
||||
} else {
|
||||
// Set option on basecoin
|
||||
|
@ -75,7 +83,7 @@ func (app *Basecoin) SetOption(key string, value string) string {
|
|||
return "Error decoding acc message: " + err.Error()
|
||||
}
|
||||
app.state.SetAccount(acc.PubKey.Address(), &acc)
|
||||
log.Notice("SetAccount", "addr", acc.PubKey.Address(), "acc", acc)
|
||||
app.logger.Info("SetAccount", "addr", acc.PubKey.Address(), "acc", acc)
|
||||
|
||||
return "Success"
|
||||
}
|
||||
|
|
|
@ -10,8 +10,9 @@ import (
|
|||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/go-wire"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
eyes "github.com/tendermint/merkleeyes/client"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
@ -56,6 +57,7 @@ func (at *appTest) reset() {
|
|||
|
||||
eyesCli := eyes.NewLocalClient("", 0)
|
||||
at.app = NewBasecoin(eyesCli)
|
||||
at.app.SetLogger(log.TestingLogger().With("module", "app"))
|
||||
|
||||
res := at.app.SetOption("base/chain_id", at.chainID)
|
||||
require.EqualValues(at.t, res, "Success")
|
||||
|
@ -104,6 +106,7 @@ func TestSetOption(t *testing.T) {
|
|||
|
||||
eyesCli := eyes.NewLocalClient("", 0)
|
||||
app := NewBasecoin(eyesCli)
|
||||
app.SetLogger(log.TestingLogger().With("module", "app"))
|
||||
|
||||
//testing ChainID
|
||||
chainID := "testChain"
|
||||
|
|
|
@ -26,13 +26,13 @@ func (app *Basecoin) LoadGenesis(path string) error {
|
|||
}
|
||||
r := app.SetOption("base/account", string(accBytes))
|
||||
// TODO: SetOption returns an error
|
||||
log.Notice("Done setting Account via SetOption", "result", r)
|
||||
app.logger.Info("Done setting Account via SetOption", "result", r)
|
||||
}
|
||||
|
||||
// set plugin options
|
||||
for _, kv := range genDoc.AppOptions.pluginOptions {
|
||||
r := app.SetOption(kv.Key, kv.Value)
|
||||
log.Notice("Done setting Plugin key-value pair via SetOption", "result", r, "k", kv.Key, "v", kv.Value)
|
||||
app.logger.Info("Done setting Plugin key-value pair via SetOption", "result", r, "k", kv.Key, "v", kv.Value)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"github.com/tendermint/tmlibs/logger"
|
||||
)
|
||||
|
||||
var log = logger.New("module", "app")
|
18
circle.yml
18
circle.yml
|
@ -1,26 +1,26 @@
|
|||
machine:
|
||||
environment:
|
||||
GOPATH: /home/ubuntu/.go_workspace
|
||||
REPO: $GOPATH/src/github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
|
||||
GOPATH: "$HOME/.go_workspace"
|
||||
PROJECT_PARENT_PATH: "$GOPATH/src/github.com/$CIRCLE_PROJECT_USERNAME"
|
||||
REPO: "$PROJECT_PARENT_PATH/$CIRCLE_PROJECT_REPONAME"
|
||||
PATH: "$GOPATH/bin:$PATH"
|
||||
hosts:
|
||||
circlehost: 127.0.0.1
|
||||
localhost: 127.0.0.1
|
||||
|
||||
checkout:
|
||||
post:
|
||||
- rm -rf $REPO
|
||||
- mkdir -p $HOME/.go_workspace/src/github.com/$CIRCLE_PROJECT_USERNAME
|
||||
- mv $HOME/$CIRCLE_PROJECT_REPONAME $REPO
|
||||
|
||||
dependencies:
|
||||
override:
|
||||
- go get github.com/Masterminds/glide
|
||||
- go version
|
||||
- glide --version
|
||||
- "cd $REPO && glide install && go install ./cmd/basecoin"
|
||||
- mkdir -p "$PROJECT_PARENT_PATH"
|
||||
- ln -sf "$HOME/$CIRCLE_PROJECT_REPONAME/" "$REPO"
|
||||
- env
|
||||
|
||||
test:
|
||||
override:
|
||||
- "cd $REPO && glide install && go install ./cmd/basecoin"
|
||||
- ls $GOPATH/bin
|
||||
- "cd $REPO && make test"
|
||||
- "cd $REPO/demo && bash start.sh"
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ func initCmd(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
if (mod1 + mod2 + mod3 + mod4) > 0 {
|
||||
log.Notice("Initialized Basecoin", "genesis", genesisFile, "key", key1File)
|
||||
logger.Info("Initialized Basecoin", "genesis", genesisFile, "key", key1File)
|
||||
} else {
|
||||
log.Notice("Already initialized", "priv_validator", privValFile)
|
||||
logger.Info("Already initialized", "priv_validator", privValFile)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"github.com/tendermint/tmlibs/logger"
|
||||
)
|
||||
|
||||
var log = logger.New("module", "commands")
|
|
@ -0,0 +1,11 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
|
||||
var (
|
||||
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "main")
|
||||
)
|
|
@ -13,7 +13,7 @@ import (
|
|||
eyes "github.com/tendermint/merkleeyes/client"
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/logger"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/node"
|
||||
|
@ -68,6 +68,7 @@ func startCmd(cmd *cobra.Command, args []string) error {
|
|||
|
||||
// Create Basecoin app
|
||||
basecoinApp := app.NewBasecoin(eyesCli)
|
||||
basecoinApp.SetLogger(logger.With("module", "app"))
|
||||
|
||||
// register IBC plugn
|
||||
basecoinApp.RegisterPlugin(NewIBCPlugin())
|
||||
|
@ -94,11 +95,11 @@ func startCmd(cmd *cobra.Command, args []string) error {
|
|||
|
||||
chainID := basecoinApp.GetState().GetChainID()
|
||||
if withoutTendermintFlag {
|
||||
log.Notice("Starting Basecoin without Tendermint", "chain_id", chainID)
|
||||
logger.Info("Starting Basecoin without Tendermint", "chain_id", chainID)
|
||||
// run just the abci app/server
|
||||
return startBasecoinABCI(basecoinApp)
|
||||
} else {
|
||||
log.Notice("Starting Basecoin with Tendermint", "chain_id", chainID)
|
||||
logger.Info("Starting Basecoin with Tendermint", "chain_id", chainID)
|
||||
// start the app with tendermint in-process
|
||||
return startTendermint(rootDir, basecoinApp)
|
||||
}
|
||||
|
@ -110,6 +111,8 @@ func startBasecoinABCI(basecoinApp *app.Basecoin) error {
|
|||
if err != nil {
|
||||
return errors.Errorf("Error creating listener: %v\n", err)
|
||||
}
|
||||
svr.SetLogger(logger.With("module", "abci-server"))
|
||||
svr.Start()
|
||||
|
||||
// Wait forever
|
||||
cmn.TrapSignal(func() {
|
||||
|
@ -127,11 +130,15 @@ func startTendermint(dir string, basecoinApp *app.Basecoin) error {
|
|||
}
|
||||
cfg.SetRoot(cfg.RootDir)
|
||||
config.EnsureRoot(cfg.RootDir)
|
||||
logger.SetLogLevel(cfg.LogLevel)
|
||||
|
||||
tmLogger, err := log.NewFilterByLevel(logger, cfg.LogLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Create & start tendermint node
|
||||
privValidator := types.LoadOrGenPrivValidator(cfg.PrivValidatorFile())
|
||||
n := node.NewNode(cfg, privValidator, proxy.NewLocalClientCreator(basecoinApp))
|
||||
privValidator := types.LoadOrGenPrivValidator(cfg.PrivValidatorFile(), tmLogger)
|
||||
n := node.NewNode(cfg, privValidator, proxy.NewLocalClientCreator(basecoinApp), tmLogger.With("module", "node"))
|
||||
|
||||
_, err = n.Start()
|
||||
if err != nil {
|
||||
|
|
|
@ -8,12 +8,13 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
|
||||
"github.com/tendermint/basecoin/state"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
client "github.com/tendermint/tendermint/rpc/client"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "counter",
|
||||
Short: "demo plugin for basecoin",
|
||||
|
|
|
@ -4,7 +4,8 @@ set -e
|
|||
cd $GOPATH/src/github.com/tendermint/basecoin/demo
|
||||
|
||||
LOG_DIR="."
|
||||
TM_VERSION="v0.9.2"
|
||||
TM_VERSION="develop"
|
||||
#TM_VERSION="v0.10.0"
|
||||
|
||||
if [[ "$CIRCLECI" == "true" ]]; then
|
||||
# set log dir
|
||||
|
@ -27,7 +28,7 @@ function ifExit() {
|
|||
if [[ "$?" != 0 ]]; then
|
||||
echo "FAIL"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function removeQuotes() {
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
hash: c887040d9aa1545d4d2c45db78032ab5e132c4eebed14e757573e7f7103fc162
|
||||
updated: 2017-04-27T20:02:48.730032774-04:00
|
||||
hash: 997e4cc3339141ee01aa2adf656425a49ebf117e6ca9e81ba72b8f94fee3e86e
|
||||
updated: 2017-05-16T13:41:59.92225084Z
|
||||
imports:
|
||||
- name: github.com/bgentry/speakeasy
|
||||
version: 4aabc24848ce5fd31929f7d1e4ea74d3709c14cd
|
||||
- name: github.com/btcsuite/btcd
|
||||
version: 4b348c1d33373d672edd83fc576892d0e46686d2
|
||||
version: 1ae306021e323ae11c71ffb8546fbd9019e6cb6f
|
||||
subpackages:
|
||||
- btcec
|
||||
- name: github.com/BurntSushi/toml
|
||||
version: b26d9c308763d68093482582cea63d69be07a0f0
|
||||
- name: github.com/davecgh/go-spew
|
||||
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
|
||||
subpackages:
|
||||
- spew
|
||||
- name: github.com/ebuchman/fail-test
|
||||
version: 95f809107225be108efcf10a3509e4ea6ceef3c4
|
||||
- name: github.com/fsnotify/fsnotify
|
||||
version: 4da3e2cfbabc9f751898f250b49f2439785783a1
|
||||
- name: github.com/go-kit/kit
|
||||
version: d67bb4c202e3b91377d1079b110a6c9ce23ab2f8
|
||||
subpackages:
|
||||
- log
|
||||
- log/level
|
||||
- log/term
|
||||
- name: github.com/go-logfmt/logfmt
|
||||
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
|
||||
- name: github.com/go-playground/locales
|
||||
version: 1e5f1161c6416a5ff48840eb8724a394e48cc534
|
||||
subpackages:
|
||||
|
@ -24,9 +28,9 @@ imports:
|
|||
- name: github.com/go-playground/universal-translator
|
||||
version: 71201497bace774495daed26a3874fd339e0b538
|
||||
- name: github.com/go-stack/stack
|
||||
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
|
||||
version: 7a2f19628aabfe68f0766b59e74d6315f8347d22
|
||||
- name: github.com/golang/protobuf
|
||||
version: 2bba0603135d7d7f5cb73b2125beeda19c09f4ef
|
||||
version: b50ceb1fa9818fa4d78b016c2d4ae025593a7ce3
|
||||
subpackages:
|
||||
- proto
|
||||
- ptypes/any
|
||||
|
@ -35,13 +39,13 @@ imports:
|
|||
- name: github.com/gorilla/context
|
||||
version: 08b5f424b9271eedf6f9f0ce86cb9396ed337a42
|
||||
- name: github.com/gorilla/handlers
|
||||
version: 3a5767ca75ece5f7f1440b1d16975247f8d8b221
|
||||
version: 13d73096a474cac93275c679c7b8a2dc17ddba82
|
||||
- name: github.com/gorilla/mux
|
||||
version: 392c28fe23e1c45ddba891b0320b3b5df220beea
|
||||
- name: github.com/gorilla/websocket
|
||||
version: 3ab3a8b8831546bd18fd182c20687ca853b2bb13
|
||||
version: a91eba7f97777409bc2c443f5534d41dd20c5720
|
||||
- name: github.com/hashicorp/hcl
|
||||
version: 630949a3c5fa3c613328e1b8256052cbc2327c9b
|
||||
version: 392dba7d905ed5d04a5794ba89f558b27e2ba1ca
|
||||
subpackages:
|
||||
- hcl/ast
|
||||
- hcl/parser
|
||||
|
@ -55,24 +59,18 @@ imports:
|
|||
version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
|
||||
- name: github.com/jmhodges/levigo
|
||||
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
|
||||
- name: github.com/kr/logfmt
|
||||
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
|
||||
- name: github.com/magiconair/properties
|
||||
version: 51463bfca2576e06c62a8504b5c0f06d61312647
|
||||
- name: github.com/mattn/go-colorable
|
||||
version: ded68f7a9561c023e790de24279db7ebf473ea80
|
||||
- name: github.com/mattn/go-isatty
|
||||
version: fc9e8d8ef48496124e79ae0df75490096eccf6fe
|
||||
- name: github.com/mitchellh/mapstructure
|
||||
version: 53818660ed4955e899c0bcafa97299a388bd7c8e
|
||||
version: cc8532a8e9a55ea36402aa21efdf403a60d34096
|
||||
- name: github.com/pelletier/go-buffruneio
|
||||
version: c37440a7cf42ac63b919c752ca73a85067e05992
|
||||
- name: github.com/pelletier/go-toml
|
||||
version: 13d49d4606eb801b8f01ae542b4afc4c6ee3d84a
|
||||
version: 685a1f1cb7a66b9cadbe8f1ac49d9f8f567d6a9d
|
||||
- name: github.com/pkg/errors
|
||||
version: 645ef00459ed84a119197bfb8d8205042c6df63d
|
||||
- name: github.com/pmezard/go-difflib
|
||||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
||||
subpackages:
|
||||
- difflib
|
||||
- name: github.com/spf13/afero
|
||||
version: 9be650865eab0c12963d8753212f4f9c66cdcf12
|
||||
subpackages:
|
||||
|
@ -80,18 +78,13 @@ imports:
|
|||
- name: github.com/spf13/cast
|
||||
version: acbeb36b902d72a7a4c18e8f3241075e7ab763e4
|
||||
- name: github.com/spf13/cobra
|
||||
version: 10f6b9d7e1631a54ad07c5c0fb71c28a1abfd3c2
|
||||
version: 3454e0e28e69c1b8effa6b5123c8e4185e20d696
|
||||
- name: github.com/spf13/jwalterweatherman
|
||||
version: fa7ca7e836cf3a8bb4ebf799f472c12d7e903d66
|
||||
version: 8f07c835e5cc1450c082fe3a439cf87b0cbb2d99
|
||||
- name: github.com/spf13/pflag
|
||||
version: 2300d0f8576fe575f71aaa5b9bbe4e1b0dc2eb51
|
||||
version: e57e3eeb33f795204c1ca35f56c44f83227c6e66
|
||||
- name: github.com/spf13/viper
|
||||
version: 5d46e70da8c0b6f812e0b170b7a985753b5c63cb
|
||||
- name: github.com/stretchr/testify
|
||||
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
|
||||
subpackages:
|
||||
- assert
|
||||
- require
|
||||
version: 0967fc9aceab2ce9da34061253ac10fb99bba5b2
|
||||
- name: github.com/syndtr/goleveldb
|
||||
version: 8c81ea47d4c41a385645e133e15510fc6a2a74b4
|
||||
subpackages:
|
||||
|
@ -108,7 +101,7 @@ imports:
|
|||
- leveldb/table
|
||||
- leveldb/util
|
||||
- name: github.com/tendermint/abci
|
||||
version: 8d8e35ae537538c9cf6808be3ca9dd7dab81b7f6
|
||||
version: 5dabeffb35c027d7087a12149685daa68989168b
|
||||
subpackages:
|
||||
- client
|
||||
- example/dummy
|
||||
|
@ -120,39 +113,42 @@ imports:
|
|||
- edwards25519
|
||||
- extra25519
|
||||
- name: github.com/tendermint/go-crypto
|
||||
version: e71bbb2509b586f0b24f120b6ba57f32aefa1579
|
||||
version: a42b10e0feb465eb56fbc6bb5b71d57ef646ec57
|
||||
subpackages:
|
||||
- cmd
|
||||
- keys
|
||||
- keys/cmd
|
||||
- keys/cryptostore
|
||||
- keys/server
|
||||
- keys/server/types
|
||||
- keys/storage/filestorage
|
||||
- keys/storage/memstorage
|
||||
- name: github.com/tendermint/go-wire
|
||||
version: b53add0b622662731985485f3a19be7f684660b8
|
||||
version: 7f81de645283af7c62f17eafe3ef13b38cc0836b
|
||||
subpackages:
|
||||
- data
|
||||
- data/base58
|
||||
- name: github.com/tendermint/light-client
|
||||
version: 6a786b321c0634e801e692af93491b75866cb0cd
|
||||
- name: github.com/tendermint/log15
|
||||
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
|
||||
version: c003b47d43fd79dcec14e5cdaf353cc461fa7cb7
|
||||
subpackages:
|
||||
- term
|
||||
- certifiers
|
||||
- certifiers/client
|
||||
- certifiers/files
|
||||
- commands
|
||||
- commands/proofs
|
||||
- commands/proxy
|
||||
- commands/seeds
|
||||
- commands/txs
|
||||
- proofs
|
||||
- name: github.com/tendermint/merkleeyes
|
||||
version: c722818b460381bc5b82e38c73ff6e22a9df624d
|
||||
subpackages:
|
||||
- app
|
||||
- client
|
||||
- iavl
|
||||
- testutil
|
||||
- name: github.com/tendermint/tendermint
|
||||
version: 07fe3e2f1345767fda9f31045da19bd277935afb
|
||||
version: e1792c1ea521ff6c10f79d7865a027024978b629
|
||||
subpackages:
|
||||
- blockchain
|
||||
- config/tendermint_test
|
||||
- config
|
||||
- consensus
|
||||
- mempool
|
||||
- node
|
||||
|
@ -167,7 +163,6 @@ imports:
|
|||
- rpc/lib/client
|
||||
- rpc/lib/server
|
||||
- rpc/lib/types
|
||||
- rpc/test
|
||||
- state
|
||||
- state/txindex
|
||||
- state/txindex/kv
|
||||
|
@ -175,18 +170,20 @@ imports:
|
|||
- types
|
||||
- version
|
||||
- name: github.com/tendermint/tmlibs
|
||||
version: 706b9fbd671d5d49ecf1b2ea3bb34e51d61ff091
|
||||
version: 812d9f9b84d1dfe4cb46ce021b3a2d97b48d1292
|
||||
subpackages:
|
||||
- autofile
|
||||
- cli
|
||||
- clist
|
||||
- common
|
||||
- db
|
||||
- events
|
||||
- flowrate
|
||||
- log
|
||||
- logger
|
||||
- merkle
|
||||
- name: golang.org/x/crypto
|
||||
version: 96846453c37f0876340a66a47f3f75b1f3a6cd2d
|
||||
version: ab89591268e0c8b748cbe4047b00197516011af5
|
||||
subpackages:
|
||||
- curve25519
|
||||
- nacl/box
|
||||
|
@ -197,7 +194,7 @@ imports:
|
|||
- ripemd160
|
||||
- salsa20/salsa
|
||||
- name: golang.org/x/net
|
||||
version: c8c74377599bd978aee1cf3b9b63a8634051cec2
|
||||
version: c9b681d35165f1995d6f3034e61f8761d4b90c99
|
||||
subpackages:
|
||||
- context
|
||||
- http2
|
||||
|
@ -207,11 +204,11 @@ imports:
|
|||
- lex/httplex
|
||||
- trace
|
||||
- name: golang.org/x/sys
|
||||
version: ea9bcade75cb975a0b9738936568ab388b845617
|
||||
version: 9c9d83fe39ed3fd2d9249fcf6b755891fff54b03
|
||||
subpackages:
|
||||
- unix
|
||||
- name: golang.org/x/text
|
||||
version: 19e3104b43db45fca0303f489a9536087b184802
|
||||
version: 470f45bf29f4147d6fbd7dfd0a02a848e49f5bf4
|
||||
subpackages:
|
||||
- secure/bidirule
|
||||
- transform
|
||||
|
@ -222,10 +219,11 @@ imports:
|
|||
subpackages:
|
||||
- googleapis/rpc/status
|
||||
- name: google.golang.org/grpc
|
||||
version: 6914ab1e338c92da4218a23d27fcd03d0ad78d46
|
||||
version: a0c3e72252b6fbf4826bb143e450eb05588a9d6d
|
||||
subpackages:
|
||||
- codes
|
||||
- credentials
|
||||
- grpclb/grpc_lb_v1
|
||||
- grpclog
|
||||
- internal
|
||||
- keepalive
|
||||
|
@ -240,4 +238,17 @@ imports:
|
|||
version: 6d8c18553ea1ac493d049edd6f102f52e618f085
|
||||
- name: gopkg.in/yaml.v2
|
||||
version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
|
||||
testImports: []
|
||||
testImports:
|
||||
- name: github.com/davecgh/go-spew
|
||||
version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9
|
||||
subpackages:
|
||||
- spew
|
||||
- name: github.com/pmezard/go-difflib
|
||||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
||||
subpackages:
|
||||
- difflib
|
||||
- name: github.com/stretchr/testify
|
||||
version: 4d4bfba8f1d1027c4fdbe371823030df51419987
|
||||
subpackages:
|
||||
- assert
|
||||
- require
|
||||
|
|
17
glide.yaml
17
glide.yaml
|
@ -4,6 +4,7 @@ import:
|
|||
- package: github.com/pkg/errors
|
||||
- package: github.com/spf13/cobra
|
||||
- package: github.com/spf13/pflag
|
||||
- package: github.com/spf13/viper
|
||||
- package: github.com/tendermint/abci
|
||||
version: develop
|
||||
subpackages:
|
||||
|
@ -12,11 +13,8 @@ import:
|
|||
- package: github.com/tendermint/go-crypto
|
||||
version: develop
|
||||
subpackages:
|
||||
- keys/cmd
|
||||
- keys/cryptostore
|
||||
- keys/server
|
||||
- keys/storage/filestorage
|
||||
- keys/storage/memstorage
|
||||
- cmd
|
||||
- keys
|
||||
- package: github.com/tendermint/go-wire
|
||||
version: develop
|
||||
subpackages:
|
||||
|
@ -27,7 +25,8 @@ import:
|
|||
- commands
|
||||
- commands/proofs
|
||||
- commands/seeds
|
||||
- commands/tx
|
||||
- commands/txs
|
||||
- proofs
|
||||
- package: github.com/tendermint/merkleeyes
|
||||
version: develop
|
||||
subpackages:
|
||||
|
@ -36,10 +35,10 @@ import:
|
|||
- package: github.com/tendermint/tendermint
|
||||
version: develop
|
||||
subpackages:
|
||||
- cmd/tendermint/commands
|
||||
- config/tendermint
|
||||
- config
|
||||
- node
|
||||
- proxy
|
||||
- rpc/client
|
||||
- rpc/core/types
|
||||
- rpc/lib/client
|
||||
- rpc/lib/types
|
||||
|
@ -47,8 +46,10 @@ import:
|
|||
- package: github.com/tendermint/tmlibs
|
||||
version: develop
|
||||
subpackages:
|
||||
- cli
|
||||
- common
|
||||
- events
|
||||
- log
|
||||
- logger
|
||||
testImport:
|
||||
- package: github.com/stretchr/testify
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
|
||||
// If the tx is invalid, a TMSP error will be returned.
|
||||
func ExecTx(state *State, pgz *types.Plugins, tx types.Tx, isCheckTx bool, evc events.Fireable) abci.Result {
|
||||
|
||||
chainID := state.GetChainID()
|
||||
|
||||
// Exec tx
|
||||
|
@ -95,11 +94,11 @@ func ExecTx(state *State, pgz *types.Plugins, tx types.Tx, isCheckTx bool, evc e
|
|||
signBytes := tx.SignBytes(chainID)
|
||||
res = validateInputAdvanced(inAcc, signBytes, tx.Input)
|
||||
if res.IsErr() {
|
||||
log.Info(cmn.Fmt("validateInputAdvanced failed on %X: %v", tx.Input.Address, res))
|
||||
state.logger.Info(cmn.Fmt("validateInputAdvanced failed on %X: %v", tx.Input.Address, res))
|
||||
return res.PrependLog("in validateInputAdvanced()")
|
||||
}
|
||||
if !tx.Input.Coins.IsGTE(types.Coins{tx.Fee}) {
|
||||
log.Info(cmn.Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address))
|
||||
state.logger.Info(cmn.Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address))
|
||||
return abci.ErrBaseInsufficientFunds.AppendLog(cmn.Fmt("input coins is %v, but fee is %v", tx.Input.Coins, types.Coins{tx.Fee}))
|
||||
}
|
||||
|
||||
|
@ -131,7 +130,7 @@ func ExecTx(state *State, pgz *types.Plugins, tx types.Tx, isCheckTx bool, evc e
|
|||
res = plugin.RunTx(cache, ctx, tx.Data)
|
||||
if res.IsOK() {
|
||||
cache.CacheSync()
|
||||
log.Info("Successful execution")
|
||||
state.logger.Info("Successful execution")
|
||||
// Fire events
|
||||
/*
|
||||
if evc != nil {
|
||||
|
@ -144,7 +143,7 @@ func ExecTx(state *State, pgz *types.Plugins, tx types.Tx, isCheckTx bool, evc e
|
|||
}
|
||||
*/
|
||||
} else {
|
||||
log.Info("AppTx failed", "error", res)
|
||||
state.logger.Info("AppTx failed", "error", res)
|
||||
// Just return the coins and return.
|
||||
inAccCopy.Balance = inAccCopy.Balance.Plus(coins)
|
||||
// But take the gas
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
@ -63,6 +64,7 @@ func (et *execTest) reset() {
|
|||
|
||||
et.store = types.NewMemKVStore()
|
||||
et.state = NewState(et.store)
|
||||
et.state.SetLogger(log.TestingLogger())
|
||||
et.state.SetChainID(et.chainID)
|
||||
|
||||
// NOTE we dont run acc2State here
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package state
|
||||
|
||||
import (
|
||||
"github.com/tendermint/tmlibs/logger"
|
||||
)
|
||||
|
||||
var log = logger.New("module", "state")
|
|
@ -3,9 +3,10 @@ package state
|
|||
import (
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
. "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/go-wire"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
eyes "github.com/tendermint/merkleeyes/client"
|
||||
. "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
|
||||
// CONTRACT: State should be quick to copy.
|
||||
|
@ -15,6 +16,7 @@ type State struct {
|
|||
store types.KVStore
|
||||
readCache map[string][]byte // optional, for caching writes to store
|
||||
writeCache *types.KVCache // optional, for caching writes w/o writing to store
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
func NewState(store types.KVStore) *State {
|
||||
|
@ -23,9 +25,14 @@ func NewState(store types.KVStore) *State {
|
|||
store: store,
|
||||
readCache: make(map[string][]byte),
|
||||
writeCache: nil,
|
||||
logger: log.NewNopLogger(),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *State) SetLogger(l log.Logger) {
|
||||
s.logger = l
|
||||
}
|
||||
|
||||
func (s *State) SetChainID(chainID string) {
|
||||
s.chainID = chainID
|
||||
s.store.Set([]byte("base/chain_id"), []byte(chainID))
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/tendermint/basecoin/types"
|
||||
eyes "github.com/tendermint/merkleeyes/client"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -16,6 +17,7 @@ func TestState(t *testing.T) {
|
|||
//States and Stores for tests
|
||||
store := types.NewMemKVStore()
|
||||
state := NewState(store)
|
||||
state.SetLogger(log.TestingLogger())
|
||||
cache := state.CacheWrap()
|
||||
eyesCli := eyes.NewLocalClient("", 0)
|
||||
|
||||
|
@ -29,12 +31,14 @@ func TestState(t *testing.T) {
|
|||
reset := func() {
|
||||
store = types.NewMemKVStore()
|
||||
state = NewState(store)
|
||||
state.SetLogger(log.TestingLogger())
|
||||
cache = state.CacheWrap()
|
||||
}
|
||||
|
||||
//set the state to using the eyesCli instead of MemKVStore
|
||||
useEyesCli := func() {
|
||||
state = NewState(eyesCli)
|
||||
state.SetLogger(log.TestingLogger())
|
||||
cache = state.CacheWrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,15 +8,17 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/basecoin/app"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/go-wire"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
eyescli "github.com/tendermint/merkleeyes/client"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
|
||||
func TestSendTx(t *testing.T) {
|
||||
eyesCli := eyescli.NewLocalClient("", 0)
|
||||
chainID := "test_chain_id"
|
||||
bcApp := app.NewBasecoin(eyesCli)
|
||||
bcApp.SetLogger(log.TestingLogger().With("module", "app"))
|
||||
bcApp.SetOption("base/chain_id", chainID)
|
||||
// t.Log(bcApp.Info())
|
||||
|
||||
|
|
Loading…
Reference in New Issue