Query uses type bytes
This commit is contained in:
parent
a63bc3fc46
commit
f491c8d8fb
32
app/app.go
32
app/app.go
|
@ -17,9 +17,11 @@ const (
|
||||||
maxTxSize = 10240
|
maxTxSize = 10240
|
||||||
|
|
||||||
typeByteBase = 0x01
|
typeByteBase = 0x01
|
||||||
typeByteGov = 0x02
|
typeByteEyes = 0x02
|
||||||
|
typeByteGov = 0x03
|
||||||
|
|
||||||
pluginNameBase = "base"
|
pluginNameBase = "base"
|
||||||
|
pluginNameEyes = "eyes"
|
||||||
pluginNameGov = "gov"
|
pluginNameGov = "gov"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -122,21 +124,21 @@ func (app *Basecoin) CheckTx(txBytes []byte) (res tmsp.Result) {
|
||||||
|
|
||||||
// TMSP::Query
|
// TMSP::Query
|
||||||
func (app *Basecoin) Query(query []byte) (res tmsp.Result) {
|
func (app *Basecoin) Query(query []byte) (res tmsp.Result) {
|
||||||
pluginName, queryStr := splitKey(string(query))
|
if len(query) == 0 {
|
||||||
if pluginName != pluginNameBase {
|
return tmsp.ErrEncodingError.SetLog("Query cannot be zero length")
|
||||||
plugin := app.plugins.GetByName(pluginName)
|
|
||||||
if plugin == nil {
|
|
||||||
return tmsp.ErrBaseUnknownPlugin.SetLog(Fmt("Unknown plugin %v", pluginName))
|
|
||||||
}
|
|
||||||
return plugin.Query([]byte(queryStr))
|
|
||||||
} else {
|
|
||||||
// TODO turn Basecoin ops into a plugin?
|
|
||||||
res = app.eyesCli.GetSync([]byte(queryStr))
|
|
||||||
if res.IsErr() {
|
|
||||||
return res.PrependLog("Error querying eyesCli")
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
typeByte := query[0]
|
||||||
|
query = query[1:]
|
||||||
|
switch typeByte {
|
||||||
|
case typeByteBase:
|
||||||
|
return tmsp.OK.SetLog("This type of query not yet supported")
|
||||||
|
case typeByteEyes:
|
||||||
|
return app.eyesCli.QuerySync(query)
|
||||||
|
case typeByteGov:
|
||||||
|
return app.govMint.Query(query)
|
||||||
|
}
|
||||||
|
return tmsp.ErrBaseUnknownPlugin.SetLog(
|
||||||
|
Fmt("Unknown plugin with type byte %X", typeByte))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TMSP::Commit
|
// TMSP::Commit
|
||||||
|
|
|
@ -18,6 +18,7 @@ Account Types:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type Tx interface {
|
type Tx interface {
|
||||||
|
AssertIsTx()
|
||||||
SignBytes(chainID string) []byte
|
SignBytes(chainID string) []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +29,9 @@ const (
|
||||||
TxTypeApp = byte(0x02)
|
TxTypeApp = byte(0x02)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (_ *SendTx) AssertIsTx() {}
|
||||||
|
func (_ *AppTx) AssertIsTx() {}
|
||||||
|
|
||||||
var _ = wire.RegisterInterface(
|
var _ = wire.RegisterInterface(
|
||||||
struct{ Tx }{},
|
struct{ Tx }{},
|
||||||
wire.ConcreteType{&SendTx{}, TxTypeSend},
|
wire.ConcreteType{&SendTx{}, TxTypeSend},
|
||||||
|
|
Loading…
Reference in New Issue