rpcs

package
v0.0.0-...-7d4e23b Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: AGPL-3.0 Imports: 34 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RoundKey           = "roundKey"        // Block round-number topic-key in the request
	RequestDataTypeKey = "requestDataType" // Data-type topic-key in the request (e.g. block, cert, block+cert)
	BlockDataKey       = "blockData"       // Block-data topic-key in the response
	CertDataKey        = "certData"        // Cert-data topic-key in the response
	BlockAndCertValue  = "blockAndCert"    // block+cert request data (as the value of requestDataTypeKey)
	LatestRoundKey     = "latest"
)

Constant strings used as keys for topics

View Source
const (
	// LedgerResponseContentType is the HTTP Content-Type header for a raw ledger block
	LedgerResponseContentType = "application/x-algorand-ledger-v2.1"

	// LedgerServiceLedgerPath is the path to register LedgerService as a handler for when using gorilla/mux
	// e.g. .Handle(LedgerServiceLedgerPath, &ls)
	LedgerServiceLedgerPath = "/v{version:[0-9.]+}/{genesisID}/ledger/{round:[0-9a-z]+}"
)
View Source
const BlockResponseContentType = "application/x-algorand-block-v1"

BlockResponseContentType is the HTTP Content-Type header for a raw binary block

View Source
const BlockResponseLatestRoundHeader = "X-Latest-Round"

BlockResponseLatestRoundHeader is returned in the response header when the requested block is not available

View Source
const BlockServiceBlockPath = "/v{version:[0-9.]+}/{genesisID}/block/{round:[0-9a-z]+}"

BlockServiceBlockPath is the path to register BlockService as a handler for when using gorilla/mux e.g. .HandleFunc(BlockServiceBlockPath, ls.ServeBlockPath)

View Source
const TxServiceHTTPPath = "/v1/{genesisID}/txsync"

TxServiceHTTPPath is the URL path to sync pending transactions from

Variables

This section is empty.

Functions

func EncodedBlockCertMaxSize

func EncodedBlockCertMaxSize() (s int)

MaxSize returns a maximum valid message size for this message type

func FormatBlockQuery

func FormatBlockQuery(round uint64, parsedURL string, net network.GossipNode) string

FormatBlockQuery formats a block request query for the given network and round number

func RawBlockBytes

func RawBlockBytes(l LedgerForBlockService, round basics.Round) ([]byte, error)

RawBlockBytes return the msgpack bytes for a block

func RegisterTxService

func RegisterTxService(pool PendingTxAggregate, registrar Registrar, genesisID string, txPoolSize int, responseSizeLimit int)

RegisterTxService creates a TxService around the provider transaction pool and registers it for RPC with the provided Registrar

func ResponseBytes

func ResponseBytes(response *http.Response, log logging.Logger, limit uint64) (data []byte, err error)

ResponseBytes reads the content of the response object and return the body content while obeying the read size limits

Types

type BlockService

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

BlockService represents the Block RPC API

func MakeBlockService

func MakeBlockService(log logging.Logger, config config.Local, ledger LedgerForBlockService, net network.GossipNode, genesisID string) *BlockService

MakeBlockService creates a BlockService around the provider Ledger and registers it for HTTP callback on the block serving path

func (*BlockService) RegisterHandlers

func (bs *BlockService) RegisterHandlers(registrar Registrar)

RegisterHandlers registers the request handlers for BlockService's paths with the registrar.

func (*BlockService) ServeBlockPath

func (bs *BlockService) ServeBlockPath(response http.ResponseWriter, request *http.Request)

ServeBlockPath returns blocks Either /v{version}/{genesisID}/block/{round} or ?b={round}&v={version} Uses gorilla/mux for path argument parsing.

func (*BlockService) Start

func (bs *BlockService) Start()

Start listening to catchup requests over ws

func (*BlockService) Stop

func (bs *BlockService) Stop()

Stop servicing catchup requests over ws

type EncodedBlockCert

type EncodedBlockCert struct {
	Block       bookkeeping.Block     `codec:"block"`
	Certificate agreement.Certificate `codec:"cert"`
	// contains filtered or unexported fields
}

EncodedBlockCert defines how GetBlockBytes encodes a block and its certificate

func (*EncodedBlockCert) CanMarshalMsg

func (_ *EncodedBlockCert) CanMarshalMsg(z interface{}) bool

func (*EncodedBlockCert) CanUnmarshalMsg

func (_ *EncodedBlockCert) CanUnmarshalMsg(z interface{}) bool

func (*EncodedBlockCert) MarshalMsg

func (z *EncodedBlockCert) MarshalMsg(b []byte) (o []byte)

MarshalMsg implements msgp.Marshaler

func (*EncodedBlockCert) MsgIsZero

func (z *EncodedBlockCert) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*EncodedBlockCert) Msgsize

func (z *EncodedBlockCert) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*EncodedBlockCert) UnmarshalMsg

func (z *EncodedBlockCert) UnmarshalMsg(bts []byte) (o []byte, err error)

func (*EncodedBlockCert) UnmarshalMsgWithState

func (z *EncodedBlockCert) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type HTTPTxSync

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

HTTPTxSync implements the TxSyncClient interface over HTTP

func (*HTTPTxSync) Address

func (hts *HTTPTxSync) Address() string

Address is part of TxSyncClient interface. Returns the root URL of the connected peer.

func (*HTTPTxSync) Close

func (hts *HTTPTxSync) Close() error

Close is part of TxSyncClient interface

Does nothing, leaves underlying client open because other HTTP requests from other interfaces could be open on it. Somewhere a Peer owns that connection and will close as needed.

func (*HTTPTxSync) Sync

func (hts *HTTPTxSync) Sync(ctx context.Context, bloom *bloom.Filter) (txgroups [][]transactions.SignedTxn, err error)

Sync gets pending transactions from a random peer. Part of TxSyncClient interface.

type HealthService

type HealthService struct{}

HealthService is a service that provides health information endpoints for the node

func MakeHealthService

func MakeHealthService(net network.GossipNode) HealthService

MakeHealthService creates a new HealthService and registers it with the provided network if enabled

func (HealthService) ServeHTTP

func (h HealthService) ServeHTTP(writer http.ResponseWriter, _ *http.Request)

type LedgerForBlockService

type LedgerForBlockService interface {
	EncodedBlockCert(rnd basics.Round) (blk []byte, cert []byte, err error)
}

LedgerForBlockService describes the Ledger methods used by BlockService.

type LedgerForService

type LedgerForService interface {
	// GetCatchpointStream returns the ReadCloseSize for a request catchpoint round
	GetCatchpointStream(round basics.Round) (ledger.ReadCloseSizer, error)
}

LedgerForService defines the ledger interface required for the LedgerService

type LedgerService

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

LedgerService represents the Ledger RPC API

func MakeLedgerService

func MakeLedgerService(config config.Local, ledger LedgerForService, net httpGossipNode, genesisID string) *LedgerService

MakeLedgerService creates a LedgerService around the provider Ledger and registers it with the HTTP router

func (*LedgerService) ServeHTTP

func (ls *LedgerService) ServeHTTP(response http.ResponseWriter, request *http.Request)

ServerHTTP returns ledgers for a particular round Either /v{version}/{genesisID}/ledger/{round} or ?r={round}&v={version} Uses gorilla/mux for path argument parsing.

func (*LedgerService) Start

func (ls *LedgerService) Start()

Start listening to catchup requests

func (*LedgerService) Stop

func (ls *LedgerService) Stop()

Stop servicing catchup requests

type PendingTxAggregate

type PendingTxAggregate interface {
	PendingTxIDs() []transactions.Txid
	PendingTxGroups() [][]transactions.SignedTxn
}

PendingTxAggregate is a container of pending transactions

type PreEncodedBlockCert

type PreEncodedBlockCert struct {
	Block       codec.Raw `codec:"block"`
	Certificate codec.Raw `codec:"cert"`
}

PreEncodedBlockCert defines how GetBlockBytes encodes a block and its certificate, using a pre-encoded Block and Certificate in msgpack format.

type Registrar

type Registrar interface {
	// RegisterHTTPHandler path accepts gorilla/mux path annotations
	RegisterHTTPHandler(path string, handler http.Handler)
	// RegisterHTTPHandlerFunc path accepts gorilla/mux path annotations and a HandlerFunc
	RegisterHTTPHandlerFunc(path string, handler func(response http.ResponseWriter, request *http.Request))
	// RegisterHandlers exposes global websocket handler registration
	RegisterHandlers(dispatch []network.TaggedMessageHandler)
}

Registrar is subset of network.GossipNode

type TxService

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

TxService provides a service that allows a remote caller to retrieve missing pending transactions

func (*TxService) ServeHTTP

func (txs *TxService) ServeHTTP(response http.ResponseWriter, request *http.Request)

ServeHTTP returns pending transactions that match a bloom filter

type TxSyncClient

type TxSyncClient interface {
	Sync(ctx context.Context, bloom *bloom.Filter) (txns [][]transactions.SignedTxn, err error)
	Address() string
	Close() error
}

TxSyncClient abstracts sync-ing pending transactions from a peer.

type TxSyncer

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

TxSyncer fetches pending transactions that are missing from its pool, and feeds them to the handler

func MakeTxSyncer

func MakeTxSyncer(pool PendingTxAggregate, clientSource network.GossipNode, txHandler data.SolicitedTxHandler, syncInterval time.Duration, syncTimeout time.Duration, serverResponseSize int) *TxSyncer

MakeTxSyncer returns a TxSyncer

func (*TxSyncer) Start

func (syncer *TxSyncer) Start(canStart chan struct{})

Start begins periodically syncing after the canStart chanel indicates it can begin

func (*TxSyncer) Stop

func (syncer *TxSyncer) Stop()

Stop stops periodic syncing

Jump to

Keyboard shortcuts

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