plugins

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: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Handshake = plugin.HandshakeConfig{
		ProtocolVersion:  4,
		MagicCookieKey:   "SIDECAR_APPCHAIN_PLUGIN",
		MagicCookieValue: "SIDECAR",
	}
	PluginName = "chain33-client"
)

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

插件进程在启动时设置Plugins,即ServeConfig中设置Plugins时,会指明其实现者; 宿主机进程在启动时也设置Plugins,即ClientConfig中设置Plugins时,不需要指明其实现者。 PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type AppchainGRPCPlugin

type AppchainGRPCPlugin struct {
	plugin.Plugin // 要嵌入(net/rpc)插件接口,是反射的作用。整个接口体需要实现:GRPCPlugin、plugin.Plugin两个接口,而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

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

func (*AppchainGRPCPlugin) GRPCServer

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

GRPCPlugin实现

type Client

type Client interface {
	Launcher
	Bind(kern Kernel)

	// Initialize initialize plugin client
	Initialize(configPath string, ID string, extra []byte) 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 link33 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

	// ID
	ID() string
}

Client defines the interface that interacts with appchain

func CreateClient

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

func CreateClients

func CreateClients(appchainConfigs []repo.Appchain, extra []byte) []Client

type GRPCClient

type GRPCClient struct {
	DID      string
	TypeName string
	// contains filtered or unexported fields
}

GRPCClient 实现了Client接口。此实现只是将请求转发给gRPC服务处理,通过gRPC客户端转发请求给插件进程 GRPCClient is an implementation of Client that talks over RPC.

func (*GRPCClient) Bind

func (g *GRPCClient) Bind(kern Kernel)

func (*GRPCClient) CommitCallback

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

func (*GRPCClient) GetCallbackMeta

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

func (*GRPCClient) GetIBTP

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

func (*GRPCClient) GetInMessage

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

func (*GRPCClient) GetInMeta

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

func (*GRPCClient) GetOutMessage

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

func (*GRPCClient) GetOutMeta

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

func (*GRPCClient) GetReceipt

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

func (*GRPCClient) ID

func (g *GRPCClient) ID() string

func (*GRPCClient) IncreaseInMeta

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

func (*GRPCClient) Initialize

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

func (*GRPCClient) Name

func (g *GRPCClient) Name() string

func (*GRPCClient) RollbackIBTP

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

func (*GRPCClient) Start

func (g *GRPCClient) Start() error

func (*GRPCClient) Stop

func (g *GRPCClient) Stop() error

func (*GRPCClient) SubmitIBTP

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

func (*GRPCClient) Type

func (g *GRPCClient) Type() string

type GRPCServer

type GRPCServer struct {
	Impl Client
}

实现 AppchainPluginServer接口,具体逻辑委托给业务接口Client的实现。主要是给插件进程使用。 ---- gRPC Server domain ----

func (*GRPCServer) CommitCallback

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

func (*GRPCServer) GetCallbackMeta

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

func (*GRPCServer) GetIBTP

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

func (*GRPCServer) GetInMessage

func (*GRPCServer) GetInMeta

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

func (*GRPCServer) GetOutMessage

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

func (*GRPCServer) GetOutMeta

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

func (*GRPCServer) GetReceipt

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

func (*GRPCServer) IncreaseInMeta

func (s *GRPCServer) IncreaseInMeta(_ context.Context, in *pb.IBTP) (*pb.IBTP, error)

func (*GRPCServer) Initialize

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

func (*GRPCServer) Name

func (*GRPCServer) RollbackIBTP

func (*GRPCServer) Start

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

func (*GRPCServer) Stop

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

func (*GRPCServer) SubmitIBTP

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

func (*GRPCServer) Type

type Kernel

type Kernel interface {
	Kill()
	Exited() bool
}

type Launcher

type Launcher interface {
	Start() error
	Stop() error
}

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