Browse Source

Conform to protobuf TMSP

pull/192/head
Jae Kwon 9 years ago
parent
commit
3f49b509d2
3 changed files with 19 additions and 20 deletions
  1. +5
    -6
      mempool/mempool.go
  2. +10
    -10
      proxy/local_app_conn.go
  3. +4
    -4
      state/execution.go

+ 5
- 6
mempool/mempool.go View File

@ -101,16 +101,15 @@ func (mem *Mempool) CheckTx(tx types.Tx) (err error) {
}
// TMSP callback function
func (mem *Mempool) resCb(req tmsp.Request, res tmsp.Response) {
switch res := res.(type) {
case tmsp.ResponseCheckTx:
reqCheckTx := req.(tmsp.RequestCheckTx)
if res.Code == tmsp.RetCodeOK {
func (mem *Mempool) resCb(req *tmsp.Request, res *tmsp.Response) {
switch res.Type {
case tmsp.ResponseTypeCheckTx:
if tmsp.RetCode(res.Code) == tmsp.RetCodeOK {
mem.counter++
memTx := &mempoolTx{
counter: mem.counter,
height: int64(mem.height),
tx: reqCheckTx.TxBytes,
tx: req.Data,
}
mem.txs.PushBack(memTx)
} else {


+ 10
- 10
proxy/local_app_conn.go View File

@ -32,8 +32,8 @@ func (app *localAppConn) Error() error {
func (app *localAppConn) EchoAsync(msg string) {
app.Callback(
tmsp.RequestEcho{msg},
tmsp.ResponseEcho{msg},
tmsp.RequestEcho(msg),
tmsp.ResponseEcho(msg),
)
}
@ -46,8 +46,8 @@ func (app *localAppConn) SetOptionAsync(key string, value string) {
log := app.Application.SetOption(key, value)
app.mtx.Unlock()
app.Callback(
tmsp.RequestSetOption{key, value},
tmsp.ResponseSetOption{log},
tmsp.RequestSetOption(key, value),
tmsp.ResponseSetOption(log),
)
}
@ -56,8 +56,8 @@ func (app *localAppConn) AppendTxAsync(tx []byte) {
code, result, log := app.Application.AppendTx(tx)
app.mtx.Unlock()
app.Callback(
tmsp.RequestAppendTx{tx},
tmsp.ResponseAppendTx{code, result, log},
tmsp.RequestAppendTx(tx),
tmsp.ResponseAppendTx(code, result, log),
)
}
@ -66,8 +66,8 @@ func (app *localAppConn) CheckTxAsync(tx []byte) {
code, result, log := app.Application.CheckTx(tx)
app.mtx.Unlock()
app.Callback(
tmsp.RequestCheckTx{tx},
tmsp.ResponseCheckTx{code, result, log},
tmsp.RequestCheckTx(tx),
tmsp.ResponseCheckTx(code, result, log),
)
}
@ -76,8 +76,8 @@ func (app *localAppConn) GetHashAsync() {
hash, log := app.Application.GetHash()
app.mtx.Unlock()
app.Callback(
tmsp.RequestGetHash{},
tmsp.ResponseGetHash{hash, log},
tmsp.RequestGetHash(),
tmsp.ResponseGetHash(hash, log),
)
}


+ 4
- 4
state/execution.go View File

@ -60,14 +60,14 @@ func (s *State) execBlockOnProxyApp(evsw *events.EventSwitch, proxyAppConn proxy
var validTxs, invalidTxs = 0, 0
// Execute transactions and get hash
proxyCb := func(req tmsp.Request, res tmsp.Response) {
switch res := res.(type) {
case tmsp.ResponseAppendTx:
proxyCb := func(req *tmsp.Request, res *tmsp.Response) {
switch res.Type {
case tmsp.ResponseTypeAppendTx:
// TODO: make use of res.Log
// TODO: make use of this info
// Blocks may include invalid txs.
// reqAppendTx := req.(tmsp.RequestAppendTx)
if res.Code == tmsp.RetCodeOK {
if tmsp.RetCode(res.Code) == tmsp.RetCodeOK {
validTxs += 1
} else {
log.Debug("Invalid tx", "code", res.Code, "log", res.Log)


Loading…
Cancel
Save