Skip to content

Commit

Permalink
feat: besu WatchBlocksV1Endpoint with SocketIO
Browse files Browse the repository at this point in the history
Primary change(s):
-----------------

1. Adds an async endpoint based on
the new SocketIO integration of the API server. The endpoint streams new
block headers to the clients as they come in through the subscription
mechanism of Web3.

2. The besu connector plugin is now capable of
accepting the WS RPC API host of the backing Besu client/ledger so that
it can instantiate a WebSocket provider for itself which was a
prerequisite of being able to use the Web3 subscriptions functionality
that the async endponit needs to work.

Secondary change(s):
-------------------

1. Updated the supply chain app example and the besu tests to
accomodate the change that the besu connector now needs to use
the web socket RPC API instead of the HTTP one.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed May 26, 2021
1 parent 51c586a commit d5e1708
Show file tree
Hide file tree
Showing 13 changed files with 708 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,14 @@ export class SupplyChainAppDummyInfrastructure {
{
this._besuAccount = await this.besu.createEthTestAccount(2000000);
const rpcApiHttpHost = await this.besu.getRpcApiHttpHost();
const rpcApiWsHost = await this.besu.getRpcApiWsHost();

const pluginRegistry = new PluginRegistry();
pluginRegistry.add(keychainPlugin);
const connector = new PluginLedgerConnectorBesu({
instanceId: "PluginLedgerConnectorBesu_Contract_Deployment",
rpcApiHttpHost,
rpcApiWsHost,
logLevel: this.options.logLevel,
pluginRegistry,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class SupplyChainApp {

this.log.info(`Configuring Cactus Node for Ledger A...`);
const rpcApiHostA = await this.ledgers.besu.getRpcApiHttpHost();
const rpcApiWsHostA = await this.ledgers.besu.getRpcApiWsHost();
const rpcApiHostB = await this.ledgers.quorum.getRpcApiHttpHost();

const connectionProfile = await this.ledgers.fabric.getConnectionProfileOrg1();
Expand Down Expand Up @@ -187,6 +188,7 @@ export class SupplyChainApp {
const connectorBesu = new PluginLedgerConnectorBesu({
instanceId: "PluginLedgerConnectorBesu_A",
rpcApiHttpHost: rpcApiHostA,
rpcApiWsHost: rpcApiWsHostA,
pluginRegistry: registryA,
logLevel: this.options.logLevel,
});
Expand Down
253 changes: 253 additions & 0 deletions packages/cactus-plugin-ledger-connector-besu/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion packages/cactus-plugin-ledger-connector-besu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@
"joi": "14.3.1",
"openapi-types": "7.0.1",
"prom-client": "13.1.0",
"rxjs": "6.6.7",
"socket.io-client": "4.0.1",
"typescript-optional": "2.0.1",
"web3": "1.2.7",
"web3-utils": "1.2.7"
},
"devDependencies": {
"@hyperledger/cactus-plugin-keychain-memory": "0.5.0",
"@hyperledger/cactus-test-tooling": "0.5.0",
"@types/express": "4.17.8"
"@types/express": "4.17.8",
"socket.io": "4.0.1",
"web3-eth": "1.2.7"
}
}
Loading

0 comments on commit d5e1708

Please sign in to comment.