avail

package
v0.0.0-...-674c92d Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBlockTracker = &config.AvailBlockTrackerConfig{
	Network:        config.DefaultAvailNetwork.String(),
	AvailAPIconfig: api.DefaultClientConfig,
	Meter:          otel.GetMeterProvider().Meter("avail_block_tracker"),
}
View Source
var DefaultNetorkScrapperConfig = &config.AvailNetworkScrapperConfig{
	Network:              config.DefaultAvailNetwork.String(),
	TrackBlocksOnDB:      true,
	NotChannelBufferSize: 1000,
	SamplerNotifyTimeout: 10 * time.Second,
	TrackDuration:        20 * time.Minute,
	TrackInterval:        6 * time.Hour,
	BlockTrackerCfg:      DefaultBlockTracker,
}

Functions

func MultihashFromHexString

func MultihashFromHexString(s string) (mh.Multihash, error)

Types

type Block

type Block struct {
	ReceivedAt     int64
	Hash           mh.Multihash
	ParentHash     mh.Multihash
	Number         uint64
	StateRoot      mh.Multihash
	ExtrinsicsRoot mh.Multihash
	Extension      BlockExtension
}

func NewBlock

func NewBlock(opts ...BlockOption) (*Block, error)

func (*Block) Cid

func (b *Block) Cid() cid.Cid

func (*Block) GetDASSamplingItems

func (b *Block) GetDASSamplingItems(network config.Network, traceItem bool) []*models.SamplingItem

func (*Block) SampleUntil

func (b *Block) SampleUntil() time.Time

func (*Block) ToDBBlock

func (b *Block) ToDBBlock(network config.Network) models.Block

func (*Block) UTCTimestamp

func (b *Block) UTCTimestamp() time.Time

type BlockAppLookup

type BlockAppLookup struct {
	Size  uint64
	Index []BlockAppLookupIndex
}

type BlockAppLookupIndex

type BlockAppLookupIndex struct {
	AppID uint64
	Start uint64
}

type BlockConsumer

type BlockConsumer interface {
	Type() ConsumerType
	Serve(context.Context) error
	ProccessNewBlock(context.Context, *BlockNotification, time.Time) error
}

type BlockExtension

type BlockExtension struct {
	Rows        uint64
	Columns     uint64
	DataRoot    mh.Multihash
	Commitments []string // TODO: parse them correctly?
	Size        uint64
	Start       uint64
	AppLookup   BlockAppLookup
}

type BlockNotification

type BlockNotification struct {
	RequestTime time.Time
	BlockInfo   api.V2BlockHeader
}

type BlockOption

type BlockOption func(*Block) error

func FromAPIBlockHeader

func FromAPIBlockHeader(blockHeader api.V2BlockHeader) BlockOption

type BlockRequester

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

func NewBlockRequester

func NewBlockRequester(
	apiCli *api.HTTPClient,
	networkConfig *config.NetworkConfiguration,
	consumers []BlockConsumer) (*BlockRequester, error)

func (*BlockRequester) AvailAPIhealthcheck

func (r *BlockRequester) AvailAPIhealthcheck(ctx context.Context) error

func (*BlockRequester) Serve

func (r *BlockRequester) Serve(ctx context.Context) error

type BlockTracker

type BlockTracker struct {
	BlockRequester *BlockRequester
	// contains filtered or unexported fields
}

func NewBlockTracker

func NewBlockTracker(
	ctx context.Context,
	cfg *config.AvailBlockTrackerConfig,
	blockConsumers ...BlockConsumer) (*BlockTracker, error)

func (*BlockTracker) Close

func (t *BlockTracker) Close(ctx context.Context) error

func (*BlockTracker) Start

func (t *BlockTracker) Start(ctx context.Context) error

type CallBackConsumer

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

func NewCallBackConsumer

func NewCallBackConsumer(
	ctx context.Context,
	blockProcessFn func(context.Context, *BlockNotification, time.Time) error,
) (*CallBackConsumer, error)

func (*CallBackConsumer) ProccessNewBlock

func (cb *CallBackConsumer) ProccessNewBlock(
	ctx context.Context,
	blockNot *BlockNotification,
	lastReqT time.Time) error

func (*CallBackConsumer) Serve

func (cb *CallBackConsumer) Serve(ctx context.Context) error

func (*CallBackConsumer) Type

func (cb *CallBackConsumer) Type() ConsumerType

type ConsumerType

type ConsumerType string
var (
	TextConsumerType     ConsumerType = "text"
	AkaiAPIConsumerType  ConsumerType = "akai_api"
	CallBackConsumerType ConsumerType = "callback"
)

type NetworkScrapper

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

NetworkScrapper is a minor wrapper on top of the BlockTracker that takes care of: - keeping track of all the DAS items comming from the Avail network - populate the DB with block information - perform some catching to not spam the DataSampler - notify to the DataSampler whenever there is an new item to track

func NewNetworkScrapper

func NewNetworkScrapper(
	cfg *config.AvailNetworkScrapperConfig,
	db db.Database,
) (*NetworkScrapper, error)

func (*NetworkScrapper) Close

func (s *NetworkScrapper) Close(ctx context.Context) error

func (*NetworkScrapper) GetQuorum

func (s *NetworkScrapper) GetQuorum() int

func (*NetworkScrapper) GetSamplingItemStream

func (s *NetworkScrapper) GetSamplingItemStream() chan []*models.SamplingItem

func (*NetworkScrapper) Serve

func (s *NetworkScrapper) Serve(ctx context.Context) error

func (*NetworkScrapper) SyncWithDatabase

func (s *NetworkScrapper) SyncWithDatabase(ctx context.Context) ([]*models.SamplingItem, error)

syncs up with the database any prior existing sampleable item that we should keep tracking

type TextConsumer

type TextConsumer struct{}

TextConsumer (most simple text logger consumer)

func NewTextConsumer

func NewTextConsumer() (*TextConsumer, error)

func (*TextConsumer) ProccessNewBlock

func (tc *TextConsumer) ProccessNewBlock(
	ctx context.Context,
	blockNot *BlockNotification,
	lastReqT time.Time) error

func (*TextConsumer) Serve

func (tc *TextConsumer) Serve(ctx context.Context) error

func (*TextConsumer) Type

func (tc *TextConsumer) Type() ConsumerType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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