github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/bft/rpc/lib/client/client.go (about)

     1  package rpcclient
     2  
     3  import (
     4  	"context"
     5  
     6  	types "github.com/gnolang/gno/tm2/pkg/bft/rpc/lib/types"
     7  )
     8  
     9  // Client is the JSON-RPC client abstraction
    10  type Client interface {
    11  	// SendRequest sends a single RPC request to the JSON-RPC layer
    12  	SendRequest(context.Context, types.RPCRequest) (*types.RPCResponse, error)
    13  
    14  	// SendBatch sends a batch of RPC requests to the JSON-RPC layer
    15  	SendBatch(context.Context, types.RPCRequests) (types.RPCResponses, error)
    16  
    17  	// Close closes the RPC client
    18  	Close() error
    19  }
    20  
    21  // Batch is the JSON-RPC batch abstraction
    22  type Batch interface {
    23  	// AddRequest adds a single request to the RPC batch
    24  	AddRequest(types.RPCRequest)
    25  
    26  	// Send sends the batch to the RPC layer
    27  	Send(context.Context) (types.RPCResponses, error)
    28  
    29  	// Clear clears out the batch
    30  	Clear() int
    31  
    32  	// Count returns the number of enqueued requests
    33  	Count() int
    34  }