Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) GetContainerByIndex(args *GetContainer) (FormattedContainer, error)
- func (c *Client) GetContainerRange(args *GetContainerRangeArgs) ([]FormattedContainer, error)
- func (c *Client) GetIndex(args *GetIndexArgs) (GetIndexResponse, error)
- func (c *Client) GetLastAccepted(args *GetLastAcceptedArgs) (FormattedContainer, error)
- func (c *Client) IsAccepted(args *GetIndexArgs) (bool, error)
- type Config
- type Container
- type FormattedContainer
- type GetContainer
- type GetContainerRangeArgs
- type GetContainerRangeResponse
- type GetIndexArgs
- type GetIndexResponse
- type GetLastAcceptedArgs
- type Index
- type Indexer
- type IsAcceptedResponse
Constants ¶
const ( // Maximum number of containers IDs that can be fetched at a time // in a call to GetContainerRange MaxFetchedByRange = 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
rpc.EndpointRequester
}
func NewClient ¶
NewClient creates a client that can interact with an index via HTTP API calls. [host] is the host to make API calls to (e.g. http://1.2.3.4:9650). [endpoint] is the path to the index endpoint (e.g. /ext/index/C/block or /ext/index/X/tx).
func (*Client) GetContainerByIndex ¶
func (c *Client) GetContainerByIndex(args *GetContainer) (FormattedContainer, error)
func (*Client) GetContainerRange ¶
func (c *Client) GetContainerRange(args *GetContainerRangeArgs) ([]FormattedContainer, error)
func (*Client) GetIndex ¶
func (c *Client) GetIndex(args *GetIndexArgs) (GetIndexResponse, error)
func (*Client) GetLastAccepted ¶
func (c *Client) GetLastAccepted(args *GetLastAcceptedArgs) (FormattedContainer, error)
func (*Client) IsAccepted ¶
func (c *Client) IsAccepted(args *GetIndexArgs) (bool, error)
type Config ¶
type Config struct { DB database.Database Log logging.Logger IndexingEnabled bool AllowIncompleteIndex bool DecisionDispatcher, ConsensusDispatcher *triggers.EventDispatcher APIServer server.RouteAdder 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 GetContainer ¶
type GetContainer struct { Index json.Uint64 `json:"index"` Encoding formatting.Encoding `json:"encoding"` }
type GetContainerRangeArgs ¶
type GetContainerRangeResponse ¶
type GetContainerRangeResponse struct {
Containers []FormattedContainer `json:"containers"`
}
type GetIndexArgs ¶
type GetIndexArgs struct { ContainerID ids.ID `json:"containerID"` Encoding formatting.Encoding `json:"encoding"` }
type GetIndexResponse ¶
type GetLastAcceptedArgs ¶
type GetLastAcceptedArgs struct {
Encoding formatting.Encoding `json:"encoding"`
}
type Index ¶
type Index interface { Accept(ctx *snow.Context, containerID ids.ID, container []byte) error GetContainerByIndex(index uint64) (Container, error) GetContainerRange(startIndex uint64, numToFetch uint64) ([]Container, error) GetLastAccepted() (Container, error) GetIndex(containerID ids.ID) (uint64, error) GetContainerByID(containerID ids.ID) (Container, error) io.Closer }
Index indexes containers in their order of acceptance Index implements triggers.Acceptor Index is thread-safe. Index assumes that Accept is called before the container is committed to the database of the VM that the container exists in.
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 ¶
NewIndexer returns a new Indexer and registers a new endpoint on the given API server.
type IsAcceptedResponse ¶
type IsAcceptedResponse struct {
IsAccepted bool `json:"isAccepted"`
}