Add Query; Add benchmark tests

This commit is contained in:
Jae Kwon
2016-01-18 14:37:42 -08:00
parent ca259ce82a
commit 3f812038a4
9 changed files with 256 additions and 54 deletions

View File

@ -29,7 +29,7 @@ func (app *CounterApplication) SetOption(key string, value string) types.RetCode
if key == "serial" && value == "on" {
app.serial = true
}
return 0
return types.RetCodeOK
}
func (app *CounterApplication) AppendTx(tx []byte) ([]types.Event, types.RetCode) {
@ -42,7 +42,7 @@ func (app *CounterApplication) AppendTx(tx []byte) ([]types.Event, types.RetCode
}
}
app.txCount += 1
return nil, 0
return nil, types.RetCodeOK
}
func (app *CounterApplication) CheckTx(tx []byte) types.RetCode {
@ -54,25 +54,29 @@ func (app *CounterApplication) CheckTx(tx []byte) types.RetCode {
return types.RetCodeBadNonce
}
}
return 0
return types.RetCodeOK
}
func (app *CounterApplication) GetHash() ([]byte, types.RetCode) {
app.hashCount += 1
if app.txCount == 0 {
return nil, 0
return nil, types.RetCodeOK
} else {
hash := make([]byte, 32)
binary.LittleEndian.PutUint64(hash, uint64(app.txCount))
return hash, 0
return hash, types.RetCodeOK
}
}
func (app *CounterApplication) AddListener(key string) types.RetCode {
return 0
return types.RetCodeOK
}
func (app *CounterApplication) RemListener(key string) types.RetCode {
return 0
return types.RetCodeOK
}
func (app *CounterApplication) Query(query []byte) (types.RetCode, []byte) {
return types.RetCodeOK, nil
}

View File

@ -27,27 +27,31 @@ func (app *DummyApplication) Info() []string {
}
func (app *DummyApplication) SetOption(key string, value string) types.RetCode {
return 0
return types.RetCodeOK
}
func (app *DummyApplication) AppendTx(tx []byte) ([]types.Event, types.RetCode) {
app.state.Set(tx, tx)
return nil, 0
return nil, types.RetCodeOK
}
func (app *DummyApplication) CheckTx(tx []byte) types.RetCode {
return 0 // all txs are valid
return types.RetCodeOK // all txs are valid
}
func (app *DummyApplication) GetHash() ([]byte, types.RetCode) {
hash := app.state.Hash()
return hash, 0
return hash, types.RetCodeOK
}
func (app *DummyApplication) AddListener(key string) types.RetCode {
return 0
return types.RetCodeOK
}
func (app *DummyApplication) RemListener(key string) types.RetCode {
return 0
return types.RetCodeOK
}
func (app *DummyApplication) Query(query []byte) (types.RetCode, []byte) {
return types.RetCodeOK, nil
}