Some checks are pending
docker-build-cometbft / vars (push) Waiting to run
docker-build-cometbft / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-cometbft / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-cometbft / merge-images (push) Blocked by required conditions
docker-build-e2e-node / vars (push) Waiting to run
docker-build-e2e-node / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-e2e-node / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-e2e-node / merge-images (push) Blocked by required conditions
40 lines
1 KiB
Go
40 lines
1 KiB
Go
package coregrpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
abci "github.com/cometbft/cometbft/abci/types"
|
|
core "github.com/cometbft/cometbft/rpc/core"
|
|
rpctypes "github.com/cometbft/cometbft/rpc/jsonrpc/types"
|
|
)
|
|
|
|
type broadcastAPI struct {
|
|
env *core.Environment
|
|
}
|
|
|
|
func (bapi *broadcastAPI) Ping(context.Context, *RequestPing) (*ResponsePing, error) {
|
|
// kvstore so we can check if the server is up
|
|
return &ResponsePing{}, nil
|
|
}
|
|
|
|
func (bapi *broadcastAPI) BroadcastTx(_ context.Context, req *RequestBroadcastTx) (*ResponseBroadcastTx, error) {
|
|
// NOTE: there's no way to get client's remote address
|
|
// see https://stackoverflow.com/questions/33684570/session-and-remote-ip-address-in-grpc-go
|
|
res, err := bapi.env.BroadcastTxCommit(&rpctypes.Context{}, req.Tx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &ResponseBroadcastTx{
|
|
CheckTx: &abci.ResponseCheckTx{
|
|
Code: res.CheckTx.Code,
|
|
Data: res.CheckTx.Data,
|
|
Log: res.CheckTx.Log,
|
|
},
|
|
TxResult: &abci.ExecTxResult{
|
|
Code: res.TxResult.Code,
|
|
Data: res.TxResult.Data,
|
|
Log: res.TxResult.Log,
|
|
},
|
|
}, nil
|
|
}
|