localrpc

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForwardTranslateBClaims

func ForwardTranslateBClaims(f *from.BClaims) (*to.BClaims, error)

func ForwardTranslateBlockHeader

func ForwardTranslateBlockHeader(f *from.BlockHeader) (*to.BlockHeader, error)

func ForwardTranslateByte

func ForwardTranslateByte(in []byte) string

func ForwardTranslateByteSlice

func ForwardTranslateByteSlice(in [][]byte) ([]string, error)

func ForwardTranslateDSLinker

func ForwardTranslateDSLinker(f *from.DSLinker) (*to.DSLinker, error)

func ForwardTranslateDSPreImage

func ForwardTranslateDSPreImage(f *from.DSPreImage) (*to.DSPreImage, error)

func ForwardTranslateDataStore

func ForwardTranslateDataStore(f *from.DataStore) (*to.DataStore, error)

func ForwardTranslateNHClaimsNHClaims

func ForwardTranslateNHClaimsNHClaims(f *from.NHClaims) (*to.NHClaims, error)

func ForwardTranslateNRClaimsNRClaims

func ForwardTranslateNRClaimsNRClaims(f *from.NRClaims) (*to.NRClaims, error)

func ForwardTranslateNextHeight

func ForwardTranslateNextHeight(f *from.NextHeight) (*to.NextHeight, error)

func ForwardTranslateNextRound

func ForwardTranslateNextRound(f *from.NextRound) (*to.NextRound, error)

func ForwardTranslatePClaims

func ForwardTranslatePClaims(f *from.PClaims) (*to.PClaims, error)

func ForwardTranslatePreCommit

func ForwardTranslatePreCommit(f *from.PreCommit) (*to.PreCommit, error)

func ForwardTranslatePreVote

func ForwardTranslatePreVote(f *from.PreVote) (*to.PreVote, error)

func ForwardTranslatePreVoteNil

func ForwardTranslatePreVoteNil(f *from.PreVoteNil) (*to.PreVoteNil, error)

func ForwardTranslateProposal

func ForwardTranslateProposal(f *from.Proposal) (*to.Proposal, error)

func ForwardTranslateRCert

func ForwardTranslateRCert(f *from.RCert) (*to.RCert, error)

func ForwardTranslateRClaims

func ForwardTranslateRClaims(f *from.RClaims) (*to.RClaims, error)

func ForwardTranslateTXIn

func ForwardTranslateTXIn(f *from.TXIn) (*to.TXIn, error)

func ForwardTranslateTXInLinker

func ForwardTranslateTXInLinker(f *from.TXInLinker) (*to.TXInLinker, error)

func ForwardTranslateTXInPreImage

func ForwardTranslateTXInPreImage(f *from.TXInPreImage) (*to.TXInPreImage, error)

func ForwardTranslateTXOut

func ForwardTranslateTXOut(f *from.TXOut) (*to.TXOut, error)

func ForwardTranslateTx

func ForwardTranslateTx(f *from.Tx) (*to.Tx, error)

func ForwardTranslateVSPreImage

func ForwardTranslateVSPreImage(f *from.VSPreImage) (*to.VSPreImage, error)

func ForwardTranslateValueStore

func ForwardTranslateValueStore(f *from.ValueStore) (*to.ValueStore, error)

func ReverseTranslateBClaims

func ReverseTranslateBClaims(f *from.BClaims) (*to.BClaims, error)

func ReverseTranslateBlockHeader

func ReverseTranslateBlockHeader(f *from.BlockHeader) (*to.BlockHeader, error)

func ReverseTranslateByte

func ReverseTranslateByte(in string) ([]byte, error)

func ReverseTranslateByteSlice

func ReverseTranslateByteSlice(in []string) ([][]byte, error)

func ReverseTranslateDSLinker

func ReverseTranslateDSLinker(f *from.DSLinker) (*to.DSLinker, error)

func ReverseTranslateDSPreImage

func ReverseTranslateDSPreImage(f *from.DSPreImage) (*to.DSPreImage, error)

func ReverseTranslateDataStore

func ReverseTranslateDataStore(f *from.DataStore) (*to.DataStore, error)

func ReverseTranslateNHClaims

func ReverseTranslateNHClaims(f *from.NHClaims) (*to.NHClaims, error)

func ReverseTranslateNRClaims

func ReverseTranslateNRClaims(f *from.NRClaims) (*to.NRClaims, error)

func ReverseTranslateNextHeight

func ReverseTranslateNextHeight(f *from.NextHeight) (*to.NextHeight, error)

func ReverseTranslateNextRound

func ReverseTranslateNextRound(f *from.NextRound) (*to.NextRound, error)

func ReverseTranslatePClaims

func ReverseTranslatePClaims(f *from.PClaims) (*to.PClaims, error)

func ReverseTranslatePreCommit

func ReverseTranslatePreCommit(f *from.PreCommit) (*to.PreCommit, error)

func ReverseTranslatePreVote

func ReverseTranslatePreVote(f *from.PreVote) (*to.PreVote, error)

func ReverseTranslatePreVoteNil

func ReverseTranslatePreVoteNil(f *from.PreVoteNil) (*to.PreVoteNil, error)

func ReverseTranslateProposal

func ReverseTranslateProposal(f *from.Proposal) (*to.Proposal, error)

func ReverseTranslateRCert

func ReverseTranslateRCert(f *from.RCert) (*to.RCert, error)

func ReverseTranslateRClaims

func ReverseTranslateRClaims(f *from.RClaims) (*to.RClaims, error)

func ReverseTranslateTXIn

func ReverseTranslateTXIn(f *from.TXIn) (*to.TXIn, error)

func ReverseTranslateTXInLinker

func ReverseTranslateTXInLinker(f *from.TXInLinker) (*to.TXInLinker, error)

func ReverseTranslateTXInPreImage

func ReverseTranslateTXInPreImage(f *from.TXInPreImage) (*to.TXInPreImage, error)

func ReverseTranslateTXOut

func ReverseTranslateTXOut(f *from.TXOut) (*to.TXOut, error)

func ReverseTranslateTx

func ReverseTranslateTx(f *from.Tx) (*to.Tx, error)

func ReverseTranslateVSPreImage

func ReverseTranslateVSPreImage(f *from.VSPreImage) (*to.VSPreImage, error)

func ReverseTranslateValueStore

func ReverseTranslateValueStore(f *from.ValueStore) (*to.ValueStore, error)

Types

type Client

type Client struct {
	sync.Mutex

	Address string
	TimeOut time.Duration
	// contains filtered or unexported fields
}

Client is a wrapper around the gRPC local state server. This wrapper abstracts all types back to the native type system rather than passing around the protobufs themselves All methods take in a context. Iif the provided context does not have a Deadline set on it, constants.MsgTimeout will be set as the timeout for a given request. This timeout is four seconds. The server will return timeout after three seconds to ensure that the client is informed about the success of a request with a large probability of success.

func (*Client) Close

func (lrpc *Client) Close() error

Close termnates the client connection pool Close may be called more than once. A client should not be used after close or an error will be returned.

func (*Client) Connect

func (lrpc *Client) Connect(ctx context.Context) error

Connect establishes communication between the client and the server.

func (*Client) GetBlockHeader

func (lrpc *Client) GetBlockHeader(ctx context.Context, height uint32) (*objs.BlockHeader, error)

GetBlockHeader allows a caller to request a BlockHeader by height.

func (*Client) GetBlockHeightForTx

func (lrpc *Client) GetBlockHeightForTx(ctx context.Context, txHash []byte) (uint32, error)

GetBlockHeightForTx returns the block height at which a tx was mined.

func (*Client) GetBlockNumber

func (lrpc *Client) GetBlockNumber(ctx context.Context) (uint32, error)

GetBlockNumber returns the current block number.

func (*Client) GetData

func (lrpc *Client) GetData(ctx context.Context, curveSpec constants.CurveSpec, account, index []byte) ([]byte, error)

GetData returns only the state stored in a datastore.

func (*Client) GetEpochNumber

func (lrpc *Client) GetEpochNumber(ctx context.Context) (uint32, error)

GetEpochNumber returns the current epoch number.

func (*Client) GetMinedTransaction

func (lrpc *Client) GetMinedTransaction(ctx context.Context, txHash []byte) (*aobjs.Tx, error)

GetMinedTransaction allows a caller to see if a mined tx is known. Due to state pruning, transactions will only be stored for a maximum of four epochs. after this time, the transaction is no longer available but all UTXOs are.

func (*Client) GetPendingTransaction

func (lrpc *Client) GetPendingTransaction(ctx context.Context, txHash []byte) (*aobjs.Tx, error)

GetPendingTransaction allows a caller to inspect the Pending Tx Pool to see if a tx is present.

func (*Client) GetTxFees

func (lrpc *Client) GetTxFees(ctx context.Context) ([]string, error)

TODO: Not tested and may not work.

func (*Client) GetUTXO

func (lrpc *Client) GetUTXO(ctx context.Context, utxoIDs [][]byte) (aobjs.Vout, error)

GetUTXO allows the caller to request UTXOs by ID.

func (*Client) GetValueForOwner

func (lrpc *Client) GetValueForOwner(ctx context.Context, curveSpec constants.CurveSpec, account []byte, minValue *uint256.Uint256) ([][]byte, *uint256.Uint256, error)

GetValueForOwner allows a caller to receive a list of UTXOs that are controlled by the named account.

func (*Client) PaginateDataStoreUTXOByOwner

func (lrpc *Client) PaginateDataStoreUTXOByOwner(ctx context.Context, curveSpec constants.CurveSpec, account []byte, num uint8, startIndex []byte) ([]*aobjs.PaginationResponse, error)

PaginateDataStoreUTXOByOwner allows an account namespace to be iterated so that all datastores may be observed. It also allows the query of a single datastore by setting the num param to 1 and the startIndex param to the target index of the desired datastore It returns a list of tuples of the form ( <utxoID>, <index> ).

func (*Client) SendTransaction

func (lrpc *Client) SendTransaction(ctx context.Context, tx *aobjs.Tx) ([]byte, error)

SendTransaction allows the caller to inject a tx into the pending tx pool.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler binds a Listener to a grpc server and sets up a RESTful API based on swagger. The Swagger API is a translation of the gRPC API. See the swagger docs for further details.

func NewStateServerHandler

func NewStateServerHandler(logger *logrus.Logger, addr string, service interfaces.StateServer) (*Handler, error)

NewStateServerHandler returns a RPC ServerHandler for the BootNode Service.

func (*Handler) Close

func (rpch *Handler) Close() error

Close will shutdown the server handler.

func (*Handler) Serve

func (rpch *Handler) Serve()

type Handlers

type Handlers struct {
	AppHandler *application.Application
	GossipBus  *gossip.Handlers
	Storage    dynamics.StorageGetter

	EthPubk []byte
	// contains filtered or unexported fields
}

Handlers is the server side of the local RPC system. Handlers dispatches requests to other systems for processing.

func (*Handlers) HandleLocalStateGetBlockHeader

func (srpc *Handlers) HandleLocalStateGetBlockHeader(ctx context.Context, req *pb.BlockHeaderRequest) (*pb.BlockHeaderResponse, error)

func (*Handlers) HandleLocalStateGetBlockNumber

func (srpc *Handlers) HandleLocalStateGetBlockNumber(ctx context.Context, req *pb.BlockNumberRequest) (*pb.BlockNumberResponse, error)

func (*Handlers) HandleLocalStateGetChainID

func (srpc *Handlers) HandleLocalStateGetChainID(ctx context.Context, req *pb.ChainIDRequest) (*pb.ChainIDResponse, error)

func (*Handlers) HandleLocalStateGetData

func (srpc *Handlers) HandleLocalStateGetData(ctx context.Context, req *pb.GetDataRequest) (*pb.GetDataResponse, error)

HandleLocalStateGetData ...

func (*Handlers) HandleLocalStateGetEpochNumber

func (srpc *Handlers) HandleLocalStateGetEpochNumber(ctx context.Context, req *pb.EpochNumberRequest) (*pb.EpochNumberResponse, error)

func (*Handlers) HandleLocalStateGetFees

func (srpc *Handlers) HandleLocalStateGetFees(ctx context.Context, req *pb.FeeRequest) (*pb.FeeResponse, error)

func (*Handlers) HandleLocalStateGetMinedTransaction

func (srpc *Handlers) HandleLocalStateGetMinedTransaction(ctx context.Context, req *pb.MinedTransactionRequest) (*pb.MinedTransactionResponse, error)

HandleLocalStateGetMinedTransaction ...

func (*Handlers) HandleLocalStateGetPendingTransaction

func (srpc *Handlers) HandleLocalStateGetPendingTransaction(ctx context.Context, req *pb.PendingTransactionRequest) (*pb.PendingTransactionResponse, error)

HandleLocalStateGetPendingTransaction handles the get pending tx request.

func (*Handlers) HandleLocalStateGetRoundStateForValidator

func (srpc *Handlers) HandleLocalStateGetRoundStateForValidator(ctx context.Context, req *pb.RoundStateForValidatorRequest) (*pb.RoundStateForValidatorResponse, error)

func (*Handlers) HandleLocalStateGetTransactionStatus

func (srpc *Handlers) HandleLocalStateGetTransactionStatus(ctx context.Context, req *pb.TransactionStatusRequest) (*pb.TransactionStatusResponse, error)

HandleLocalStateGetTransactionStatus ...

func (*Handlers) HandleLocalStateGetTxBlockNumber

func (srpc *Handlers) HandleLocalStateGetTxBlockNumber(ctx context.Context, req *pb.TxBlockNumberRequest) (*pb.TxBlockNumberResponse, error)

func (*Handlers) HandleLocalStateGetUTXO

func (srpc *Handlers) HandleLocalStateGetUTXO(ctx context.Context, req *pb.UTXORequest) (*pb.UTXOResponse, error)

HandleLocalStateGetUTXO ...

func (*Handlers) HandleLocalStateGetValidatorSet

func (srpc *Handlers) HandleLocalStateGetValidatorSet(ctx context.Context, req *pb.ValidatorSetRequest) (*pb.ValidatorSetResponse, error)

func (*Handlers) HandleLocalStateGetValueForOwner

func (srpc *Handlers) HandleLocalStateGetValueForOwner(ctx context.Context, req *pb.GetValueRequest) (*pb.GetValueResponse, error)

HandleLocalStateGetValueForOwner ...

func (*Handlers) HandleLocalStateIterateNameSpace

func (srpc *Handlers) HandleLocalStateIterateNameSpace(ctx context.Context, req *pb.IterateNameSpaceRequest) (*pb.IterateNameSpaceResponse, error)

HandleLocalStateIterateNameSpace ...

func (*Handlers) HandleLocalStateSendTransaction

func (srpc *Handlers) HandleLocalStateSendTransaction(ctx context.Context, req *pb.TransactionData) (*pb.TransactionDetails, error)

func (*Handlers) Init

func (srpc *Handlers) Init(database *db.Database, app *application.Application, gh *gossip.Handlers, pubk []byte, safe func() bool, storage dynamics.StorageGetter)

Init will initialize the Consensus Engine and all sub modules.

func (*Handlers) SafeMonitor

func (srpc *Handlers) SafeMonitor()

func (*Handlers) Start

func (srpc *Handlers) Start()

func (*Handlers) Stop

func (srpc *Handlers) Stop()

Jump to

Keyboard shortcuts

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