syncer

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type AppchainHandler added in v1.4.0

type AppchainHandler func() error

type Config added in v1.5.0

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

func GenerateConfig added in v1.5.0

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

type IBTPHandler

type IBTPHandler func(ibtp *pb.IBTP)

type Option added in v1.5.0

type Option func(*Config)

func WithClient added in v1.5.0

func WithClient(cli rpcx.Client) Option

func WithLite added in v1.5.0

func WithLite(lite lite.Lite) Option

func WithLogger added in v1.5.0

func WithLogger(logger logrus.FieldLogger) Option

func WithStorage added in v1.5.0

func WithStorage(store storage.Storage) Option

type RecoverUnionHandler added in v1.4.0

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

type RollbackHandler added in v1.6.1

type RollbackHandler func(ibtp *pb.IBTP)

type SubscriptionKey added in v1.8.0

type SubscriptionKey struct {
	PierID      string `json:"pier_id"`
	AppchainDID string `json:"appchain_did"`
}

type Syncer

type Syncer interface {
	// Start starts the service of syncer
	Start() error

	// Stop stops the service of syncer
	Stop() error

	// 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 pier from bitxhub
	ListenIBTP() <-chan *model.WrappedIBTP

	// 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

	GetAssetExchangeSigns(id string) ([]byte, error)

	//getIBTPSigns gets ibtp signs from bitxhub cluster
	GetIBTPSigns(ibtp *pb.IBTP) ([]byte, error)

	//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

	RegisterRollbackHandler(handler RollbackHandler) error
}

type WrapperSyncer

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

WrapperSyncer represents the necessary data for sync tx wrappers from bitxhub

func New

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

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

func (*WrapperSyncer) GetAppchains added in v1.5.0

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

func (*WrapperSyncer) GetAssetExchangeSigns added in v1.5.0

func (syncer *WrapperSyncer) GetAssetExchangeSigns(id string) ([]byte, error)

func (*WrapperSyncer) GetIBTPSigns added in v1.5.0

func (syncer *WrapperSyncer) GetIBTPSigns(ibtp *pb.IBTP) ([]byte, error)

func (*WrapperSyncer) GetInterchainById added in v1.5.0

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

func (*WrapperSyncer) ListenIBTP added in v1.5.0

func (syncer *WrapperSyncer) ListenIBTP() <-chan *model.WrappedIBTP

func (*WrapperSyncer) QueryIBTP added in v1.5.0

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

func (*WrapperSyncer) QueryInterchainMeta added in v1.5.0

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

func (*WrapperSyncer) RegisterAppchainHandler added in v1.4.0

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

func (*WrapperSyncer) RegisterRecoverHandler added in v1.4.0

func (syncer *WrapperSyncer) RegisterRecoverHandler(handleRecover RecoverUnionHandler) error

func (*WrapperSyncer) RegisterRollbackHandler added in v1.6.1

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

func (*WrapperSyncer) SendIBTP added in v1.5.0

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