plugins

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: GPL-3.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Handshake = plugin.HandshakeConfig{
		ProtocolVersion:  4,
		MagicCookieKey:   "PIER_APPCHAIN_PLUGIN",
		MagicCookieValue: "PIER",
	}
	PluginName = "appchain-plugin"
)

Handshake is a common handshake that is shared by plugin and host.

View Source
var PluginMap = map[string]plugin.Plugin{
	PluginName: &AppchainGRPCPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type AppchainGRPCPlugin added in v1.4.0

type AppchainGRPCPlugin struct {
	plugin.Plugin
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl Client
}

This is the implementation of plugin.GRPCPlugin so we can serve/consume this.

func (*AppchainGRPCPlugin) GRPCClient added in v1.4.0

func (p *AppchainGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*AppchainGRPCPlugin) GRPCServer added in v1.4.0

func (p *AppchainGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type Client added in v1.4.0

type Client interface {
	// Initialize initialize plugin client
	Initialize(configPath string, extra []byte) error

	// Start starts to listen appchain event
	Start() error

	// Stop stops client
	Stop() error

	// GetIBTPCh gets an interchain ibtp channel generated by client
	GetIBTPCh() chan *pb.IBTP

	// GetUpdateMeta gets an updated trust meta channel by client
	GetUpdateMeta() chan *pb.UpdateMeta

	// SubmitIBTP submits the interchain ibtp to appchain
	SubmitIBTP(from string, index uint64, serviceID string, ibtpType pb.IBTP_Type, content *pb.Content, proof *pb.BxhProof, isEncrypted bool) (*pb.SubmitIBTPResponse, error)

	// SubmitReceipt submit the receipt ibtp to appchain
	SubmitReceipt(to string, index uint64, serviceID string, ibtpType pb.IBTP_Type, result *pb.Result, proof *pb.BxhProof) (*pb.SubmitIBTPResponse, error)

	// GetOutMessage gets interchain ibtp by service pair and index from broker contract
	GetOutMessage(servicePair string, idx uint64) (*pb.IBTP, error)

	// GetReceiptMessage gets receipt ibtp by service pair and index from broker contract
	GetReceiptMessage(servicePair string, idx uint64) (*pb.IBTP, error)

	// GetInMeta gets an index map, which implicates the greatest index of
	// ingoing interchain txs for each service pair
	GetInMeta() (map[string]uint64, error)

	// GetOutMeta gets an index map, which implicates the greatest index of
	// outgoing interchain txs for each service pair
	GetOutMeta() (map[string]uint64, error)

	// GetReceiptMeta gets an index map, which implicates the greatest index of
	// executed callback txs for each service pair
	GetCallbackMeta() (map[string]uint64, error)

	// GetDstRollbackMeta gets an index map, which implicates the greatest index of
	// executed rollback txs from each service pair
	GetDstRollbackMeta() (map[string]uint64, error)

	// GetDirectTransactionMeta gets transaction start timestamp, timeout period and transaction status in direct mode
	GetDirectTransactionMeta(string) (uint64, uint64, uint64, error)

	// GetServices gets all service IDs the pier cares
	GetServices() ([]string, error)

	// GetChainID gets BitXHub and appchain ID
	GetChainID() (string, string, error)

	// GetAppchainInfo gets appchain information by appchain ID
	GetAppchainInfo(chainID string) (string, []byte, string, error)

	// Name gets name of blockchain from plugin
	Name() string

	// Type gets type of blockchain from plugin
	Type() string

	// GetOffChainData get offchain data and send back
	GetOffChainData(request *pb.GetDataRequest) (*pb.GetDataResponse, error)

	// GetOffChainDataReq get offchain data request
	GetOffChainDataReq() chan *pb.GetDataRequest

	// SubmitOffChainData submit offchain data to plugin
	SubmitOffChainData(response *pb.GetDataResponse) error
}

Client defines the interface that interacts with appchain

func CreateClient

func CreateClient(appchainConfig *repo.Appchain, extra []byte) (Client, *plugin.Client, error)

type GRPCClient added in v1.4.0

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

GRPCClient is an implementation of Client that talks over RPC.

func (*GRPCClient) GetAppchainInfo added in v1.18.0

func (g *GRPCClient) GetAppchainInfo(chainID string) (string, []byte, string, error)

func (*GRPCClient) GetCallbackMeta added in v1.4.0

func (g *GRPCClient) GetCallbackMeta() (map[string]uint64, error)

func (*GRPCClient) GetChainID added in v1.12.0

func (g *GRPCClient) GetChainID() (string, string, error)

func (*GRPCClient) GetDirectTransactionMeta added in v1.21.0

func (g *GRPCClient) GetDirectTransactionMeta(id string) (uint64, uint64, uint64, error)

func (*GRPCClient) GetDstRollbackMeta added in v1.12.0

func (g *GRPCClient) GetDstRollbackMeta() (map[string]uint64, error)

func (*GRPCClient) GetIBTPCh added in v1.18.0

func (g *GRPCClient) GetIBTPCh() chan *pb.IBTP

func (*GRPCClient) GetInMeta added in v1.4.0

func (g *GRPCClient) GetInMeta() (map[string]uint64, error)

func (*GRPCClient) GetOffChainData added in v1.22.0

func (g *GRPCClient) GetOffChainData(request *pb.GetDataRequest) (*pb.GetDataResponse, error)

func (*GRPCClient) GetOffChainDataReq added in v1.22.0

func (g *GRPCClient) GetOffChainDataReq() chan *pb.GetDataRequest

func (*GRPCClient) GetOutMessage added in v1.4.0

func (g *GRPCClient) GetOutMessage(servicePair string, idx uint64) (*pb.IBTP, error)

func (*GRPCClient) GetOutMeta added in v1.4.0

func (g *GRPCClient) GetOutMeta() (map[string]uint64, error)

func (*GRPCClient) GetReceiptMessage added in v1.14.0

func (g *GRPCClient) GetReceiptMessage(servicePair string, idx uint64) (*pb.IBTP, error)

func (*GRPCClient) GetServices added in v1.12.0

func (g *GRPCClient) GetServices() ([]string, error)

func (*GRPCClient) GetUpdateMeta added in v1.18.0

func (g *GRPCClient) GetUpdateMeta() chan *pb.UpdateMeta

func (*GRPCClient) Initialize added in v1.4.0

func (g *GRPCClient) Initialize(configPath string, extra []byte) error

func (*GRPCClient) Name added in v1.4.0

func (g *GRPCClient) Name() string

func (*GRPCClient) Start added in v1.4.0

func (g *GRPCClient) Start() error

func (*GRPCClient) Stop added in v1.4.0

func (g *GRPCClient) Stop() error

func (*GRPCClient) SubmitIBTP added in v1.4.0

func (g *GRPCClient) SubmitIBTP(from string, index uint64, serviceID string, ibtpType pb.IBTP_Type, content *pb.Content, proof *pb.BxhProof, isEncrypted bool) (*pb.SubmitIBTPResponse, error)

func (*GRPCClient) SubmitOffChainData added in v1.22.0

func (g *GRPCClient) SubmitOffChainData(response *pb.GetDataResponse) error

func (*GRPCClient) SubmitReceipt added in v1.14.0

func (g *GRPCClient) SubmitReceipt(to string, index uint64, serviceID string, ibtpType pb.IBTP_Type, result *pb.Result, proof *pb.BxhProof) (*pb.SubmitIBTPResponse, error)

func (*GRPCClient) Type added in v1.4.0

func (g *GRPCClient) Type() string

type GRPCServer added in v1.4.0

type GRPCServer struct {
	Impl Client
}

---- gRPC Server domain ----

func (*GRPCServer) CommitCallback added in v1.4.0

func (s *GRPCServer) CommitCallback(_ context.Context, _ *pb.IBTP) (*pb.Empty, error)

func (*GRPCServer) GetAppchainInfo added in v1.18.0

func (s *GRPCServer) GetAppchainInfo(ctx context.Context, request *pb.ChainInfoRequest) (*pb.ChainInfoResponse, error)

func (*GRPCServer) GetCallbackMeta added in v1.4.0

func (s *GRPCServer) GetCallbackMeta(context.Context, *pb.Empty) (*pb.GetMetaResponse, error)

func (*GRPCServer) GetChainID added in v1.12.0

func (s *GRPCServer) GetChainID(ctx context.Context, empty *pb.Empty) (*pb.ChainIDResponse, error)

func (*GRPCServer) GetDirectTransactionMeta added in v1.21.0

func (s *GRPCServer) GetDirectTransactionMeta(ctx context.Context, request *pb.DirectTransactionMetaRequest) (*pb.DirectTransactionMetaResponse, error)

func (*GRPCServer) GetDstRollbackMeta added in v1.12.0

func (s *GRPCServer) GetDstRollbackMeta(ctx context.Context, empty *pb.Empty) (*pb.GetMetaResponse, error)

func (*GRPCServer) GetIBTPCh added in v1.18.0

func (s *GRPCServer) GetIBTPCh(_ *pb.Empty, conn pb.AppchainPlugin_GetIBTPChServer) error

func (*GRPCServer) GetInMeta added in v1.4.0

func (s *GRPCServer) GetInMeta(context.Context, *pb.Empty) (*pb.GetMetaResponse, error)

func (*GRPCServer) GetOffChainData added in v1.22.0

func (s *GRPCServer) GetOffChainData(ctx context.Context, req *pb.GetDataRequest) (*pb.GetDataResponse, error)

func (*GRPCServer) GetOffChainDataReq added in v1.22.0

func (s *GRPCServer) GetOffChainDataReq(_ *pb.Empty, conn pb.AppchainPlugin_GetOffChainDataReqServer) error

func (*GRPCServer) GetOutMessage added in v1.4.0

func (s *GRPCServer) GetOutMessage(_ context.Context, req *pb.GetMessageRequest) (*pb.IBTP, error)

func (*GRPCServer) GetOutMeta added in v1.4.0

func (s *GRPCServer) GetOutMeta(context.Context, *pb.Empty) (*pb.GetMetaResponse, error)

func (*GRPCServer) GetReceiptMessage added in v1.14.0

func (s *GRPCServer) GetReceiptMessage(_ context.Context, req *pb.GetMessageRequest) (*pb.IBTP, error)

func (*GRPCServer) GetServices added in v1.12.0

func (s *GRPCServer) GetServices(ctx context.Context, empty *pb.Empty) (*pb.ServicesResponse, error)

func (*GRPCServer) GetUpdateMeta added in v1.11.1

func (s *GRPCServer) GetUpdateMeta(empty *pb.Empty, server pb.AppchainPlugin_GetUpdateMetaServer) error

func (*GRPCServer) Initialize added in v1.4.0

func (s *GRPCServer) Initialize(_ context.Context, req *pb.InitializeRequest) (*pb.Empty, error)

func (*GRPCServer) Name added in v1.4.0

func (*GRPCServer) Start added in v1.4.0

func (s *GRPCServer) Start(context.Context, *pb.Empty) (*pb.Empty, error)

func (*GRPCServer) Stop added in v1.4.0

func (s *GRPCServer) Stop(context.Context, *pb.Empty) (*pb.Empty, error)

func (*GRPCServer) SubmitIBTP added in v1.4.0

func (*GRPCServer) SubmitOffChainData added in v1.22.0

func (s *GRPCServer) SubmitOffChainData(_ context.Context, res *pb.GetDataResponse) (*pb.Empty, error)

func (*GRPCServer) SubmitReceipt added in v1.14.0

func (s *GRPCServer) SubmitReceipt(ctx context.Context, ibtp *pb.SubmitReceiptRequest) (*pb.SubmitIBTPResponse, error)

func (*GRPCServer) Type added in v1.4.0

Directories

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

Jump to

Keyboard shortcuts

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