subgraph

package
v0.0.0-...-efbdb50 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	Intrinsics
	*Definition

	ID  string // QmHELLOWORLD as fetched when necessary
	Log *zap.Logger
}

Base contains initialized values for a Subgraph instance, wrapped in a struct for future-proofness.

type BlockRef

type BlockRef interface {
	ID() string
	Number() uint64
	Timestamp() time.Time
}

type DDL

type DDL interface {
	InitiateSchema(handleStatement func(statement string) error) error
	CreateTables(handleStatement func(table string, statement string) error) error
	CreateIndexes(handleStatement func(table string, statement string) error) error
	DropIndexes(handleStatement func(table string, statement string) error) error
}

type Definition

type Definition struct {
	PackageName string

	HighestParallelStep int

	StartBlock    uint64
	IncludeFilter string
	Entities      *entity.Registry
	DDL           DDL
	Manifest      string
	GraphQLSchema string
	Abis          map[string]string

	New       func(Base) Subgraph
	MergeFunc func(step int, current, next entity.Interface) entity.Interface
}
var MainSubgraphDef *Definition

type Intrinsics

type Intrinsics interface {
	Save(entity entity.Interface) error
	Load(entity entity.Interface) error
	LoadAllDistinct(model entity.Interface, blockNum uint64) ([]entity.Interface, error)
	Remove(entity entity.Interface) error

	// Block returns the current block being processed by your subgraph handler.
	Block() BlockRef

	/// Reproc
	Step() int
	StepBelow(step int) bool
	StepAbove(step int) bool

	/// JSON-RPC
	RPC(calls []*RPCCall) ([]*RPCResponse, error)
}

Intrinsics is per subgraph and should be unique for each subgraph. The underlying implementation should know about its surrounding context to know when to close when at which block it's currently at.

It's expected that the implementation will be called by one go routine at a time.

type RPCCall

type RPCCall struct {
	ToAddr          string
	MethodSignature string // ex: "name() (string)"
}

func (*RPCCall) ToString

func (c *RPCCall) ToString() string

type RPCResponse

type RPCResponse struct {
	Decoded       []interface{}
	Raw           string
	DecodingError error
	CallError     error // always deterministic
}

type Subgraph

type Subgraph interface {
	Init() error

	LoadDynamicDataSources(blockNum uint64) error
	// FIXME: this should be a `bstream.Block`, and generated `HandleBlock`
	// casts it to an ETH-specific block, or a `ToNative()` first thing.
	HandleBlock(block *pbcodec.Block) error

	LogStatus()
}

Jump to

Keyboard shortcuts

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