rpcs

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 31 Imported by: 0

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)
)

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 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. .Handle(BlockServiceBlockPath, &ls)

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

TxServiceHTTPPath is the URL path to sync pending transactions from

Variables

This section is empty.

Functions

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 *data.Ledger, 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 *data.Ledger, 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) ServeHTTP

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

ServerHTTP returns blocks Either /v{version}/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)

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 LedgerService

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

LedgerService represents the Ledger RPC API

func MakeLedgerService

func MakeLedgerService(config config.Local, ledger *data.Ledger, net network.GossipNode, 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)
	// 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