Skip to content

Commit

Permalink
FAB-11122 NodeSDK remove EventHub
Browse files Browse the repository at this point in the history
Remove from the NodeSDK the old EventHub and
convert test to use the new ChannelEventHub.

Change-Id: I808aa9339fee83d97031ee4124f90c0507b90308
Signed-off-by: Bret Harrison <[email protected]>
  • Loading branch information
harrisob committed Jul 17, 2018
1 parent 0d1c4e1 commit 1cd9109
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 2,221 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ For a high-level design specificiation for Fabric SDKs of all languages, visit [

fabric-client and fabric-ca-client are written in CommonJS modules and take advantage of ECMAScript 2015 class syntax.

* The main top-level class is **Channel**. It is the client's view of a fabric [channel](https://docs.google.com/document/d/1eRNxxQ0P8yp4Wh__Vi6ddaN_vhN2RQHP-IruHNUwyhc/). The SDK allows you to interact with multiple channels. A channel object can be configured with a different ordering service or share a common ordering service, depending on how the target blockchain network is set up. A channel object has a _KeyValueStore_ to store private keys and certificates for authenticated users. Through the channel object the application can perform
* The main top-level class is **Channel**. It is the client's view of a fabric [channel](https://docs.google.com/document/d/1eRNxxQ0P8yp4Wh__Vi6ddaN_vhN2RQHP-IruHNUwyhc/). The SDK allows you to interact with multiple channels. A channel object can be configured with a different ordering service or share a common ordering service, depending on how the target blockchain network is set up. A channel object has a _KeyValueStore_ to store private keys and certificates for authenticated users. Through the channel object the application can perform
* The **KeyValueStore** is a very simple interface which SDK uses to store and retrieve all persistent data. This data includes private keys, so it is very important to keep this storage secure. The default implementation is a simple file-based version found in the _FileKeyValueStore_ class. The SDK also provides an implementation based on CouchDB which can be configured to use a local CouchDB database or a remote deployment including a Cloudant database.
* The **User** class represents an end user who transacts on the channel. The user object must have a valid enrollment configured in order to properly sign transaction requests. The enrollment materials can either be obtained from enrolling with fabric-ca or an external Certificate Authority.
* The **EventHub** class encapsulates the interaction with the network peers' event streams.
* The **ChannelEventHub** class encapsulates the interaction with the network peers' event streams.
* The **FabricCAClientImpl** class provides security and identity related features such as user registration and enrollment, transaction certificate issuance. The Hyperledger Fabric has a built-in implementation that issues _ECerts_ (enrollment certificates) and _TCerts_ (transaction certificates). ECerts are for enrollment identity and TCerts are for transactions.

### Pluggability
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ The SDK's list of features include:
* [transaction-by-id]{@link Channel#queryTransaction}
* [channel configuration data]{@link Channel#getChannelConfig}
* monitoring events:
* [connect to a peer's event stream]{@link EventHub#connect}
* listen on [block events]{@link EventHub#registerBlockEvent}
* listen on [transactions events]{@link EventHub#registerTxEvent} and find out if the transaction was successfully committed to the ledger or marked invalid
* listen on [custom events]{@link EventHub#registerChaincodeEvent} produced by chaincodes
* [connect to a peer's event stream]{@link ChannelEventHub#connect}
* listen on [block events]{@link ChannelEventHub#registerBlockEvent}
* listen on [transactions events]{@link ChannelEventHub#registerTxEvent} and find out if the transaction was successfully committed to the ledger or marked invalid
* listen on [custom events]{@link ChannelEventHub#registerChaincodeEvent} produced by chaincodes
* serializable [User]{@link User} object with signing capabilities
* [hierarchical configuration]{@link Client.getConfigSetting} settings with multiple layers of overrides: files, environment variable, program arguments, in-memory settings
* [logging utility]{@link Client.setLogger} with a built-in logger (winston) and can be overriden with a number of popular loggers including log4js and bunyan
Expand Down
58 changes: 1 addition & 57 deletions fabric-client/lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const User = require('./User.js');
const Channel = require('./Channel.js');
const Packager = require('./Packager.js');
const Peer = require('./Peer.js');
const EventHub = require('./EventHub.js');
const ChannelEventHub = require('./ChannelEventHub');
const Orderer = require('./Orderer.js');
const TransactionID = require('./TransactionID.js');
Expand Down Expand Up @@ -382,60 +381,6 @@ const Client = class extends BaseClient {
return orderer;
}

/**
* Returns an {@link EventHub} object. An event hub object encapsulates the
* properties of an event stream on a peer node, through which the peer publishes
* notifications of blocks being committed in the channel's ledger.
*
* @returns {EventHub} The EventHub instance
*/
newEventHub() {
return new EventHub(this);
}

/**
* Returns an {@link EventHub} object based on the event hub address
* as defined in the currently loaded network configuration for the
* peer by the name parameter. The named peer must have the "eventUrl"
* setting or a null will be returned.
*
* @param {string} peer_name - The name of the peer that has an event hub defined
* @returns {EventHub} The EventHub instance that has had the event hub address assigned
*/
getEventHub(peer_name) {
if (this._network_config) {
return this._network_config.getEventHub(peer_name);
} else {
return null;
}
}

/**
* Returns a list of {@link EventHub} for an organization as defined
* in the currently loaded network configuration. If no organization mspid is
* provided then the organization referenced in the currently active network
* configuration's client section will be used. The list will be based on
* the peers in the organization that have the "eventUrl" setting.
*
* @param {string} mspid - Optional - The mspid of an organization
* @returns {EventHub[]} An array of EventHub instances that are defined for this organization
*/
getEventHubsForOrg(mspid) {
let event_hubs = [];
let _mspid = mspid;
if (!mspid) {
_mspid = this._mspid;
}
if (_mspid && this._network_config) {
const organization = this._network_config.getOrganizationByMspId(_mspid);
if (organization) {
event_hubs = organization.getEventHubs();
}
}

return event_hubs;
}

/*
* Private utility method to get target peers. The peers will be in the organization of this client,
* (meaning the peer has the same mspid). If this client is not assigned a mspid, then all
Expand Down Expand Up @@ -723,7 +668,7 @@ const Client = class extends BaseClient {
* @returns {Promise} Promise for a result object with status on the acceptance of the update request
* by the orderer. A channel update is finally completed when the new channel configuration
* block created by the orderer has been committed to the channel's peers. To be notified
* of the successful update of the channel, an application should use the {@link EventHub}
* of the successful update of the channel, an application should use the {@link ChannelEventHub}
* to connect to the peers and register a block listener.
*/
updateChannel(request) {
Expand Down Expand Up @@ -1812,7 +1757,6 @@ function _getNetworkConfig(config, client) {

module.exports = Client;
module.exports.Peer = Peer;
module.exports.EventHub = EventHub;
module.exports.ChannelEventHub = ChannelEventHub;
module.exports.Orderer = Orderer;
module.exports.Channel = Channel;
Expand Down
Loading

0 comments on commit 1cd9109

Please sign in to comment.