7
pbapi "gitverse.ru/IvanTimofeev/cranberry/pkg/grpc"
8
grpc "google.golang.org/grpc"
9
"google.golang.org/grpc/credentials/insecure"
12
type CranberryClient struct {
17
func NewCranberryClient(host string, port int) *CranberryClient {
18
return &CranberryClient{
24
func (crc *CranberryClient) SendTx(tx *pbapi.Tx, pubKey []byte, signature *pbapi.Signature) error {
25
conn, err := grpc.NewClient(fmt.Sprintf("%s:%d", crc.host, crc.port),
26
grpc.WithTransportCredentials(insecure.NewCredentials()))
31
client := pbapi.NewCranberryServiceClient(conn)
32
_, err = client.SendTx(context.Background(), &pbapi.SendTxRequest{
43
func (crc *CranberryClient) GetBlockByHeight(height uint64) (*pbapi.GetBlockByHeightResponse, error) {
44
conn, err := grpc.NewClient(fmt.Sprintf("%s:%d", crc.host, crc.port),
45
grpc.WithTransportCredentials(insecure.NewCredentials()))
50
client := pbapi.NewCranberryServiceClient(conn)
51
return client.GetBlockByHeight(context.Background(), &pbapi.GetBlockByHeightRequest{