func (app *MerkleEyesApp) Commit() tmsp.Result { if app.tree.Size() == 0 { return tmsp.NewResultOK(nil, "Empty hash for empty tree") } hash := app.tree.Hash() return tmsp.NewResultOK(hash, "") }
func (cli *grpcClient) InfoSync() (res types.Result) { reqres := cli.InfoAsync() if res := cli.checkErrGetResult(); res.IsErr() { return res } resp := reqres.Response.GetInfo() return types.NewResultOK([]byte(resp.Info), LOG) }
func (cli *grpcClient) EchoSync(msg string) (res types.Result) { reqres := cli.EchoAsync(msg) if res := cli.checkErrGetResult(); res.IsErr() { return res } resp := reqres.Response.GetEcho() return types.NewResultOK([]byte(resp.Message), LOG) }
func (app *CounterApplication) Commit() tmsp.Result { app.mempoolTxCount = app.txCount if app.txCount == 0 { return tmsp.OK } else { hash := make([]byte, 8) binary.BigEndian.PutUint64(hash, uint64(app.txCount)) return tmsp.NewResultOK(hash, "") } }
func (app *CounterApplication) Commit() types.Result { app.hashCount += 1 if app.txCount == 0 { return types.OK } else { hash := make([]byte, 8) binary.BigEndian.PutUint64(hash, uint64(app.txCount)) return types.NewResultOK(hash, "") } }
func (client *Client) GetSync(key []byte) (res tmsp.Result) { query := make([]byte, 1+wire.ByteSliceSize(key)) buf := query buf[0] = 0x01 // Get TypeByte buf = buf[1:] wire.PutByteSlice(buf, key) res = client.QuerySync(query) if res.IsErr() { return res } value := res.Data return tmsp.NewResultOK(value, "") }
func (app *MerkleEyesApp) Query(query []byte) tmsp.Result { if len(query) == 0 { return tmsp.OK } typeByte := query[0] query = query[1:] switch typeByte { case 0x01: // Get by key key, n, err := wire.GetByteSlice(query) if err != nil { return tmsp.ErrEncodingError.SetLog(Fmt("Error getting key: %v", err.Error())) } query = query[n:] if len(query) != 0 { return tmsp.ErrEncodingError.SetLog(Fmt("Got bytes left over")) } _, value, _ := app.tree.Get(key) return tmsp.NewResultOK(value, "") case 0x02: // Get by index index, n, err := wire.GetVarint(query) if err != nil { return tmsp.ErrEncodingError.SetLog(Fmt("Error getting index: %v", err.Error())) } query = query[n:] if len(query) != 0 { return tmsp.ErrEncodingError.SetLog(Fmt("Got bytes left over")) } _, value := app.tree.GetByIndex(index) return tmsp.NewResultOK(value, "") case 0x03: // Get size size := app.tree.Size() res := wire.BinaryBytes(size) return tmsp.NewResultOK(res, "") default: return tmsp.ErrUnknownRequest.SetLog(Fmt("Unexpected Query type byte %X", typeByte)) } }
func (app *DummyApplication) Query(query []byte) types.Result { index, value, exists := app.state.Get(query) resStr := Fmt("Index=%v value=%v exists=%v", index, string(value), exists) return types.NewResultOK([]byte(resStr), "") }
func (app *DummyApplication) Commit() types.Result { hash := app.state.Hash() return types.NewResultOK(hash, "") }
func (app *CounterApplication) Query(query []byte) tmsp.Result { return tmsp.NewResultOK(nil, Fmt("Query is not supported")) }
func (app *CounterApplication) Query(query []byte) types.Result { return types.NewResultOK(nil, fmt.Sprintf("Query is not supported")) }
func (app *NilApplication) Query(query []byte) types.Result { return types.NewResultOK(nil, "") }
func (app *NilApplication) Commit() types.Result { return types.NewResultOK([]byte("nil"), "") }
func (app *NilApplication) CheckTx(tx []byte) types.Result { return types.NewResultOK(nil, "") }