tendermint/rpc/grpc/api.go

37 lines
824 B
Go
Raw Normal View History

2016-06-21 10:19:49 -07:00
package core_grpc
import (
2017-11-14 14:30:00 -08:00
"context"
2016-06-21 10:19:49 -07:00
abci "github.com/tendermint/abci/types"
2017-10-04 13:40:45 -07:00
core "github.com/tendermint/tendermint/rpc/core"
2016-06-21 10:19:49 -07:00
)
type broadcastAPI struct {
}
func (bapi *broadcastAPI) Ping(ctx context.Context, req *RequestPing) (*ResponsePing, error) {
// dummy so we can check if the server is up
return &ResponsePing{}, nil
}
2016-06-21 10:19:49 -07:00
func (bapi *broadcastAPI) BroadcastTx(ctx context.Context, req *RequestBroadcastTx) (*ResponseBroadcastTx, error) {
res, err := core.BroadcastTxCommit(req.Tx)
if err != nil {
2016-06-21 10:19:49 -07:00
return nil, err
}
return &ResponseBroadcastTx{
CheckTx: &abci.ResponseCheckTx{
Code: res.CheckTx.Code,
Data: res.CheckTx.Data,
Log: res.CheckTx.Log,
},
DeliverTx: &abci.ResponseDeliverTx{
Code: res.DeliverTx.Code,
Data: res.DeliverTx.Data,
Log: res.DeliverTx.Log,
},
}, nil
2016-06-21 10:19:49 -07:00
}