service

package
v2.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

Block SDK Mempool Service

The Block SDK mempool service is a service that allows you to query the current state of the application side mempool.

Usage

The mempool service is a standard gRPC service that can be paired with http or grpc clients.

HTTP Clients

To make requests to the mempool service using HTTP, you have to use the grpc-gateway defined on your application's server. This is usually hosted on port 1317.

gRPC Clients

To query the mempool service using gRPC, you can use the Mempool ServiceClient defined in types:

type serviceClient struct {
	cc grpc1.ClientConn
}

func NewServiceClient(cc grpc1.ClientConn) ServiceClient {
	return &serviceClient{cc}
}

func (c *serviceClient) GetTxDistribution(ctx context.Context, in *GetTxDistributionRequest, opts ...grpc.CallOption) (*GetTxDistributionResponse, error) {
	out := new(GetTxDistributionResponse)
	err := c.cc.Invoke(ctx, "/sdk.mempool.v1.Service/GetTxDistribution", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

Endpoints

GetTxDistribution

GetTxDistribution returns the current distribution of transactions in the mempool. The response is a map of the lane name to the number of transactions in that lane.

type GetTxDistributionRequest struct {}

type GetTxDistributionResponse struct {
    Distribution map[string]uint64
}
HTTP Requests

To query the mempool service using HTTP, you can use the following endpoint:

curl http://localhost:1317/block-sdk/mempool/v1/distribution

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGRPCGatewayRoutes

func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux)

RegisterGRPCGatewayRoutes mounts the Block SDK mempool service's GRPC-gateway routes on the given Mux.

func RegisterMempoolService

func RegisterMempoolService(
	server gogogrpc.Server,
	mempool block.Mempool,
)

Types

type QueryService

type QueryService struct {
	types.UnimplementedServiceServer
	// contains filtered or unexported fields
}

QueryService defines the service used by the gRPC query server to query the Block SDK mempool.

func NewQueryService

func NewQueryService(mempool block.Mempool) *QueryService

NewQueryService creates a new QueryService instance.

func (*QueryService) GetTxDistribution

GetTxDistribution returns the current distribution of transactions in the mempool.

Directories

Path Synopsis
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL