indexer

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderChain = "x-bpi-chain"

Variables

View Source
var (
	DefaultEntryPoints = []string{"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", "0xdc5319815cdaac2d113f7f275bc893ed7d9ca469"}

	DefaultChainId = map[string]string{
		"ethereum": "1",
		"goerli":   "5",
		"sepolia":  "11155111",

		"polygon":        "137",
		"polygon-mumbai": "80001",

		"optimism":        "10",
		"optimism-goerli": "420",

		"arbitrum":        "421613",
		"arbitrum-one":    "42161",
		"arbitrum-nova":   "42170",
		"arbitrum-goerli": "421613",
		"bsc":             "56",
	}

	DefaultStartBlocks = map[string]int64{
		"ethereum": 17066994,
		"goerli":   8812127,
		"sepolia":  3296058,

		"polygon":        41402415,
		"polygon-mumbai": 34239265,

		"optimism":        93335977,
		"optimism-goerli": 10442160,

		"arbitrum":        79305493,
		"arbitrum-nova":   8945015,
		"arbitrum-goerli": 17068300,
		"bsc":             27251985,
	}
)
View Source
var (
	FlagVersion = &cli.BoolFlag{
		Name:  "version",
		Usage: "Version",
	}

	FlagConfig = &cli.StringFlag{
		Name:  "config",
		Usage: "config file",
		Value: "",
	}

	FlagListen = &cli.StringFlag{
		Name:  "listen",
		Usage: "listen",
		Value: "127.0.0.1:2052",
	}

	FlagGrpcListen = &cli.StringFlag{
		Name:  "grpc.listen",
		Usage: "grpc.listen",
		Value: "127.0.0.1:2053",
	}

	FlagReadonly = &cli.BoolFlag{
		Name:  "readonly",
		Usage: "readonly",
		Value: false,
	}

	FlagChain = &cli.StringFlag{
		Name:  "chain",
		Usage: "ChainCfg",
		Value: "",
	}

	FlagChainId = &cli.StringFlag{
		Name:  "chain.id",
		Usage: string(_mustMarshal(DefaultChainId)),
		Value: "",
	}

	FlagEntryPoint = &cli.StringFlag{
		Name:  "entrypoint",
		Usage: "Entrypoint contract",
		Value: "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789",
	}

	FlagBackendUrl = &cli.StringFlag{
		Name:  "backend",
		Usage: "Backends chain rpc provider url",
		Value: "",
	}

	FlagCompress = &cli.BoolFlag{
		Name:  "compress",
		Usage: "compress",
		Value: false,
	}

	FlagDbEngin = &cli.StringFlag{
		Name:  "db.engin",
		Usage: "Backing database implementation to use ('memory' or 'redis' or 'pebble')",
		Value: "memory",
	}

	FlagDbDataSource = &cli.StringFlag{
		Name:  "db.ds",
		Usage: "mysql://user:passwd@hostname:port/databasename, redis://passwd@host:port",
		Value: "",
	}

	FlagEthLogsStartBlock = &cli.Int64Flag{
		Name:  "block.start",
		Usage: string(_mustMarshal(DefaultStartBlocks)),
		Value: 0,
	}

	FlagEthLogsBlockRange = &cli.Int64Flag{
		Name:  "block.range",
		Usage: "eth_getLogs block range",
		Value: 1000,
	}
)
View Source
var (
	LogDescriptor = "0x49628fd1471006c1482da88028e9ce4dbb080b815c9b0344d39e5a8e6ec1419f"
)

Functions

func DbKeyStartBlock

func DbKeyStartBlock(chain string) string

func DbKeyUserOp

func DbKeyUserOp(chain, op string) string

func NewDb

func NewDb(engin, dataSource string) database.KVStore

func Run

func Run(cfg *Config) error

Types

type Backend

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

func NewBackend

func NewBackend(headers []HeadersCfg, eps []string, chain ChainCfg, db database.KVStore) *Backend

func (*Backend) CallAndSave

func (b *Backend) CallAndSave(fromBlock, toBlock int64, cli *web3.Web3) error

func (*Backend) LatestBlockNumber

func (b *Backend) LatestBlockNumber() (uint64, *web3.Web3, error)

func (*Backend) Run

func (b *Backend) Run() error

func (*Backend) SetNextStartBlock

func (b *Backend) SetNextStartBlock(block int64)

func (*Backend) StartBlock

func (b *Backend) StartBlock() int64

type ChainCfg added in v1.0.4

type ChainCfg struct {
	Chain           string
	ChainId         string `yaml:"chainId"`
	Backends        []string
	StartBlock      int64 `yaml:"startBlock"`
	BlockRangeSize  int64 `yaml:"blockRangeSize"`
	PullingInterval int64 `yaml:"pullingInterval"`
}

type Config

type Config struct {
	EntryPoints []string `yaml:"entryPoints"`
	Listen      string
	GrpcListen  string `yaml:"grpcListen"`
	Readonly    bool
	Compress    bool
	Db          DBCfg
	Chains      []ChainCfg
	Headers     []HeadersCfg
}

func ParseConfig

func ParseConfig(ctx *cli.Context) *Config

func ParseConfigFromCmd added in v1.0.4

func ParseConfigFromCmd(ctx *cli.Context) (*Config, error)

func ParseConfigFromFile added in v1.0.4

func ParseConfigFromFile(ctx *cli.Context) (*Config, error)

type DBCfg added in v1.0.4

type DBCfg struct {
	Engin string
	Ds    string
}

type GrpcServer

type GrpcServer struct {
	proto.UnimplementedRelayServer
	// contains filtered or unexported fields
}

func NewGrpcServer

func NewGrpcServer(cfg *Config, db database.KVStore) *GrpcServer

func (*GrpcServer) Chain added in v1.0.4

func (s *GrpcServer) Chain() string

func (*GrpcServer) Compressed added in v1.0.3

func (s *GrpcServer) Compressed() bool

func (*GrpcServer) Db

func (s *GrpcServer) Db() database.KVStore

func (*GrpcServer) EntryPoints added in v1.0.4

func (s *GrpcServer) EntryPoints() []string

func (*GrpcServer) Relay

func (s *GrpcServer) Relay(ctx context.Context, request *proto.Request) (*proto.Response, error)

func (*GrpcServer) Run

func (s *GrpcServer) Run() error

type HeadersCfg added in v1.0.4

type HeadersCfg struct {
	Host    string
	Headers []string
}

type Rpc

type Rpc interface {
	Db() database.KVStore
	EntryPoints() []string
	Compressed() bool
}

type Server

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

func NewServer

func NewServer(cfg *Config, db database.KVStore) *Server

func (*Server) Compressed added in v1.0.3

func (s *Server) Compressed() bool

func (*Server) Db

func (s *Server) Db() database.KVStore

func (*Server) EntryPoints added in v1.0.4

func (s *Server) EntryPoints() []string

func (*Server) Run

func (s *Server) Run() error

type Status added in v1.0.2

type Status struct {
	Chain       string `json:"chain"`
	BlockNumber int64  `json:"block_number"`
	LatestBlock int64  `json:"latest_block"`
	CatchingUp  bool   `json:"catching_up"`
}

Jump to

Keyboard shortcuts

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