Documentation ¶
Index ¶
- Constants
- func CalBlockHash(block *common.Block) ([]byte, error)
- func CalConnIdentifier(connProfile *ConnectionProfile, participant *Participant, useDiscovery bool) string
- func CreateChannel(conn *NetworkConnection, txContent []byte, orderer string) (string, error)
- func CreateSigningIdentity(sdk *fabsdk.FabricSDK, participant *Participant) (msp.SigningIdentity, error)
- func ExecuteChaincode(conn *NetworkConnection, channelID string, chaincodeID string, ...) (*channel.Response, error)
- func GetJoinedChannels(conn *NetworkConnection, endpointURL string, options ...DiscoverOptionFunc) ([]*peer.ChannelInfo, error)
- func InstallChaincode(conn *NetworkConnection, cc *Chaincode, targets []string) (map[string]ExecutionResult, error)
- func InstantiateChaincode(conn *NetworkConnection, cc *Chaincode, target string, orderer string) (fab.TransactionID, error)
- func JoinChannel(conn *NetworkConnection, channelID string, targets []string, orderer string) error
- func MonitorBlockEvent(conn *NetworkConnection, channelID string, ...) error
- func NewJavaCCPackage(chaincodeRealPath string) (*resource.CCPackage, error)
- func NewNodeCCPackage(chaincodeRealPath string) (*resource.CCPackage, error)
- func TLSAllCertsByBytes(certBytes [][]byte) ([]*x509.Certificate, error)
- func TLSCertByBytes(bytes []byte) (*x509.Certificate, error)
- func UpgradeChaincode(conn *NetworkConnection, cc *Chaincode, target string, orderer string) (fab.TransactionID, error)
- type Action
- type Block
- func QueryBlock(conn *NetworkConnection, channelID string, targets []string, begin uint64, ...) ([]*Block, error)
- func QueryBlockByHash(conn *NetworkConnection, channelID string, targets []string, blockHash string) (*Block, error)
- func QueryBlockByTxID(conn *NetworkConnection, channelID string, targets []string, txID string) (*Block, error)
- type Chaincode
- type ChaincodeData
- type ChaincodeOperType
- type Channel
- type ChannelConfigCongnRes
- type ChannelPeerCongnRes
- type ConnectionProfile
- type Descriptor
- type DiscoverOption
- type DiscoverOptionFunc
- type Endorser
- type ExecutionResult
- type HashReadWriteCol
- type KVRead
- type KVWrite
- type Ledger
- type NSReadWriteSet
- type NetworkConnection
- func (conn *NetworkConnection) Close()
- func (conn *NetworkConnection) ConfiguredChannels() map[string]fab.ChannelEndpointConfig
- func (conn *NetworkConnection) ConfiguredOrderers() map[string]fab.OrdererConfig
- func (conn *NetworkConnection) ConfiguredOrganizations() map[string]fab.OrganizationConfig
- func (conn *NetworkConnection) ConfiguredPeers() map[string]fab.PeerConfig
- func (conn *NetworkConnection) Show() string
- type NetworkOverview
- type Orderer
- type OrdererConfigCognRes
- type Organization
- type Participant
- type Peer
- type PeerStatus
- type ProposalResponse
- type ResultCode
- type TXReadWriteSet
- type Transaction
Constants ¶
const ( ChaincodeType_GOLANG = "golang" ChaincodeType_NODE = "node" ChaincodeType_JAVA = "java" )
const DiscoverTimeOut = 30 * time.Second
DiscoverTimeOut timeout for discovery
const (
// LSCC code of lifecycle chaincode
LSCC = "lscc"
)
Variables ¶
This section is empty.
Functions ¶
func CalBlockHash ¶
CalBlockHash to calculate block hash
func CalConnIdentifier ¶
func CalConnIdentifier(connProfile *ConnectionProfile, participant *Participant, useDiscovery bool) string
CalConnIdentifier to calculate the identifier for the connection. Calculated by parameters.
func CreateChannel ¶
func CreateChannel(conn *NetworkConnection, txContent []byte, orderer string) (string, error)
CreateChannel to create a channel
func CreateSigningIdentity ¶
func CreateSigningIdentity(sdk *fabsdk.FabricSDK, participant *Participant) (msp.SigningIdentity, error)
CreateSigningIdentity To create identity by orgname, cert and key.
func ExecuteChaincode ¶
func ExecuteChaincode(conn *NetworkConnection, channelID string, chaincodeID string, operType ChaincodeOperType, targets []string, funcName string, args []string, options ...channel.RequestOption) (*channel.Response, error)
ExecuteChaincode to invoke a chaincode TODO to determine the targets
func GetJoinedChannels ¶
func GetJoinedChannels(conn *NetworkConnection, endpointURL string, options ...DiscoverOptionFunc) ([]*peer.ChannelInfo, error)
GetJoinedChannels to get all joined channels of an endpoint.
func InstallChaincode ¶
func InstallChaincode(conn *NetworkConnection, cc *Chaincode, targets []string) (map[string]ExecutionResult, error)
InstallChaincode to handle the detailed corresponding message, and multiple peers - some failed issue, the installation will be executed for multiple times. TODO to use resmgmt.InstallCC
func InstantiateChaincode ¶
func InstantiateChaincode(conn *NetworkConnection, cc *Chaincode, target string, orderer string) (fab.TransactionID, error)
InstantiateChaincode to instantiate chaincode.
func JoinChannel ¶
func JoinChannel(conn *NetworkConnection, channelID string, targets []string, orderer string) error
JoinChannel to join a peer into channel
func MonitorBlockEvent ¶
func MonitorBlockEvent(conn *NetworkConnection, channelID string, eventChan chan<- *fab.FilteredBlockEvent, closeChan <-chan int, eventCloseChan chan<- int) error
MonitorBlockEvent to monitor block event
func NewJavaCCPackage ¶
NewNodeCCPackage creates new go lang chaincode package
func NewNodeCCPackage ¶
NewNodeCCPackage creates new go lang chaincode package
func TLSAllCertsByBytes ¶
func TLSAllCertsByBytes(certBytes [][]byte) ([]*x509.Certificate, error)
TLSAllCertsByBytes to make cert from bytes.
func TLSCertByBytes ¶
func TLSCertByBytes(bytes []byte) (*x509.Certificate, error)
TLSCertByBytes to make cert from bytes.
func UpgradeChaincode ¶
func UpgradeChaincode(conn *NetworkConnection, cc *Chaincode, target string, orderer string) (fab.TransactionID, error)
UpgradeChaincode to upgrade chaincode.
Types ¶
type Action ¶
type Action struct { ChaincodeName string `json:"chaincodeName"` ChaincodeVersion string `json:"chaincodeVersion"` Arguments []string `json:"arguments"` Endorsers []*Endorser `json:"endorsers"` ProposalResponse *ProposalResponse `json:"proposalResponse"` }
Action action of a transaction
type Block ¶
type Block struct { Number uint64 `json:"number"` DataHash string `json:"dataHash"` PreviousHash string `json:"previousHash"` BlockHash string `json:"blockHash"` Transactions []*Transaction `json:"transactions"` Time int64 `json:"time"` }
Block block of a ledger
func QueryBlock ¶
func QueryBlock(conn *NetworkConnection, channelID string, targets []string, begin uint64, len uint64) ([]*Block, error)
QueryBlock to query blocks of the given numbers. TODO the targets can be empty
func QueryBlockByHash ¶
func QueryBlockByHash(conn *NetworkConnection, channelID string, targets []string, blockHash string) (*Block, error)
QueryBlockByHash to query blocks of the given hash.
func QueryBlockByTxID ¶
func QueryBlockByTxID(conn *NetworkConnection, channelID string, targets []string, txID string) (*Block, error)
QueryBlockByTxID to query blocks of the given tx id.
type Chaincode ¶
type Chaincode struct { // For installation and instantiation Name string `json:"name"` Version string `json:"version"` Path string `json:"path"` // for go, it is package // For installtion only BasePath string `json:"basePath"` // for go, it is go path. <BasePath>/src/<Path> will be the go chaincode real path. Type string `json:"type"` // see pb.ChaincodeSpec_Type Package []byte `json:"package"` // For instantiation only ChannelID string `json:"channelID"` // instantiated in channnel Policy string `json:"policy"` // Endorsement policy Constructor []string `json:"constructor"` // Arguments for instantiation // For status. The chaincode might be instantiated (on channel) by not installed (on peer). Installed bool `json:"installed"` // It might be false while channelID is not empty, since it is instantiated in channel but not installed in current peer. }
Chaincode chaincode
func QueryInstalledChaincodes ¶
func QueryInstalledChaincodes(conn *NetworkConnection, endpointURL string, options ...DiscoverOptionFunc) ([]*Chaincode, error)
QueryInstalledChaincodes to get all installed chaincodes
func QueryInstantiatedChaincodes ¶
func QueryInstantiatedChaincodes(conn *NetworkConnection, channelID string) ([]*Chaincode, error)
QueryInstantiatedChaincodes to get all instantiated chaincodes per channel.
type ChaincodeData ¶
type ChaincodeData struct { Name string `json:"name"` Version string `json:"version"` Principals []string `json:"principals"` Rule string `json:"rule"` }
ChaincodeData a simplied chaincode data from lscc
type ChaincodeOperType ¶
type ChaincodeOperType int
ChaincodeOperType chaincode operation type of
const ( // ChaincodeOperTypeExecute execute a chaincode ChaincodeOperTypeExecute ChaincodeOperType = iota // ChaincodeOperTypeQuery query a chaincode ChaincodeOperTypeQuery )
type Channel ¶
type Channel struct { ChannelID string `json:"channelID"` Peers util.Set `json:"peers"` AnchorPeers util.Set `json:"anchorPeers"` Orderers util.Set `json:"orderers"` Policies *fab.ChannelPolicies `json:"policies"` }
Channel channel
type ChannelConfigCongnRes ¶
type ChannelConfigCongnRes struct {
ChannelConfigs map[string]*fab.ChannelEndpointConfig
}
ChannelConfigCongnRes implementation of option config, ordererConfig interface. See fabric-sdk/go/pkg/fab/opts.go
func (*ChannelConfigCongnRes) ChannelConfig ¶
func (cccr *ChannelConfigCongnRes) ChannelConfig(channelID string) *fab.ChannelEndpointConfig
ChannelConfig to find config of chanel.
type ChannelPeerCongnRes ¶
type ChannelPeerCongnRes struct {
ChannelPeersList map[string][]fab.ChannelPeer
}
ChannelPeerCongnRes option config interface, See fabric-sdk/go/pkg/fab/opts.go
func (*ChannelPeerCongnRes) ChannelPeers ¶
func (cpcr *ChannelPeerCongnRes) ChannelPeers(channelID string) []fab.ChannelPeer
ChannelPeers to find peers of channel.
type ConnectionProfile ¶
ConnectionProfile basic connection profile.
type Descriptor ¶
type Descriptor struct {
// contains filtered or unexported fields
}
Descriptor ...
type DiscoverOption ¶
type DiscoverOption struct { // List of endpoint urls, only discover/monitor these peers. Targets []string `json:"discoverPeers"` IsDetail bool `json:"isDetail"` }
DiscoverOption to collect all options in discovery
type DiscoverOptionFunc ¶
type DiscoverOptionFunc func(opt *DiscoverOption) error
DiscoverOptionFunc to handle the discovery option
func WithIsDetail ¶
func WithIsDetail(isDetail bool) DiscoverOptionFunc
WithIsDetail only retrieve details of the peer.
func WithTargets ¶
func WithTargets(targets ...string) DiscoverOptionFunc
WithTargets only retrieve details of the peer.
type Endorser ¶
type Endorser struct { CommonName string `json:"commonName"` Subject string `json:"subject"` IsCA bool `json:"isCA"` MSPID string `json:"MSPID"` Sign string `json:"sign"` Issuer string `json:"issuer"` }
Endorser who endorses the transaction action
type ExecutionResult ¶
type ExecutionResult struct { Code ResultCode `json:"code"` Message string `json:"message"` Result interface{} `json:"result"` }
ExecutionResult execution result
type HashReadWriteCol ¶
type HashReadWriteCol struct { CollectionName string `json:"collectionName"` KVReadSet []*KVRead `json:"kvReadSet"` KVWriteSet []*KVWrite `json:"kvWriteSet"` }
HashReadWriteCol for hashed rw set.
type KVRead ¶
type KVRead struct { Key string `json:"key"` VerBlockNum uint64 `json:"verBlockNum"` VerTxNum uint64 `json:"verTxNum"` }
KVRead key value pair.
type KVWrite ¶
type KVWrite struct { Key string `json:"key"` IsDelete bool `json:"isDelete"` Value interface{} `json:"value"` }
KVWrite key value pair.
type Ledger ¶
type Ledger struct { Height uint64 `json:"height"` CurrentBlockHash string `json:"currentBlockHash"` Endorser string `json:"endorser"` Status int32 `json:"status"` }
Ledger ledger
func QueryLedger ¶
func QueryLedger(conn *NetworkConnection, channelID string, targets []string) (*Ledger, error)
QueryLedger to query a ledger from an endpoint. TODO the targets can be empty
type NSReadWriteSet ¶
type NSReadWriteSet struct { NameSpace string `json:"nameSpace"` KVReadSet []*KVRead `json:"kvReadSet"` KVWriteSet []*KVWrite `json:"kvWriteSet"` HashReadWriteCols []*HashReadWriteCol `json:"hashReadWriteCols"` }
NSReadWriteSet namespace rw set.
type NetworkConnection ¶
type NetworkConnection struct { // Materials to initialize the connection *ConnectionProfile *Participant UseDiscovery bool // To identify the connection from others. Normally be hash of connection profile, participant and useDiscovery. Identifier string UpdateTime time.Time ActiveTime time.Time // Some intermediate/context based on the sdk. SDK *fabsdk.FabricSDK Client context.Client ClientProvider context.ClientProvider // Conifguration and discovered result, they are only for indication or presentation, not for the network directly. Channels map[string]*Channel Organizations map[string]*Organization Peers map[string]*Peer Orderers map[string]*Orderer EndpointStatuses map[string]util.EndPointStatus ChannelLedgers map[string]*Ledger ChannelChaincodes map[string][]*Chaincode ChannelOrderers map[string][]*Orderer ChannelAnchorPeers map[string][]string }
NetworkConnection the entry to the Fabric network. TODO to have lock for update, and a safe disconnection when update/close.
func NewConnection ¶
func NewConnection(connProfile *ConnectionProfile, participant *Participant, useDiscovery bool) (*NetworkConnection, error)
NewConnection to create a new connection to the Fabric network. TODO To add a new paraemter for CognitiveUpdate automatically.
func (*NetworkConnection) Close ¶
func (conn *NetworkConnection) Close()
Close to close the underlying connection. TODO if use session, it should not be closed.
func (*NetworkConnection) ConfiguredChannels ¶
func (conn *NetworkConnection) ConfiguredChannels() map[string]fab.ChannelEndpointConfig
ConfiguredChannels return the configured channels of the network.
func (*NetworkConnection) ConfiguredOrderers ¶
func (conn *NetworkConnection) ConfiguredOrderers() map[string]fab.OrdererConfig
ConfiguredOrderers return the configured orderers of the network.
func (*NetworkConnection) ConfiguredOrganizations ¶
func (conn *NetworkConnection) ConfiguredOrganizations() map[string]fab.OrganizationConfig
ConfiguredOrganizations return the configured organizations of the network.
func (*NetworkConnection) ConfiguredPeers ¶
func (conn *NetworkConnection) ConfiguredPeers() map[string]fab.PeerConfig
ConfiguredPeers return the configured peers of the network.
type NetworkOverview ¶
type NetworkOverview struct { Peers []*Peer `json:"peers"` Channels []*Channel `json:"channels"` EndpointStatuses map[string]util.EndPointStatus `json:"endpointStatuses"` ChannelOrderers map[string][]*Orderer `json:"channelOrderers"` ChannelLedgers map[string]*Ledger `json:"channelLedgers"` ChannelChainCodes map[string][]*Chaincode `json:"channelChaincodes"` ChannelAnchorPeers map[string][]string `json:"channelAnchorPeers"` }
NetworkOverview for whole network
func DiscoverNetworkOverview ¶
func DiscoverNetworkOverview(conn *NetworkConnection, options ...DiscoverOptionFunc) (*NetworkOverview, error)
DiscoverNetworkOverview To get all peers by discover. TODO for now, only 1 endpoint config is well supported. Fault tolerant.
type Orderer ¶
type Orderer struct { Name string `json:"name"` URL string `json:"URL"` // from OrdererConfig GRPCOptions map[string]interface{} `json:"TLSCACert"` // from OrdererConfig TLSCACert *x509.Certificate `json:"GRPCOptions"` // from OrdererConfig Channels util.Set `json:"channels"` }
Orderer common orderer instance
type OrdererConfigCognRes ¶
type OrdererConfigCognRes struct {
OrdererConfigs map[string]*fab.OrdererConfig
}
OrdererConfigCognRes option config interface, See fabric-sdk-go/pkg/fab/opts.go
func (*OrdererConfigCognRes) OrdererConfig ¶
func (occr *OrdererConfigCognRes) OrdererConfig(nameOrURL string) (*fab.OrdererConfig, bool)
OrdererConfig overrides EndpointConfig's OrdererConfig function which returns the ordererConfig instance for the name/URL arg
type Organization ¶
type Organization struct { Name string `json:"name"` MSPID string `json:"MSPID"` CryptoPath string `json:"cryptoPath"` Peers util.Set `json:"peers"` }
Organization org
type Participant ¶
type Peer ¶
type Peer struct { Name string `json:"name"` OrgName string `json:"orgName"` MSPID string `json:"MSPID"` URL string `json:"URL"` // from PeerConfig TLSCACert *x509.Certificate `json:"TLSCACert"` // from PeerConfig GRPCOptions map[string]interface{} `json:"GRPCOptions"` // from PeerConfig Channels util.Set `json:"channels"` PeerChannelConfigs map[string]*fab.PeerChannelConfig `json:"peerChannelConfigs"` // map[channelID] IsConfigured bool `json:"isConfigured"` UpdateTime int64 `json:"updateTime"` }
Peer common peer instance
type PeerStatus ¶
type PeerStatus struct { Ping bool `json:"ping"` GRPC bool `json:"GRPC"` Valid bool `json:"valid"` }
PeerStatus peer status, corresponding to EndpointStatus
type ProposalResponse ¶
type ProposalResponse struct { Chaincode *Chaincode `json:"chaincode"` Response interface{} `json:"response"` TXReadWriteSet *TXReadWriteSet `json:"txReadWriteSet"` }
ProposalResponse proposal response.
type ResultCode ¶
type ResultCode uint32
ResultCode uint32
const ( // ResultSuccess success ResultSuccess ResultCode = 0 // ResultFailure failure ResultFailure ResultCode = 1 )
type TXReadWriteSet ¶
type TXReadWriteSet struct { DataModel string `json:"dataModel"` NSReadWriteSets []*NSReadWriteSet `json:"nsReadWriteSets"` }
TXReadWriteSet transaction rw set.
type Transaction ¶
type Transaction struct {
Actions []*Action `json:"actions"`
}
Transaction transaction of a block