subscan_plugin

package module
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: GPL-3.0 Imports: 5 Imported by: 3

README

Subscan Plugin

The subscan plugin is an interface lib to subscan-essentials plugin, and Gen tool can automatically generate plugin templates

Install

go get github.com/itering/subscan-plugin

Usage

tutorial

Test

go test ./... -v
cd tools/gen-plugin && ./test_gen_tools.sh

LICENSE

GPL-3.0

Resource

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin interface {
	// Init storage interface
	InitDao(d storage.Dao)

	// Init http router
	InitHttp() []router.Http

	// Receive Extrinsic data when subscribe extrinsic dispatch
	ProcessExtrinsic(*storage.Block, *storage.Extrinsic, []storage.Event) error

	// Receive Extrinsic data when subscribe extrinsic dispatch
	ProcessEvent(*storage.Block, *storage.Event, decimal.Decimal) error

	// Receive Block data when subscribe block
	ProcessBlock(context.Context, *storage.Block) error

	// Mysql tables schema auto migrate
	Migrate()

	// Subscribe Extrinsic with special module
	SubscribeExtrinsic() []string

	// Subscribe Events with special module
	SubscribeEvent() []string

	// Plugins version
	Version() string

	// Set Redis Pool
	SetRedisPool(RedisPool)

	// Plugin enable
	Enable() bool

	// Consumption queue
	ConsumptionQueue() []string

	// ExecWorker exec a task when subscribe queue
	ExecWorker(ctx context.Context, queue, class string, raw interface{}) error

	// plugin common cli
	Commands() []cli.Command
}

type RedisPool

type RedisPool interface {
	// HMGet redis hmset
	HMGet(c context.Context, key string, field ...string) (ms map[string]string)
	// GetCacheTtl redis ttl
	GetCacheTtl(ctx context.Context, key string) int
	// HmSetEx redis setex
	HmSetEx(c context.Context, key string, value interface{}, ttl int) (err error)
	// SISMEMBER redis sismember
	SISMEMBER(c context.Context, key string, value interface{}) bool
	// SAdd redis sadd
	SAdd(c context.Context, key string, ttl int, value ...string) bool
	// HINCRBY redis hincrby
	HINCRBY(c context.Context, key string, field string, value int) (int, error)
}

Directories

Path Synopsis
tools
gen-plugin command
You can use the "packr clean" command to clean up this, and any other packr generated files.
You can use the "packr clean" command to clean up this, and any other packr generated files.
gen-plugin/packrd
You can use the "packr2 clean" command to clean up this, and any other packr generated files.
You can use the "packr2 clean" command to clean up this, and any other packr generated files.

Jump to

Keyboard shortcuts

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