cchain

package
v0.1.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cchain defines the API to interact with the omni consensus chain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	// Subscribe registers a callback function that will be called with all approved
	// attestations (as they become available per source chain block) on the consensus chain from
	// the provided source chain ID and height (inclusive).
	//
	// Worker name is only used for metrics.
	Subscribe(ctx context.Context, sourceChainID uint64, sourceHeight uint64,
		workerName string, callback ProviderCallback)

	// AttestationsFrom returns the subsequent approved attestations for the provided source chain
	// and height (inclusive). It will return max 100 attestations per call.
	AttestationsFrom(ctx context.Context, sourceChainID uint64, sourceHeight uint64) ([]xchain.Attestation, error)

	// LatestAttestation returns the latest approved attestation for the provided source chain or false
	// if none exist.
	LatestAttestation(ctx context.Context, sourceChainID uint64) (xchain.Attestation, bool, error)

	// WindowCompare returns wether the given attestation block header is behind (-1), or in (0), or ahead (1)
	// of the current vote window. The vote window is a configured number of blocks around the latest approved
	// attestation for the provided chain.
	WindowCompare(ctx context.Context, sourceChainID uint64, height uint64) (int, error)
}

Provider abstracts connecting to the omni consensus chain and streaming approved attestations for each source chain block from a specific height.

It provides exactly once-delivery guarantees for the callback function. It will exponentially backoff and retry forever while the callback function returns an error.

type ProviderCallback

type ProviderCallback func(ctx context.Context, approved xchain.Attestation) error

ProviderCallback is the callback function signature that will be called with each approved attestation per source chain block in strictly sequential order.

Directories

Path Synopsis
Package provider implements the cchain.Provider interface.
Package provider implements the cchain.Provider interface.

Jump to

Keyboard shortcuts

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