feeder

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultTimeouts = "5s"
)
View Source
const (
	PreConfirmedBlankIdentifier = "0x0"
)

Variables

View Source
var ErrDeprecatedCompiledClass = errors.New("deprecated compiled class")
View Source
var ErrInvalidFeederResponse = errors.New("invalid feeder response")
View Source
var ErrPreConfirmedBlockNotFound = errors.New("pre-confirmed block not found")

ErrPreConfirmedBlockNotFound is returned by the pre-confirmed queries when the gateway answers 400, meaning the requested block is not (or no longer) in the pre-confirmed window.

Functions

func ExponentialBackoff

func ExponentialBackoff(wait time.Duration) time.Duration

func HTTPTimeoutsSettings added in v0.14.4

func HTTPTimeoutsSettings(w http.ResponseWriter, r *http.Request, client *Client)

func NopBackoff

func NopBackoff(d time.Duration) time.Duration

func ParseTimeouts added in v0.14.3

func ParseTimeouts(value string) ([]time.Duration, bool, error)

ParseTimeouts parses a comma-separated string of duration values into a slice of time.Duration. Returns: - the parsed timeout values - if a fixed or dynamic timeouts should be used - an error in case the string cannot be parsed

Types

type Backoff

type Backoff func(wait time.Duration) time.Duration

type Client

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

func NewClient

func NewClient(clientURL *url.URL, opts ...Option) *Client

func NewTestClient

func NewTestClient(t testing.TB, network *networks.Network, opts ...Option) *Client

NewTestClient returns a client and a function to close a test server.

func (*Client) Block

func (c *Client) Block(ctx context.Context, blockID string) (starknet.Block, error)

func (*Client) BlockHeader added in v0.15.22

func (c *Client) BlockHeader(
	ctx context.Context, blockID string,
) (starknet.BlockHeader, error)

func (*Client) BlockTrace added in v0.7.2

func (c *Client) BlockTrace(ctx context.Context, blockHash string) (starknet.BlockTrace, error)

func (*Client) CasmClassDefinition added in v0.15.9

func (c *Client) CasmClassDefinition(
	ctx context.Context,
	classHash *felt.Felt,
) (starknet.CasmClass, error)

func (*Client) ClassDefinition

func (c *Client) ClassDefinition(
	ctx context.Context, classHash *felt.Felt,
) (starknet.ClassDefinition, error)

func (*Client) FeeTokenAddresses added in v0.15.7

func (c *Client) FeeTokenAddresses(ctx context.Context) (starknet.FeeTokenAddresses, error)

func (*Client) PreConfirmedBlockLatest added in v0.16.5

func (c *Client) PreConfirmedBlockLatest(
	ctx context.Context,
	blockIdentifier string,
	knownTransactionCount uint64,
) (starknet.PreConfirmedUpdate, uint64, error)

PreConfirmedBlockLatest fetches the highest pre_confirmed block the server currently exposes. The response carries its block_number so the caller can discover the pre_confirmed tip without tracking the height itself. Pass an empty identifier and zero txCount for a full reply.

func (*Client) PreConfirmedBlockWithIdentifier added in v0.16.1

func (c *Client) PreConfirmedBlockWithIdentifier(
	ctx context.Context,
	blockNumber string,
	blockIdentifier string,
	knownTransactionCount uint64,
) (starknet.PreConfirmedUpdate, error)

PreConfirmedBlockWithIdentifier fetches the pre_confirmed block at the given height, using the given block identifier and known transaction count to tell the server what the caller already has.

blockIdentifier and knownTransactionCount enable delta sync: the server uses them to decide whether to return a no-change marker, only the transactions appended since knownTransactionCount, or the full block when the round identifier no longer matches. Set both to zero values to get a full block.

func (*Client) PublicKey added in v0.8.0

func (c *Client) PublicKey(ctx context.Context) (felt.Felt, error)

func (*Client) SetTimeouts added in v0.16.6

func (c *Client) SetTimeouts(timeouts []time.Duration, fixed bool)

SetTimeouts atomically replaces the timeouts of a live client. It is used by the PUT /feeder/timeouts endpoint.

func (*Client) Signature added in v0.6.0

func (c *Client) Signature(ctx context.Context, blockID string) (starknet.Signature, error)

func (*Client) StateUpdate

func (c *Client) StateUpdate(ctx context.Context, blockID string) (starknet.StateUpdate, error)

func (*Client) StateUpdateWithBlockAndSignature added in v0.16.1

func (c *Client) StateUpdateWithBlockAndSignature(
	ctx context.Context,
	blockID string,
) (starknet.StateUpdateWithBlockAndSignature, error)

func (*Client) Transaction deprecated

func (c *Client) Transaction(
	ctx context.Context, transactionHash *felt.Felt,
) (starknet.DeprecatedTransactionStatus, error)

Deprecated: Transaction calls the get_transaction endpoint which returns the full transaction body. Use TransactionStatus() instead.

func (*Client) TransactionStatus added in v0.15.20

func (c *Client) TransactionStatus(
	ctx context.Context,
	transactionHash *felt.Felt,
) (starknet.TransactionStatus, error)

TransactionStatus calls the get_transaction_status endpoint which returns only status fields (finality, execution status, block hash) without the full transaction body.

type EventListener added in v0.8.2

type EventListener interface {
	OnResponse(urlPath string, status int, took time.Duration)
}

type Option added in v0.16.6

type Option func(*options)

Option is a functional option for configuring the feeder client.

func WithAPIKey added in v0.16.6

func WithAPIKey(key string) Option

func WithBackoff added in v0.16.6

func WithBackoff(b Backoff) Option

func WithHTTPClient added in v0.16.6

func WithHTTPClient(client *http.Client) Option

func WithListener added in v0.16.6

func WithListener(l EventListener) Option

func WithLogger added in v0.16.6

func WithLogger(logger log.StructuredLogger) Option

func WithMaxRetries added in v0.16.6

func WithMaxRetries(num int) Option

func WithMaxWait added in v0.16.6

func WithMaxWait(d time.Duration) Option

func WithMinWait added in v0.16.6

func WithMinWait(d time.Duration) Option

func WithTimeouts added in v0.16.6

func WithTimeouts(timeouts []time.Duration, fixed bool) Option

func WithUserAgent added in v0.16.6

func WithUserAgent(ua string) Option

type Reader added in v0.16.1

type Reader interface {
	Block(ctx context.Context, blockID string) (starknet.Block, error)
	BlockHeader(ctx context.Context, blockID string) (starknet.BlockHeader, error)
	BlockTrace(ctx context.Context, blockHash string) (starknet.BlockTrace, error)
	CasmClassDefinition(ctx context.Context, classHash *felt.Felt) (starknet.CasmClass, error)
	ClassDefinition(ctx context.Context, classHash *felt.Felt) (starknet.ClassDefinition, error)
	FeeTokenAddresses(ctx context.Context) (starknet.FeeTokenAddresses, error)
	PreConfirmedBlockWithIdentifier(
		ctx context.Context,
		blockNumber string,
		blockIdentifier string,
		knownTransactionCount uint64,
	) (starknet.PreConfirmedUpdate, error)
	PreConfirmedBlockLatest(
		ctx context.Context,
		blockIdentifier string,
		knownTransactionCount uint64,
	) (starknet.PreConfirmedUpdate, uint64, error)
	PublicKey(ctx context.Context) (felt.Felt, error)
	Signature(ctx context.Context, blockID string) (starknet.Signature, error)
	StateUpdate(ctx context.Context, blockID string) (starknet.StateUpdate, error)
	StateUpdateWithBlockAndSignature(
		ctx context.Context,
		blockID string,
	) (starknet.StateUpdateWithBlockAndSignature, error)
	// Deprecated: Use TransactionStatus() instead.
	Transaction(
		ctx context.Context,
		transactionHash *felt.Felt,
	) (starknet.DeprecatedTransactionStatus, error)
	TransactionStatus(
		ctx context.Context,
		transactionHash *felt.Felt,
	) (starknet.TransactionStatus, error)
}

type SelectiveListener added in v0.8.2

type SelectiveListener struct {
	OnResponseCb func(urlPath string, status int, took time.Duration)
}

func (*SelectiveListener) OnResponse added in v0.8.2

func (l *SelectiveListener) OnResponse(urlPath string, status int, took time.Duration)

type StatusError added in v0.16.6

type StatusError struct {
	Code int
}

StatusError reports a non-OK HTTP status from the feeder gateway.

func (*StatusError) Error added in v0.16.6

func (e *StatusError) Error() string

type Timeouts added in v0.14.3

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

func (*Timeouts) DecreaseTimeout added in v0.14.3

func (t *Timeouts) DecreaseTimeout()

func (*Timeouts) GetCurrentTimeout added in v0.14.3

func (t *Timeouts) GetCurrentTimeout() time.Duration

func (*Timeouts) IncreaseTimeout added in v0.14.3

func (t *Timeouts) IncreaseTimeout()

func (*Timeouts) String added in v0.14.3

func (t *Timeouts) String() string

type Validatable added in v0.16.5

type Validatable[T any] interface {
	*T
	Validate() error
}

Validatable is a generic constraint satisfied by a pointer type *T whose underlying value type T can validate itself. Implementers provide a Validate method with a pointer receiver that checks the receiver's fields and returns an error if validation fails.

Jump to

Keyboard shortcuts

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