github.com/number571/tendermint@v0.34.11-gost/rpc/grpc/api.go (about)

     1  package coregrpc
     2  
     3  import (
     4  	"context"
     5  
     6  	abci "github.com/number571/tendermint/abci/types"
     7  	core "github.com/number571/tendermint/rpc/core"
     8  	rpctypes "github.com/number571/tendermint/rpc/jsonrpc/types"
     9  )
    10  
    11  type broadcastAPI struct {
    12  	env *core.Environment
    13  }
    14  
    15  func (bapi *broadcastAPI) Ping(ctx context.Context, req *RequestPing) (*ResponsePing, error) {
    16  	// kvstore so we can check if the server is up
    17  	return &ResponsePing{}, nil
    18  }
    19  
    20  // Deprecated: gRPC  in the RPC layer of Tendermint will be removed in 0.36.
    21  func (bapi *broadcastAPI) BroadcastTx(ctx context.Context, req *RequestBroadcastTx) (*ResponseBroadcastTx, error) {
    22  	// NOTE: there's no way to get client's remote address
    23  	// see https://stackoverflow.com/questions/33684570/session-and-remote-ip-address-in-grpc-go
    24  	res, err := bapi.env.BroadcastTxCommit(&rpctypes.Context{}, req.Tx)
    25  	if err != nil {
    26  		return nil, err
    27  	}
    28  
    29  	return &ResponseBroadcastTx{
    30  		CheckTx: &abci.ResponseCheckTx{
    31  			Code: res.CheckTx.Code,
    32  			Data: res.CheckTx.Data,
    33  			Log:  res.CheckTx.Log,
    34  		},
    35  		DeliverTx: &abci.ResponseDeliverTx{
    36  			Code: res.DeliverTx.Code,
    37  			Data: res.DeliverTx.Data,
    38  			Log:  res.DeliverTx.Log,
    39  		},
    40  	}, nil
    41  }