syncer

package
v0.0.0-...-f069fcf Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIBTPNotFound  = fmt.Errorf("receipt from link33 failed")
	ErrMetaOutOfDate = fmt.Errorf("interchain meta is out of date")
)

Functions

This section is empty.

Types

type AppchainHandler

type AppchainHandler func() error

type Config

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

func GenerateConfig

func GenerateConfig(opts ...Option) (*Config, error)

type Handler

type Handler interface {
	// GetAppchains gets appchains from bitxhub node
	GetAppchains() ([]*appchainmgr.Appchain, error)

	// GetInterchainById gets interchain meta by appchain id
	GetInterchainById(from string) *pb.Interchain

	// RegisterRecoverHandler registers handler that recover ibtps from bitxhub
	RegisterRecoverHandler(RecoverUnionHandler) error

	// RegisterAppchainHandler registers handler that fetch appchains information
	RegisterAppchainHandler(handler AppchainHandler) error
}

type IBTPHandler

type IBTPHandler func(ibtp *pb.IBTP)

type Option

type Option func(*Config)

func WithClient

func WithClient(cli rpcx.Client) Option

func WithLogger

func WithLogger(logger logrus.FieldLogger) Option

func WithStorage

func WithStorage(store storage.Storage) Option

type RecoverUnionHandler

type RecoverUnionHandler func(ibtp *pb.IBTP) (*rpcx.Interchain, error)

type RollbackHandler

type RollbackHandler func(ibtp *pb.IBTP)

type SubscriptionKey

type SubscriptionKey struct {
	SidecarID   string `json:"sidecar_id"`
	AppchainDID string `json:"appchain_did"`
}

type Syncer

type Syncer interface {
	// QueryInterchainMeta queries meta including interchain and receipt related meta from bitxhub
	QueryInterchainMeta() *pb.Interchain

	// QueryIBTP query ibtp from bitxhub by its id.
	// if error occurs, it means this ibtp is not existed on bitxhub
	QueryIBTP(ibtpID string) (*pb.IBTP, bool, error)

	// ListenIBTP listen on the ibtps destined for this sidecar from bitxhub
	ListenIBTP() <-chan *pb.IBTPX

	// SendIBTP sends interchain or receipt type of ibtp to bitxhub
	// if error occurs, user need to reconstruct this ibtp cause it means ibtp is invalid on bitxhub
	SendIBTP(ibtp *pb.IBTP) error

	RegisterRollbackHandler(handler RollbackHandler) error
}

type WrapperSyncer

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

WrapperSyncer represents the necessary data for sync tx wrappers from link33

func New

func New(sidecarID, appchainDID string, mode string, opts ...Option) (*WrapperSyncer, error)

New creates instance of WrapperSyncer given agent interacting with link33, validators addresses of link33 and local storage

func (*WrapperSyncer) GetAppchains

func (syncer *WrapperSyncer) GetAppchains() ([]*appchainmgr.Appchain, error)

func (*WrapperSyncer) GetInterchainById

func (syncer *WrapperSyncer) GetInterchainById(from string) *pb.Interchain

func (*WrapperSyncer) ListenIBTP

func (syncer *WrapperSyncer) ListenIBTP() <-chan *pb.IBTPX

func (*WrapperSyncer) QueryIBTP

func (syncer *WrapperSyncer) QueryIBTP(ibtpID string) (*pb.IBTP, bool, error)

func (*WrapperSyncer) QueryInterchainMeta

func (syncer *WrapperSyncer) QueryInterchainMeta() *pb.Interchain

func (*WrapperSyncer) RegisterAppchainHandler

func (syncer *WrapperSyncer) RegisterAppchainHandler(handler AppchainHandler) error

func (*WrapperSyncer) RegisterRollbackHandler

func (syncer *WrapperSyncer) RegisterRollbackHandler(handler RollbackHandler) error

func (*WrapperSyncer) SendIBTP

func (syncer *WrapperSyncer) SendIBTP(ibtp *pb.IBTP) error

func (*WrapperSyncer) Start

func (syncer *WrapperSyncer) Start() error

Start implements Syncer

func (*WrapperSyncer) Stop

func (syncer *WrapperSyncer) Stop() error

Stop implements Syncer

Directories

Path Synopsis
Package mock_syncer is a generated GoMock package.
Package mock_syncer is a generated GoMock package.

Jump to

Keyboard shortcuts

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