indexer

package
v1.36.178 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: BSD-3-Clause Imports: 26 Imported by: 2

Documentation

Index

Constants

View Source
const MaxFetchedByRange = 1024

Maximum number of containers IDs that can be fetched at a time in a call to GetContainerRange

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Requester rpc.EndpointRequester
}

func NewClient

func NewClient(uri string) *Client

NewClient creates a client that can interact with an index via HTTP API calls. [uri] is the path to make API calls to. For example:

func (*Client) GetContainerByID

func (c *Client) GetContainerByID(ctx context.Context, id ids.ID, options ...rpc.Option) (Container, uint64, error)

Get a container and its index by its ID

func (*Client) GetContainerByIndex

func (c *Client) GetContainerByIndex(ctx context.Context, index uint64, options ...rpc.Option) (Container, error)

Get a container by its index

func (*Client) GetContainerRange

func (c *Client) GetContainerRange(ctx context.Context, startIndex uint64, numToFetch int, options ...rpc.Option) ([]Container, error)

GetContainerRange returns the transactions at index [startIndex], [startIndex+1], ... , [startIndex+n-1] If [n] == 0, returns an empty response (i.e. null). If [startIndex] > the last accepted index, returns an error (unless the above apply.) If we run out of transactions, returns the ones fetched before running out.

func (*Client) GetIndex

func (c *Client) GetIndex(ctx context.Context, id ids.ID, options ...rpc.Option) (uint64, error)

Returns 1 less than the number of containers accepted on this chain

func (*Client) GetLastAccepted

func (c *Client) GetLastAccepted(ctx context.Context, options ...rpc.Option) (Container, uint64, error)

Get the most recently accepted container and its index

func (*Client) IsAccepted

func (c *Client) IsAccepted(ctx context.Context, id ids.ID, options ...rpc.Option) (bool, error)

Returns true if the given container is accepted

type Config

type Config struct {
	DB                   database.Database
	Log                  log.Logger
	IndexingEnabled      bool
	AllowIncompleteIndex bool
	BlockAcceptorGroup   nodeconsensus.AcceptorGroup
	TxAcceptorGroup      nodeconsensus.AcceptorGroup
	VertexAcceptorGroup  nodeconsensus.AcceptorGroup
	APIServer            server.PathAdder
	ShutdownF            func()
}

Config for an indexer

type Container

type Container struct {
	// ID of this container
	ID ids.ID `serialize:"true"`
	// Byte representation of this container
	Bytes []byte `serialize:"true"`
	// Unix time, in nanoseconds, at which this container was accepted by this node
	Timestamp int64 `serialize:"true"`
}

Container is something that gets accepted (a block, transaction or vertex)

type FormattedContainer

type FormattedContainer struct {
	ID        ids.ID              `json:"id"`
	Bytes     string              `json:"bytes"`
	Timestamp json.Time           `json:"timestamp"`
	Encoding  formatting.Encoding `json:"encoding"`
	Index     json.Uint64         `json:"index"`
}

func (*FormattedContainer) MarshalZAP added in v1.36.178

func (x *FormattedContainer) MarshalZAP() ([]byte, error)

MarshalZAP writes FormattedContainer from constant offsets.

func (*FormattedContainer) UnmarshalZAP added in v1.36.178

func (x *FormattedContainer) UnmarshalZAP(data []byte) error

UnmarshalZAP reads FormattedContainer out of the buffer that arrived.

type GetContainerByIDArgs

type GetContainerByIDArgs struct {
	ID       ids.ID              `json:"id"`
	Encoding formatting.Encoding `json:"encoding"`
}

func (*GetContainerByIDArgs) MarshalZAP added in v1.36.178

func (x *GetContainerByIDArgs) MarshalZAP() ([]byte, error)

MarshalZAP writes GetContainerByIDArgs from constant offsets.

func (*GetContainerByIDArgs) UnmarshalZAP added in v1.36.178

func (x *GetContainerByIDArgs) UnmarshalZAP(data []byte) error

UnmarshalZAP reads GetContainerByIDArgs out of the buffer that arrived.

type GetContainerByIndexArgs

type GetContainerByIndexArgs struct {
	Index    json.Uint64         `json:"index"`
	Encoding formatting.Encoding `json:"encoding"`
}

func (*GetContainerByIndexArgs) MarshalZAP added in v1.36.178

func (x *GetContainerByIndexArgs) MarshalZAP() ([]byte, error)

MarshalZAP writes GetContainerByIndexArgs from constant offsets.

func (*GetContainerByIndexArgs) UnmarshalZAP added in v1.36.178

func (x *GetContainerByIndexArgs) UnmarshalZAP(data []byte) error

UnmarshalZAP reads GetContainerByIndexArgs out of the buffer that arrived.

type GetContainerRangeArgs

type GetContainerRangeArgs struct {
	StartIndex json.Uint64         `json:"startIndex"`
	NumToFetch json.Uint64         `json:"numToFetch"`
	Encoding   formatting.Encoding `json:"encoding"`
}

func (*GetContainerRangeArgs) MarshalZAP added in v1.36.178

func (x *GetContainerRangeArgs) MarshalZAP() ([]byte, error)

MarshalZAP writes GetContainerRangeArgs from constant offsets.

func (*GetContainerRangeArgs) UnmarshalZAP added in v1.36.178

func (x *GetContainerRangeArgs) UnmarshalZAP(data []byte) error

UnmarshalZAP reads GetContainerRangeArgs out of the buffer that arrived.

type GetContainerRangeResponse

type GetContainerRangeResponse struct {
	Containers []FormattedContainer `json:"containers"`
}

func (*GetContainerRangeResponse) MarshalZAP added in v1.36.178

func (x *GetContainerRangeResponse) MarshalZAP() ([]byte, error)

MarshalZAP writes GetContainerRangeResponse from constant offsets.

func (*GetContainerRangeResponse) UnmarshalZAP added in v1.36.178

func (x *GetContainerRangeResponse) UnmarshalZAP(data []byte) error

UnmarshalZAP reads GetContainerRangeResponse out of the buffer that arrived.

type GetIndexArgs

type GetIndexArgs struct {
	ID ids.ID `json:"id"`
}

func (*GetIndexArgs) MarshalZAP added in v1.36.178

func (x *GetIndexArgs) MarshalZAP() ([]byte, error)

MarshalZAP writes GetIndexArgs from constant offsets.

func (*GetIndexArgs) UnmarshalZAP added in v1.36.178

func (x *GetIndexArgs) UnmarshalZAP(data []byte) error

UnmarshalZAP reads GetIndexArgs out of the buffer that arrived.

type GetIndexResponse

type GetIndexResponse struct {
	Index json.Uint64 `json:"index"`
}

func (*GetIndexResponse) MarshalZAP added in v1.36.178

func (x *GetIndexResponse) MarshalZAP() ([]byte, error)

MarshalZAP writes GetIndexResponse from constant offsets.

func (*GetIndexResponse) UnmarshalZAP added in v1.36.178

func (x *GetIndexResponse) UnmarshalZAP(data []byte) error

UnmarshalZAP reads GetIndexResponse out of the buffer that arrived.

type GetLastAcceptedArgs

type GetLastAcceptedArgs struct {
	Encoding formatting.Encoding `json:"encoding"`
}

func (*GetLastAcceptedArgs) MarshalZAP added in v1.36.178

func (x *GetLastAcceptedArgs) MarshalZAP() ([]byte, error)

MarshalZAP writes GetLastAcceptedArgs from constant offsets.

func (*GetLastAcceptedArgs) UnmarshalZAP added in v1.36.178

func (x *GetLastAcceptedArgs) UnmarshalZAP(data []byte) error

UnmarshalZAP reads GetLastAcceptedArgs out of the buffer that arrived.

type Indexer

type Indexer interface {
	chains.Registrant
	// Close will do nothing and return nil after the first call
	io.Closer
}

Indexer causes accepted containers for a given chain to be indexed by their ID and by the order in which they were accepted by this node. Indexer is threadsafe.

func NewIndexer

func NewIndexer(config Config) (Indexer, error)

NewIndexer returns a new Indexer and registers a new endpoint on the given API server.

type IsAcceptedArgs

type IsAcceptedArgs struct {
	ID ids.ID `json:"id"`
}

func (*IsAcceptedArgs) MarshalZAP added in v1.36.178

func (x *IsAcceptedArgs) MarshalZAP() ([]byte, error)

MarshalZAP writes IsAcceptedArgs from constant offsets.

func (*IsAcceptedArgs) UnmarshalZAP added in v1.36.178

func (x *IsAcceptedArgs) UnmarshalZAP(data []byte) error

UnmarshalZAP reads IsAcceptedArgs out of the buffer that arrived.

type IsAcceptedResponse

type IsAcceptedResponse struct {
	IsAccepted bool `json:"isAccepted"`
}

func (*IsAcceptedResponse) MarshalZAP added in v1.36.178

func (x *IsAcceptedResponse) MarshalZAP() ([]byte, error)

MarshalZAP writes IsAcceptedResponse from constant offsets.

func (*IsAcceptedResponse) UnmarshalZAP added in v1.36.178

func (x *IsAcceptedResponse) UnmarshalZAP(data []byte) error

UnmarshalZAP reads IsAcceptedResponse out of the buffer that arrived.

Directories

Path Synopsis
examples
p-chain command
x-chain-blocks command

Jump to

Keyboard shortcuts

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