enable ibc by default

This commit is contained in:
Ethan Buchman 2017-02-13 17:04:49 -05:00
parent 1d8f59644f
commit 558df7da15
7 changed files with 27 additions and 21 deletions

View File

@ -51,14 +51,15 @@ func (app *Basecoin) RegisterPlugin(plugin types.Plugin) {
}
// ABCI::SetOption
func (app *Basecoin) SetOption(key string, value string) (log string) {
PluginName, key := splitKey(key)
if PluginName != PluginNameBase {
func (app *Basecoin) SetOption(key string, value string) string {
pluginName, key := splitKey(key)
if pluginName != PluginNameBase {
// Set option on plugin
plugin := app.plugins.GetByName(PluginName)
plugin := app.plugins.GetByName(pluginName)
if plugin == nil {
return "Invalid plugin name: " + PluginName
return "Invalid plugin name: " + pluginName
}
log.Info("SetOption on plugin", "plugin", pluginName, "key", key, "value", value)
return plugin.SetOption(app.state, key, value)
} else {
// Set option on basecoin
@ -74,6 +75,7 @@ func (app *Basecoin) SetOption(key string, value string) (log string) {
return "Error decoding acc message: " + err.Error()
}
app.state.SetAccount(acc.PubKey.Address(), acc)
log.Info("SetAccount", "addr", acc.PubKey.Address(), "acc", acc)
return "Success"
}
return "Unrecognized option key " + key

View File

@ -17,7 +17,7 @@ func (app *Basecoin) LoadGenesis(path string) error {
for _, kv := range kvz {
log := app.SetOption(kv.Key, kv.Value)
// TODO: remove debug output
fmt.Printf("Set %v=%v. Log: %v", kv.Key, kv.Value, log)
fmt.Printf("Set %v=%v. Log: %v\n", kv.Key, kv.Value, log)
}
return nil
}

View File

@ -17,8 +17,8 @@ func main() {
commands.TxCmd,
commands.QueryCmd,
commands.KeyCmd,
commands.VerifyCmd, // TODO: move to merkleeyes?
commands.BlockCmd, // TODO: move to adam?
commands.VerifyCmd,
commands.BlockCmd,
commands.AccountCmd,
}
app.Run(os.Args)

View File

@ -9,7 +9,6 @@ import (
"github.com/urfave/cli"
"github.com/tendermint/basecoin/plugins/ibc"
"github.com/tendermint/basecoin/types"
cmn "github.com/tendermint/go-common"
"github.com/tendermint/go-merkle"
@ -17,10 +16,9 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
)
// Register the IBC plugin at start and for transactions
func RegisterIBC() {
RegisterTxSubcommand(IbcCmd)
RegisterStartPlugin("ibc", func() types.Plugin { return ibc.New() })
// returns a new IBC plugin to be registered with Basecoin
func NewIBCPlugin() *ibc.IBCPlugin {
return ibc.New()
}
//---------------------------------------------------------------------
@ -104,9 +102,9 @@ var (
// ibc commands
var (
IbcCmd = cli.Command{
IbcTxCmd = cli.Command{
Name: "ibc",
Usage: "Send a transaction to the interblockchain (ibc) plugin",
Usage: "an IBC transaction, for InterBlockchain Communication",
Flags: TxFlags,
Subcommands: []cli.Command{
IbcRegisterTxCmd,

View File

@ -72,7 +72,10 @@ func cmdStart(c *cli.Context) error {
// Create Basecoin app
basecoinApp := app.NewBasecoin(eyesCli)
// register all plugins
// register IBC plugn
basecoinApp.RegisterPlugin(NewIBCPlugin())
// register all other plugins
for _, p := range plugins {
basecoinApp.RegisterPlugin(p.newPlugin())
}
@ -91,7 +94,9 @@ func cmdStart(c *cli.Context) error {
if c.Bool("in-proc") {
startTendermint(c, basecoinApp)
} else {
startBasecoinABCI(c, basecoinApp)
if err := startBasecoinABCI(c, basecoinApp); err != nil {
return err
}
}
return nil

View File

@ -37,12 +37,13 @@ var (
Subcommands: []cli.Command{
SendTxCmd,
AppTxCmd,
IbcTxCmd,
},
}
SendTxCmd = cli.Command{
Name: "send",
Usage: "Create, sign, and broadcast a SendTx transaction",
Usage: "a SendTx transaction, for sending tokens around",
ArgsUsage: "",
Action: func(c *cli.Context) error {
return cmdSendTx(c)
@ -52,7 +53,7 @@ var (
AppTxCmd = cli.Command{
Name: "app",
Usage: "Create, sign, and broadcast a raw AppTx transaction",
Usage: "an AppTx transaction, for sending raw data to plugins",
ArgsUsage: "",
Action: func(c *cli.Context) error {
return cmdAppTx(c)

View File

@ -95,7 +95,7 @@ func ExecTx(state *State, pgz *types.Plugins, tx types.Tx, isCheckTx bool, evc e
}
if !tx.Input.Coins.IsGTE(types.Coins{tx.Fee}) {
log.Info(Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address))
return abci.ErrBaseInsufficientFunds
return abci.ErrBaseInsufficientFunds.AppendLog(Fmt("input coins is %d, but fee is %d", tx.Input.Coins, types.Coins{tx.Fee}))
}
// Validate call address
@ -238,7 +238,7 @@ func validateInputAdvanced(acc *types.Account, signBytes []byte, in types.TxInpu
}
// Check amount
if !balance.IsGTE(in.Coins) {
return abci.ErrBaseInsufficientFunds
return abci.ErrBaseInsufficientFunds.AppendLog(Fmt("balance is %d, tried to send %d", balance, in.Coins))
}
// Check signatures
if !acc.PubKey.VerifyBytes(signBytes, in.Signature) {