Hyperledger Fabric 2.0 gRPC Interface

Based Fabric v2.0.1with v1.xdifferent version, v2version of the protosdefinitions in a separate warehouse fabric-protos management, and use of protocspecific language code means it is also used to generate a separate warehouse storage, such as a golangversion of fabric-protos-Go .

一、 Orderer

1. AtomicBroadcast

Service definition to orderer / ab.proto

service AtomicBroadcast {
    // broadcast receives a reply of Acknowledgement for each common.Envelope in order, indicating success or type of failure
    rpc Broadcast(stream common.Envelope) returns (stream BroadcastResponse);

    // deliver first requires an Envelope of type DELIVER_SEEK_INFO with Payload data as a mashaled SeekInfo message, then a stream of block replies is received.
    rpc Deliver(stream common.Envelope) returns (stream DeliverResponse);
}

1.1 Broadcast

BroadcastAn interface for receiving messages to be sorted, including ordinary transaction txmessage and a channelconfiguration message.
The client transaction message is submitted to endorsing peersa pre-execution chaincodeand endorsement read result set, return the results to the client to Ordererbe sorted.

1.2 Deliver

DeliverThe interface is used peershave been sorted distribution blockdata peernode join channelfrom the Orderersorted acquired block.

2. Cluster

Service definition to orderer / cluster.proto

// Cluster defines communication between cluster members.
service Cluster {
    // Step passes an implementation-specific message to another cluster member.
    rpc Step(stream StepRequest) returns (stream StepResponse);
}

Fabric v1.1 supports the following EtcdRaftconsensus algorithm, and using Kafkaconsensus algorithms of various orderercenters of independent connection kafkacluster different, using the EtcdRaftconsensus algorithm each ordererconsisting of a cluster, Stepfor the exchange of messages between cluster nodes.

Two, Peer

1. Endorser

Service definition to peer / peer.proto

service Endorser {
    rpc ProcessProposal(SignedProposal) returns (ProposalResponse);
}

ProcessProposalTransaction message interface for the client to submit the signed endorsing peerspre-set to perform read and write and endorsement. It refers to the so-called pre-execution performed using current local state books chaincodegenerated set of read and write, but the execution result is not written books.

2. Deliver

Service definition to peer / events.proto

service Deliver {
    // Deliver first requires an Envelope of type ab.DELIVER_SEEK_INFO with
    // Payload data as a marshaled orderer.SeekInfo message,
    // then a stream of block replies is received
    rpc Deliver (stream common.Envelope) returns (stream DeliverResponse) {
    }
    // DeliverFiltered first requires an Envelope of type ab.DELIVER_SEEK_INFO with
    // Payload data as a marshaled orderer.SeekInfo message,
    // then a stream of **filtered** block replies is received
    rpc DeliverFiltered (stream common.Envelope) returns (stream DeliverResponse) {
    }
    // DeliverWithPrivateData first requires an Envelope of type ab.DELIVER_SEEK_INFO with
    // Payload data as a marshaled orderer.SeekInfo message,
    // then a stream of block and private data replies is received
    rpc DeliverWithPrivateData (stream common.Envelope) returns (stream DeliverResponse) {
    }
}

2.1 Deliver & DeliverFiltered

DeliverThe client interface is used to distribute the books have been written to the local blockdata. The client will endorsing peersreturn the results submitted to the ordererpost, waiting for peerthe notification transaction is completed.

2.2 DeliverWithPrivateData

DeliverWithPrivateDatav2.0 version of the new, private data with the distribution of blockdata

Three, Chaincode

1. ChaincodeSupport

Service definition to peer / chaincode_shim.proto

// Interface that provides support to chaincode execution. ChaincodeContext
// provides the context necessary for the server to respond appropriately.
service ChaincodeSupport {
    rpc Register(stream ChaincodeMessage) returns (stream ChaincodeMessage);
}

RegisterFor Chaincodewhen you start to peerRegisterChaincode

2. Chaincode

Service definition to peer / chaincode_shim.proto

// Chaincode as a server - peer establishes a connection to the chaincode as a client
// Currently only supports a stream connection.
service Chaincode {
    rpc Connect(stream ChaincodeMessage) returns (stream ChaincodeMessage);
}

v2New service, Chaincodestart and end as a service by peervia Connectthe connection interfaceChaincode

Four, Gossip

Service definition to gossip / message.proto

// Gossip
service Gossip {

    // GossipStream is the gRPC stream used for sending and receiving messages
    rpc GossipStream (stream Envelope) returns (stream Envelope);

    // Ping is used to probe a remote peer's aliveness
    rpc Ping (Empty) returns (Empty);
}

To alleviate Ordererthe pressure, the organization only a few peerconnections ordererfor the latest block, within each organization peerthrough Gossipthe Internet, through the Gossipexchange of blockdata and private data.

五、Discovery

Service definition in discovery / protocol.proto

// Discovery defines a service that serves information about the fabric network
// like which peers, orderers, chaincodes, etc.
service Discovery {
    // Discover receives a signed request, and returns a response.
    rpc Discover (SignedRequest) returns (Response);
}

DiscoveryConvenient service for clients to obtain the overall Fabriccondition of the network, only need to know a query to the initial node can be channelin the peers, config, membership, chaincodeand so on.

reference:

Released three original articles · won praise 0 · Views 70

Guess you like

Origin blog.csdn.net/DAOSHUXINDAN/article/details/104668870