Documentation
¶
Overview ¶
Package ports provides an adapter management center and enables plug-ins for adapter modules to enhance extendibility and maintainability.
This development has only three small goals: 1. Micro code refactoring - change the original code as little as possible; 2. Determine the interface - provides an adapter interface (AdapterController) to enable plug-ins for adapter modules; 3. Centralized adapter management - provides a pool interface (Ports) to enhance extendibility and maintainability.
Index ¶
- func Consensus2of3(value int) int
- func GetAdapterKey(a Adapter) string
- func GetAdapterKeyByConfig(c *AdapterConfig) string
- func GetAdapters(chainName string) (map[string]Adapter, error)
- func GetNodeAddress(a Adapter) string
- func ParseNodeAddress(nodeAddr string) (string, int, error)
- func RegisterAdapter(config *AdapterConfig) error
- type Adapter
- type AdapterConfig
- type AdapterController
- type AdapterService
- type Builder
- type EventsListener
- type Ports
- type QosAdapter
- func (a *QosAdapter) Count() (totalNumber int, consensusNumber int)
- func (a *QosAdapter) GetChainName() string
- func (a *QosAdapter) GetIP() string
- func (a *QosAdapter) GetPort() int
- func (a *QosAdapter) GetSequence() int64
- func (a *QosAdapter) ObtainTx(chain string, sequence int64) (qcp *txs.TxQcp, err error)
- func (a *QosAdapter) QuerySequence(chainName string, inout string) (int64, error)
- func (a *QosAdapter) Start() error
- func (a *QosAdapter) Stop() error
- func (a *QosAdapter) SubmitTx(chain string, tx *txs.TxQcp) error
- func (a *QosAdapter) Subscribe(listener EventsListener)
- func (a *QosAdapter) Sync() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAdapterKeyByConfig ¶
func GetAdapterKeyByConfig(c *AdapterConfig) string
GetAdapterKeyByConfig Gen an adapter key from adapter config
func GetAdapters ¶
GetAdapters Get all Adapters for the specified chain
func ParseNodeAddress ¶
ParseNodeAddress parse node address to get ip and port
func RegisterAdapter ¶
func RegisterAdapter(config *AdapterConfig) error
RegisterAdapter Check, create and register an Adapter
Types ¶
type Adapter ¶
type Adapter interface {
SubmitTx(chainID string, tx *txs.TxQcp) error
ObtainTx(chainID string, sequence int64) (*txs.TxQcp, error)
QuerySequence(chainID string, inout string) (int64, error)
GetSequence() int64
// Count Calculate the total and consensus number for chain
Count() (totalNumber int, consensusNumber int)
GetChainName() string
GetIP() string
GetPort() int
}
Adapter Chain adapter interface for consensus engine ( consensus.ConsEngine ) and ferry ( consensus.Ferry )
type AdapterConfig ¶
type AdapterConfig struct {
ChainName string
ChainType string
IP string
Port int
Query string
Listener EventsListener
}
AdapterConfig is parameters for build an AdapterService
type AdapterController ¶
type AdapterController interface {
Start() error
Sync() error
Stop() error
Subscribe(listener EventsListener)
}
AdapterController Chain adapter controller interface for adapter pool manager ( adapter.Ports )
type AdapterService ¶
type AdapterService interface {
AdapterController
Adapter
}
AdapterService Inner cache type ( AdapterController and Adapter )
Suitable for a variety of different block chain
type Builder ¶
type Builder func(config AdapterConfig) (AdapterService, error)
Builder Create an AdapterService for the specified chain
type EventsListener ¶
EventsListener Listen Tx events from target chain
type Ports ¶
type Ports interface {
Init()
RegisterBuilder(chain string, builder Builder) error
Register(config *AdapterConfig) error
Count(chainName string) int
Get(chainName string) (map[string]Adapter, error)
}
Ports Chain adapter pool interface
func GetPortsIncetance ¶
func GetPortsIncetance() Ports
GetPortsIncetance Get Ports singlton instance
type QosAdapter ¶
type QosAdapter struct {
// contains filtered or unexported fields
}
QosAdapter provides adapter for qos chain
func (*QosAdapter) Count ¶
func (a *QosAdapter) Count() (totalNumber int, consensusNumber int)
Count return total number and consensus number of adapters for qos chain
func (*QosAdapter) GetChainName ¶
func (a *QosAdapter) GetChainName() string
GetChainName returns chain's name
func (*QosAdapter) GetSequence ¶
func (a *QosAdapter) GetSequence() int64
GetSequence returns sequence stored in QosAdapter
func (*QosAdapter) QuerySequence ¶
func (a *QosAdapter) QuerySequence(chainName string, inout string) (int64, error)
QuerySequence query sequence for the specified chainName and inout ("in" or "out")
func (*QosAdapter) SubmitTx ¶
func (a *QosAdapter) SubmitTx(chain string, tx *txs.TxQcp) error
SubmitTx submit Tx to qos chain
func (*QosAdapter) Subscribe ¶
func (a *QosAdapter) Subscribe(listener EventsListener)
Subscribe events from qos chain