Documentation
¶
Index ¶
- Constants
- Variables
- type BlockSubscription
- type BlocksDeliverer
- type ChainInfoGetter
- type Chaincode
- type ChaincodeDiscoverer
- type ChaincodeInvokeBuilder
- type ChaincodeInvokeResponse
- type ChaincodeQueryBuilder
- type Channel
- type ChannelDiscoverer
- type ChannelListGetter
- type Client
- type CurrentIdentity
- type DeliverClient
- type DiscoveryProvider
- type DoOption
- type DoOptions
- type Endorser
- type Endpoint
- type EnvelopeParsingError
- type EventCCSeekOption
- type EventCCSubscription
- type EventsDeliverer
- type GRPCStreamError
- type HostEndpoint
- type InvalidTxError
- type Invoker
- type LocalPeersDiscoverer
- type MSPPeerPool
- type Orderer
- type ParsedBlocksDeliverer
- type Peer
- type PeerEndorseError
- type PeerPool
- type PeerPoolCheckStrategy
- type Querier
- type TransArgs
- type TxEvent
- type TxSubscription
- type TxWaiter
- type UnknownEventTypeError
Constants ¶
const ( TxWaiterSelfType string = "self" TxWaiterAllType string = "all" )
types which identify tx "wait'er" policy we don't make it as alias for preventing binding to our lib
Variables ¶
var ( SeekFromOldest = &orderer.SeekPosition{ Type: &orderer.SeekPosition_Oldest{Oldest: &orderer.SeekOldest{}}} SeekFromNewest = &orderer.SeekPosition{ Type: &orderer.SeekPosition_Newest{Newest: &orderer.SeekNewest{}}} SeekToMax = block.NewSeekSpecified(math.MaxUint64) )
Functions ¶
This section is empty.
Types ¶
type BlockSubscription ¶
type BlocksDeliverer ¶ added in v0.7.0
type BlocksDeliverer interface {
// Blocks - shortcut for core.PeerPool().DeliverClient(mspIdentity).SubscribeBlock(chanName,seekRange).Blocks()
// subscribe to new blocks on specified channel
// if provided 'identity' is 'nil' default one will be set
Blocks(
ctx context.Context,
channel string,
identity msp.SigningIdentity,
blockRange ...int64,
) (blockChan <-chan *common.Block, closer func() error, err error)
}
type ChainInfoGetter ¶ added in v0.10.0
type Chaincode ¶
type Chaincode interface {
// GetPeers returns chaincode peers
GetPeers() []Peer
// Invoke returns invoke builder for presented chaincode function
Invoke(fn string) ChaincodeInvokeBuilder
// Query returns query builder for presented function and arguments
Query(fn string, args ...string) ChaincodeQueryBuilder
// Subscribe returns subscription on chaincode events
Subscribe(ctx context.Context) (EventCCSubscription, error)
}
Chaincode describes common operations with chaincode
type ChaincodeDiscoverer ¶ added in v0.7.0
type ChaincodeDiscoverer interface {
Endorsers() []*HostEndpoint
ChaincodeName() string
ChaincodeVersion() string
ChannelDiscoverer
}
ChaincodeDiscoverer - looking for info about network, channel, chaincode in local configs or gossip
type ChaincodeInvokeBuilder ¶
type ChaincodeInvokeBuilder interface {
// WithIdentity allows invoking chaincode from custom identity
WithIdentity(identity msp.SigningIdentity) ChaincodeInvokeBuilder
// Transient allows passing arguments to transient map
Transient(args TransArgs) ChaincodeInvokeBuilder
// ArgBytes set slice of bytes as argument
ArgBytes([][]byte) ChaincodeInvokeBuilder
// ArgJSON set slice of JSON-marshalled data
ArgJSON(in ...interface{}) ChaincodeInvokeBuilder
// ArgString set slice of strings as arguments
ArgString(args ...string) ChaincodeInvokeBuilder
// Do makes invoke with built arguments
Do(ctx context.Context, opts ...DoOption) (response *peer.Response, txID string, err error)
}
ChaincodeInvokeBuilder describes possibilities how to get invoke results
type ChaincodeInvokeResponse ¶
type ChaincodeQueryBuilder ¶
type ChaincodeQueryBuilder interface {
// WithIdentity allows invoking chaincode from custom identity
WithIdentity(identity msp.SigningIdentity) ChaincodeQueryBuilder
// WithArguments allows querying chaincode with arguments
WithArguments(argBytes [][]byte) ChaincodeQueryBuilder
// Transient allows passing arguments to transient map
Transient(args TransArgs) ChaincodeQueryBuilder
// AsBytes allows getting result of querying chaincode as byte slice
AsBytes(ctx context.Context) ([]byte, error)
// AsJSON allows getting result of querying chaincode to presented structures using JSON-unmarshalling
AsJSON(ctx context.Context, out interface{}) error
// AsProposalResponse allows getting raw peer response
AsProposalResponse(ctx context.Context) (*peer.ProposalResponse, error)
// Do makes query with built arguments
Do(ctx context.Context) (*peer.Response, error)
}
ChaincodeQueryBuilder describe possibilities how to get query results
type ChannelDiscoverer ¶ added in v0.7.0
type ChannelDiscoverer interface {
Orderers() []*HostEndpoint
ChannelName() string
}
ChannelDiscoverer - info about orderers in channel
type ChannelListGetter ¶ added in v0.10.0
type ChannelListGetter interface {
GetChannels(ctx context.Context) (*peer.ChannelQueryResponse, error)
}
type Client ¶ added in v0.10.0
type Client interface {
EventsDeliverer
BlocksDeliverer
Invoker
FabricV2() bool
}
type CurrentIdentity ¶ added in v0.7.4
type CurrentIdentity interface {
// CurrentIdentity identity returns current signing identity used by core
CurrentIdentity() msp.SigningIdentity
}
type DeliverClient ¶
type DeliverClient interface {
// SubscribeCC allows subscribing on chaincode events using name of channel, chaincode and block offset
SubscribeCC(ctx context.Context, channelName string, ccName string, seekOpt ...EventCCSeekOption) (EventCCSubscription, error)
// SubscribeTx allows subscribing on transaction events by id
SubscribeTx(ctx context.Context, channelName string, txID string, seekOpt ...EventCCSeekOption) (TxSubscription, error)
// SubscribeBlock allows subscribing on block events. Always returns new instance of block subscription
SubscribeBlock(ctx context.Context, channelName string, seekOpt ...EventCCSeekOption) (BlockSubscription, error)
}
type DiscoveryProvider ¶
type DiscoveryProvider interface {
Chaincode(ctx context.Context, channelName string, ccName string) (ChaincodeDiscoverer, error)
Channel(ctx context.Context, channelName string) (ChannelDiscoverer, error)
LocalPeers(ctx context.Context) (LocalPeersDiscoverer, error)
}
type DoOption ¶ added in v0.5.0
func WithEndorsingMpsIDs ¶ added in v0.7.0
func WithIdentity ¶ added in v0.7.0
func WithIdentity(identity msp.SigningIdentity) DoOption
type DoOptions ¶ added in v0.5.0
type DoOptions struct {
Identity msp.SigningIdentity
Pool PeerPool
TxWaiter TxWaiter
// necessary only for 'tx waiter all'
EndorsingMspIDs []string
}
type Endorser ¶ added in v0.7.4
type Endorser interface {
// Endorse sends proposal to endorsing peer and returns its result
Endorse(ctx context.Context, proposal *peer.SignedProposal) (*peer.ProposalResponse, error)
}
type EnvelopeParsingError ¶
type EnvelopeParsingError struct {
Err error
}
func (EnvelopeParsingError) Error ¶
func (e EnvelopeParsingError) Error() string
type EventCCSeekOption ¶
type EventCCSeekOption func() (*orderer.SeekPosition, *orderer.SeekPosition)
func SeekOldest ¶
func SeekOldest() EventCCSeekOption
SeekOldest sets offset to channel blocks from beginning
func SeekRange ¶
func SeekRange(start, end uint64) EventCCSeekOption
SeekRange sets offset from one block to another by their numbers
func SeekSingle ¶
func SeekSingle(num uint64) EventCCSeekOption
SeekSingle sets offset from block number
type EventCCSubscription ¶
type EventCCSubscription interface {
// Events initiates internal GRPC stream and returns channel on chaincode events
Events() chan *peer.ChaincodeEvent
EventsExtended() chan interface {
Event() *peer.ChaincodeEvent
Block() uint64
TxTimestamp() *timestamp.Timestamp
}
// Errors returns errors associated with this subscription
Errors() chan error
// Close cancels current subscription
Close() error
}
type EventsDeliverer ¶ added in v0.7.0
type EventsDeliverer interface {
// Events - shortcut for PeerPool().DeliverClient(...).SubscribeCC(...).Events()
// subscribe on chaincode events using name of channel, chaincode and block offset
// if provided 'identity' is 'nil' default one will be set
Events(
ctx context.Context,
channel string,
chaincode string,
identity msp.SigningIdentity,
blockRange ...int64,
) (events chan interface {
Event() *peer.ChaincodeEvent
Block() uint64
TxTimestamp() *timestamp.Timestamp
}, closer func() error, err error)
}
type GRPCStreamError ¶
GRPCStreamError contains original error from GRPC stream
func (GRPCStreamError) Error ¶
func (e GRPCStreamError) Error() string
type HostEndpoint ¶ added in v0.7.0
type InvalidTxError ¶
type InvalidTxError struct {
TxId string
Code peer.TxValidationCode
}
func (InvalidTxError) Error ¶
func (e InvalidTxError) Error() string
type Invoker ¶
type Invoker interface {
Querier
// Invoke - shortcut for invoking chaincodes
// if provided 'identity' is 'nil' default one will be set
// txWaiterType - param which identify transaction waiting policy.
// available: 'self'(wait for one peer of endorser org), 'all'(wait for each organization from endorsement policy)
// default is 'self'(even if you pass empty string)
Invoke(
ctx context.Context,
channel string,
chaincode string,
args [][]byte,
identity msp.SigningIdentity,
transient map[string][]byte,
txWaiterType string,
) (res *peer.Response, chaincodeTx string, err error)
}
type LocalPeersDiscoverer ¶ added in v0.7.0
type LocalPeersDiscoverer interface {
Peers() []*HostEndpoint
}
LocalPeersDiscoverer discover local peers without providing info about channel, chaincode
type MSPPeerPool ¶ added in v0.7.4
type MSPPeerPool interface {
Peers() []Peer
FirstReadyPeer() (Peer, error)
Process(ctx context.Context, proposal *peer.SignedProposal) (*peer.ProposalResponse, error)
DeliverClient(identity msp.SigningIdentity) (DeliverClient, error)
}
type Orderer ¶
type Orderer interface {
// Broadcast sends envelope to orderer and returns it's result
Broadcast(ctx context.Context, envelope *common.Envelope) (*orderer.BroadcastResponse, error)
// Deliver fetches block from orderer by envelope
Deliver(ctx context.Context, envelope *common.Envelope) (*common.Block, error)
// GetConfigBlock returns last config block
GetConfigBlock(ctx context.Context, signer msp.SigningIdentity, channelName string) (*common.Block, error)
}
type ParsedBlocksDeliverer ¶ added in v0.10.6
type ParsedBlocksDeliverer interface {
// ParsedBlocks the same as BlocksDeliverer.Blocks, but returns a channel with parsed blocks
ParsedBlocks(
ctx context.Context,
channel string,
identity msp.SigningIdentity,
blockRange ...int64,
) (parsedBlockChan <-chan *hlfproto.Block, parsedCloser func() error, err error)
}
type Peer ¶
type Peer interface {
Querier
Endorser
ChannelListGetter
ChainInfoGetter
BlocksDeliverer
ParsedBlocksDeliverer
EventsDeliverer
// DeliverClient returns DeliverClient
DeliverClient(identity msp.SigningIdentity) (DeliverClient, error)
// URI returns url used for grpc connection
URI() string
// Conn returns instance of grpc connection
Conn() *grpc.ClientConn
// Close terminates peer connection
Close() error
}
Peer is common interface for endorsing peer
type PeerEndorseError ¶
PeerEndorseError describes peer endorse error TODO currently not working cause peer embeds error in string
func (PeerEndorseError) Error ¶
func (e PeerEndorseError) Error() string
type PeerPool ¶
type PeerPool interface {
GetPeers() map[string][]Peer
GetMSPPeers(mspID string) []Peer
FirstReadyPeer(mspID string) (Peer, error)
Add(mspId string, peer Peer, strategy PeerPoolCheckStrategy) error
EndorseOnMSP(ctx context.Context, mspId string, proposal *peer.SignedProposal) (*peer.ProposalResponse, error)
EndorseOnMSPs(ctx context.Context, endorsingMspIDs []string, proposal *peer.SignedProposal) ([]*peer.ProposalResponse, error)
DeliverClient(mspId string, identity msp.SigningIdentity) (DeliverClient, error)
Close() error
}
type PeerPoolCheckStrategy ¶
type Querier ¶ added in v0.7.4
type Querier interface {
CurrentIdentity
// Query - shortcut for querying chaincodes
// if provided 'identity' is 'nil' default one will be set
Query(
ctx context.Context,
channel string,
chaincode string,
args [][]byte,
identity msp.SigningIdentity,
transient map[string][]byte,
) (*peer.Response, error)
}
type TxSubscription ¶
type TxSubscription interface {
// Result returns result of current tx: success flag, original peer validation code and error if occurred
Result() (peer.TxValidationCode, error)
Close() error
}
TxSubscription describes tx subscription
type TxWaiter ¶ added in v0.5.0
TxWaiter is interface for build your custom function for wait of result of tx after endorsement
type UnknownEventTypeError ¶
type UnknownEventTypeError struct {
Type string
}
func (UnknownEventTypeError) Error ¶
func (e UnknownEventTypeError) Error() string