fab

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalancerType

type BalancerType string

BalancerType is the load-balancer type

const (
	// RoundRobin (default) chooses endorsers in a round-robin fashion
	RoundRobin BalancerType = "RoundRobin"

	// Random chooses endorsers randomly
	Random BalancerType = "Random"
)

type CertKeyPair

type CertKeyPair struct {
	Cert []byte
	Key  []byte
}

CertKeyPair contains the private key and certificate

type ChannelEndpointConfig

type ChannelEndpointConfig struct {
	// Orderers list of ordering service nodes
	Orderers []string
	// Peers a list of peer-channels that are part of this organization
	// to get the real Peer config object, use the Name field and fetch NetworkConfig.Peers[Name]
	Peers map[string]PeerChannelConfig
	// Policies list of policies for channel
	Policies ChannelPolicies
}

ChannelEndpointConfig provides the definition of channels for the network

type ChannelPeer

type ChannelPeer struct {
	PeerChannelConfig
	NetworkPeer
}

ChannelPeer combines channel peer info with raw peerConfig info

type ChannelPolicies

type ChannelPolicies struct {
	// Policy for querying channel block
	QueryChannelConfig QueryChannelConfigPolicy
	Discovery          DiscoveryPolicy
	Selection          SelectionPolicy
	EventService       EventServicePolicy
}

ChannelPolicies defines list of policies defined for a channel

type DiscoveryPolicy

type DiscoveryPolicy struct {
	MinResponses int
	MaxTargets   int
	RetryOpts    retry.Opts
}

DiscoveryPolicy defines policy for discovery

type EnabledDisabled

type EnabledDisabled string

EnabledDisabled specifies whether or not a feature is enabled

const (
	// Enabled indicates that the feature is enabled.
	Enabled EnabledDisabled = "Enabled"

	// Disabled indicates that the feature is disabled.
	Disabled EnabledDisabled = "Disabled"
)

type EventServicePolicy

type EventServicePolicy struct {
	// ResolverStrategy returns the peer resolver strategy to use when connecting to a peer
	// Default: MinBlockHeightPeerResolver
	ResolverStrategy ResolverStrategy

	// Balancer is the balancer to use when choosing a peer to connect to
	Balancer BalancerType

	// MinBlockHeightResolverMode specifies the behaviour of the MinBlockHeight resolver. Note that this
	// parameter is used when ResolverStrategy is either MinBlockHeightStrategy or PreferOrgStrategy.
	// ResolveByThreshold (default): resolves to peers based on block height lag threshold, as specified by BlockHeightLagThreshold.
	// MinBlockHeightResolverMode: then only the peers with the latest block heights are chosen.
	MinBlockHeightResolverMode MinBlockHeightResolverMode

	// BlockHeightLagThreshold returns the block height lag threshold. This value is used for choosing a peer
	// to connect to. If a peer is lagging behind the most up-to-date peer by more than the given number of
	// blocks then it will be excluded from selection.
	BlockHeightLagThreshold int

	// PeerMonitor indicates whether or not to enable the peer monitor.
	PeerMonitor EnabledDisabled

	// ReconnectBlockHeightLagThreshold - if >0 then the event client will disconnect from the peer if the peer's
	// block height falls behind the specified number of blocks and will reconnect to a better performing peer.
	// If set to 0 (default) then the peer will not disconnect based on block height.
	// NOTE: Setting this value too low may cause the event client to disconnect/reconnect too frequently, thereby
	// affecting performance.
	ReconnectBlockHeightLagThreshold int

	// PeerMonitorPeriod is the period in which the connected peer is monitored to see if
	// the event client should disconnect from it and reconnect to another peer.
	// If set to 0 then the peer will not be monitored and will not be disconnected.
	PeerMonitorPeriod time.Duration
}

EventServicePolicy specifies the policy for the event service

type MinBlockHeightResolverMode

type MinBlockHeightResolverMode string

MinBlockHeightResolverMode specifies the behaviour of the MinBlockHeight resolver strategy.

const (
	// ResolveByThreshold resolves to peers based on block height lag threshold.
	ResolveByThreshold MinBlockHeightResolverMode = "ResolveByThreshold"

	// ResolveLatest resolves to peers with the most up-to-date block height
	ResolveLatest MinBlockHeightResolverMode = "ResolveLatest"
)

type NetworkConfig

type NetworkConfig struct {
	Channels      map[string]ChannelEndpointConfig
	Organizations map[string]OrganizationConfig
	Orderers      map[string]OrdererConfig
	Peers         map[string]PeerConfig
}

NetworkConfig provides a static definition of endpoint configuration network

type NetworkPeer

type NetworkPeer struct {
	PeerConfig
	MSPID      string
	Properties map[Property]interface{}
}

NetworkPeer combines peer info with MSP info

type OrdererConfig

type OrdererConfig struct {
	URL         string
	GRPCOptions map[string]interface{}
	TLSCACert   *x509.Certificate
}

OrdererConfig defines an orderer configuration

type OrganizationConfig

type OrganizationConfig struct {
	MSPID                  string
	CryptoPath             string
	Users                  map[string]CertKeyPair
	Peers                  []string
	CertificateAuthorities []string
}

OrganizationConfig provides the definition of an organization in the network

type PeerChannelConfig

type PeerChannelConfig struct {
	EndorsingPeer  bool
	ChaincodeQuery bool
	LedgerQuery    bool
	EventSource    bool
}

PeerChannelConfig defines the peer capabilities

type PeerConfig

type PeerConfig struct {
	URL         string
	GRPCOptions map[string]interface{}
	TLSCACert   *x509.Certificate
}

PeerConfig defines a peer configuration

type PeerState

type PeerState interface {
	BlockHeight() uint64
}

PeerState provides state information about the Peer

type Properties

type Properties map[Property]interface{}

Properties defines the properties of a peer

type Property

type Property = string

Property is the key into the Properties map

const (
	// PropertyChaincodes defines the chaincodes that are deployed on the peer. Value type:[]*github.com/hyperledger/fabric-protos-go/gossip.Chaincode
	PropertyChaincodes Property = "Chaincodes"
	// PropertyLedgerHeight defines the ledger height property. Value type: uint64
	PropertyLedgerHeight Property = "LedgerHeight"
	// PropertyLeftChannel defines the "left-channel" property which indicates whether the peer left the channel. Value type: bool
	PropertyLeftChannel Property = "LeftChannel"
)

Following is a well-known list of properties of a peer, although this list may be extended.

type QueryChannelConfigPolicy

type QueryChannelConfigPolicy struct {
	MinResponses int
	MaxTargets   int
	RetryOpts    retry.Opts
}

QueryChannelConfigPolicy defines policy for channelConfigBlock

type ResolverStrategy

type ResolverStrategy string

ResolverStrategy is the peer resolver type

const (
	// BalancedStrategy is a peer resolver strategy that chooses peers based on a configured load balancer
	BalancedStrategy ResolverStrategy = "Balanced"

	// MinBlockHeightStrategy is a peer resolver strategy that chooses the best peer according to a block height lag threshold.
	// The maximum block height of all peers is determined and the peers whose block heights are under the maximum height but above
	// a provided "lag" threshold are load balanced. The other peers are not considered.
	MinBlockHeightStrategy ResolverStrategy = "MinBlockHeight"

	// PreferOrgStrategy is a peer resolver strategy that determines which peers are suitable based on block height lag threshold,
	// although will prefer the peers in the current org (as long as their block height is above a configured threshold).
	// If none of the peers from the current org are suitable then a peer from another org is chosen.
	PreferOrgStrategy ResolverStrategy = "PreferOrg"
)

type SelectionPolicy

type SelectionPolicy struct {
	// SortingStrategy is the endorser sorting strategy to use
	SortingStrategy SelectionSortingStrategy

	// BalancerType is the balancer to use in order to load-balance calls to endorsers
	Balancer BalancerType

	// BlockHeightLagThreshold is the number of blocks from the highest block number of a group of peers
	// that a peer can lag behind and still be considered to be up-to-date. These peers will be sorted
	// using the given Balancer. If a peer's block height falls behind this threshold then it will be
	// demoted to a lower priority list of peers which will be sorted according to block height.
	// Note: This property only applies to BlockHeightPriority sorter
	BlockHeightLagThreshold int
}

SelectionPolicy defines policy for selection

type SelectionSortingStrategy

type SelectionSortingStrategy string

SelectionSortingStrategy is the endorser selection sorting strategy

const (
	// BlockHeightPriority (default) is a load-balancing selection sorting strategy
	// which also prioritizes peers at a block height that is above a certain "lag" threshold.
	BlockHeightPriority SelectionSortingStrategy = "BlockHeightPriority"

	// Balanced is a load-balancing selection sorting strategy
	Balanced SelectionSortingStrategy = "Balanced"
)

Jump to

Keyboard shortcuts

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