plugins

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 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, pierID string, extra []byte) error

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

	// Stop stops client
	Stop() error

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

	// SubmitIBTP submits the interchain ibtp to appchain
	SubmitIBTP(*pb.IBTP) (*pb.SubmitIBTPResponse, error)

	// RollbackIBTP rollbacks the interchain ibtp to appchain
	RollbackIBTP(ibtp *pb.IBTP, isSrcChain bool) (*pb.RollbackIBTPResponse, error)

	// increase in meta without actually executing it
	IncreaseInMeta(ibtp *pb.IBTP) (*pb.IBTP, error)

	// GetOutMessage gets interchain ibtp by index and target chain_id from broker contract
	GetOutMessage(to string, idx uint64) (*pb.IBTP, error)

	// GetInMessage gets receipt by index and source chain_id
	GetInMessage(from string, idx uint64) ([][]byte, error)

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

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

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

	// CommitCallback is a callback function when get receipt from bitxhub success
	CommitCallback(ibtp *pb.IBTP) error

	// GetReceipt gets receipt of an executed IBTP
	GetReceipt(ibtp *pb.IBTP) (*pb.IBTP, error)

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

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

Client defines the interface that interacts with appchain

func CreateClient

func CreateClient(pierID string, 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) CommitCallback added in v1.4.0

func (g *GRPCClient) CommitCallback(_ *pb.IBTP) error

func (*GRPCClient) GetCallbackMeta added in v1.4.0

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

func (*GRPCClient) GetIBTP added in v1.4.0

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

func (*GRPCClient) GetInMessage added in v1.4.0

func (g *GRPCClient) GetInMessage(from string, idx uint64) ([][]byte, error)

func (*GRPCClient) GetInMeta added in v1.4.0

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

func (*GRPCClient) GetOutMessage added in v1.4.0

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

func (*GRPCClient) GetOutMeta added in v1.4.0

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

func (*GRPCClient) GetReceipt added in v1.6.0

func (g *GRPCClient) GetReceipt(ibtp *pb.IBTP) (*pb.IBTP, error)

func (*GRPCClient) IncreaseInMeta added in v1.6.1

func (g *GRPCClient) IncreaseInMeta(original *pb.IBTP) (*pb.IBTP, error)

func (*GRPCClient) Initialize added in v1.4.0

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

func (*GRPCClient) Name added in v1.4.0

func (g *GRPCClient) Name() string

func (*GRPCClient) RollbackIBTP added in v1.6.1

func (g *GRPCClient) RollbackIBTP(ibtp *pb.IBTP, srcChain bool) (*pb.RollbackIBTPResponse, error)

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(ibtp *pb.IBTP) (*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) GetCallbackMeta added in v1.4.0

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

func (*GRPCServer) GetIBTP added in v1.4.0

func (s *GRPCServer) GetIBTP(_ *pb.Empty, conn pb.AppchainPlugin_GetIBTPServer) error

func (*GRPCServer) GetInMessage added in v1.4.0

func (*GRPCServer) GetInMeta added in v1.4.0

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

func (*GRPCServer) GetOutMessage added in v1.4.0

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

func (*GRPCServer) GetOutMeta added in v1.4.0

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

func (*GRPCServer) GetReceipt added in v1.6.0

func (s *GRPCServer) GetReceipt(_ context.Context, ibtp *pb.IBTP) (*pb.IBTP, error)

func (*GRPCServer) IncreaseInMeta added in v1.6.1

func (s *GRPCServer) IncreaseInMeta(_ context.Context, in *pb.IBTP) (*pb.IBTP, 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) RollbackIBTP added in v1.6.1

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 (s *GRPCServer) SubmitIBTP(_ context.Context, ibtp *pb.IBTP) (*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