enable ibc by default
This commit is contained in:
parent
1d8f59644f
commit
558df7da15
12
app/app.go
12
app/app.go
|
@ -51,14 +51,15 @@ func (app *Basecoin) RegisterPlugin(plugin types.Plugin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABCI::SetOption
|
// ABCI::SetOption
|
||||||
func (app *Basecoin) SetOption(key string, value string) (log string) {
|
func (app *Basecoin) SetOption(key string, value string) string {
|
||||||
PluginName, key := splitKey(key)
|
pluginName, key := splitKey(key)
|
||||||
if PluginName != PluginNameBase {
|
if pluginName != PluginNameBase {
|
||||||
// Set option on plugin
|
// Set option on plugin
|
||||||
plugin := app.plugins.GetByName(PluginName)
|
plugin := app.plugins.GetByName(pluginName)
|
||||||
if plugin == nil {
|
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)
|
return plugin.SetOption(app.state, key, value)
|
||||||
} else {
|
} else {
|
||||||
// Set option on basecoin
|
// 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()
|
return "Error decoding acc message: " + err.Error()
|
||||||
}
|
}
|
||||||
app.state.SetAccount(acc.PubKey.Address(), acc)
|
app.state.SetAccount(acc.PubKey.Address(), acc)
|
||||||
|
log.Info("SetAccount", "addr", acc.PubKey.Address(), "acc", acc)
|
||||||
return "Success"
|
return "Success"
|
||||||
}
|
}
|
||||||
return "Unrecognized option key " + key
|
return "Unrecognized option key " + key
|
||||||
|
|
|
@ -17,7 +17,7 @@ func (app *Basecoin) LoadGenesis(path string) error {
|
||||||
for _, kv := range kvz {
|
for _, kv := range kvz {
|
||||||
log := app.SetOption(kv.Key, kv.Value)
|
log := app.SetOption(kv.Key, kv.Value)
|
||||||
// TODO: remove debug output
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ func main() {
|
||||||
commands.TxCmd,
|
commands.TxCmd,
|
||||||
commands.QueryCmd,
|
commands.QueryCmd,
|
||||||
commands.KeyCmd,
|
commands.KeyCmd,
|
||||||
commands.VerifyCmd, // TODO: move to merkleeyes?
|
commands.VerifyCmd,
|
||||||
commands.BlockCmd, // TODO: move to adam?
|
commands.BlockCmd,
|
||||||
commands.AccountCmd,
|
commands.AccountCmd,
|
||||||
}
|
}
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
|
|
||||||
"github.com/tendermint/basecoin/plugins/ibc"
|
"github.com/tendermint/basecoin/plugins/ibc"
|
||||||
"github.com/tendermint/basecoin/types"
|
|
||||||
|
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
"github.com/tendermint/go-merkle"
|
"github.com/tendermint/go-merkle"
|
||||||
|
@ -17,10 +16,9 @@ import (
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register the IBC plugin at start and for transactions
|
// returns a new IBC plugin to be registered with Basecoin
|
||||||
func RegisterIBC() {
|
func NewIBCPlugin() *ibc.IBCPlugin {
|
||||||
RegisterTxSubcommand(IbcCmd)
|
return ibc.New()
|
||||||
RegisterStartPlugin("ibc", func() types.Plugin { return ibc.New() })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
@ -104,9 +102,9 @@ var (
|
||||||
// ibc commands
|
// ibc commands
|
||||||
|
|
||||||
var (
|
var (
|
||||||
IbcCmd = cli.Command{
|
IbcTxCmd = cli.Command{
|
||||||
Name: "ibc",
|
Name: "ibc",
|
||||||
Usage: "Send a transaction to the interblockchain (ibc) plugin",
|
Usage: "an IBC transaction, for InterBlockchain Communication",
|
||||||
Flags: TxFlags,
|
Flags: TxFlags,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
IbcRegisterTxCmd,
|
IbcRegisterTxCmd,
|
||||||
|
|
|
@ -72,7 +72,10 @@ func cmdStart(c *cli.Context) error {
|
||||||
// Create Basecoin app
|
// Create Basecoin app
|
||||||
basecoinApp := app.NewBasecoin(eyesCli)
|
basecoinApp := app.NewBasecoin(eyesCli)
|
||||||
|
|
||||||
// register all plugins
|
// register IBC plugn
|
||||||
|
basecoinApp.RegisterPlugin(NewIBCPlugin())
|
||||||
|
|
||||||
|
// register all other plugins
|
||||||
for _, p := range plugins {
|
for _, p := range plugins {
|
||||||
basecoinApp.RegisterPlugin(p.newPlugin())
|
basecoinApp.RegisterPlugin(p.newPlugin())
|
||||||
}
|
}
|
||||||
|
@ -91,7 +94,9 @@ func cmdStart(c *cli.Context) error {
|
||||||
if c.Bool("in-proc") {
|
if c.Bool("in-proc") {
|
||||||
startTendermint(c, basecoinApp)
|
startTendermint(c, basecoinApp)
|
||||||
} else {
|
} else {
|
||||||
startBasecoinABCI(c, basecoinApp)
|
if err := startBasecoinABCI(c, basecoinApp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -37,12 +37,13 @@ var (
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
SendTxCmd,
|
SendTxCmd,
|
||||||
AppTxCmd,
|
AppTxCmd,
|
||||||
|
IbcTxCmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTxCmd = cli.Command{
|
SendTxCmd = cli.Command{
|
||||||
Name: "send",
|
Name: "send",
|
||||||
Usage: "Create, sign, and broadcast a SendTx transaction",
|
Usage: "a SendTx transaction, for sending tokens around",
|
||||||
ArgsUsage: "",
|
ArgsUsage: "",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return cmdSendTx(c)
|
return cmdSendTx(c)
|
||||||
|
@ -52,7 +53,7 @@ var (
|
||||||
|
|
||||||
AppTxCmd = cli.Command{
|
AppTxCmd = cli.Command{
|
||||||
Name: "app",
|
Name: "app",
|
||||||
Usage: "Create, sign, and broadcast a raw AppTx transaction",
|
Usage: "an AppTx transaction, for sending raw data to plugins",
|
||||||
ArgsUsage: "",
|
ArgsUsage: "",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return cmdAppTx(c)
|
return cmdAppTx(c)
|
||||||
|
|
|
@ -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}) {
|
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))
|
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
|
// Validate call address
|
||||||
|
@ -238,7 +238,7 @@ func validateInputAdvanced(acc *types.Account, signBytes []byte, in types.TxInpu
|
||||||
}
|
}
|
||||||
// Check amount
|
// Check amount
|
||||||
if !balance.IsGTE(in.Coins) {
|
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
|
// Check signatures
|
||||||
if !acc.PubKey.VerifyBytes(signBytes, in.Signature) {
|
if !acc.PubKey.VerifyBytes(signBytes, in.Signature) {
|
||||||
|
|
Loading…
Reference in New Issue