Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fabric-connector): add getChainInfo, improve getBlock output #3298

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { json2str } from "@hyperledger/cactus-cmd-socketio-server";
import { AssetTradeStatus } from "./define";
import {
WatchBlocksCactusTransactionsEventV1 as FabricWatchBlocksCactusTransactionsEventV1,
CactiBlockTransactionEventV1,
WatchBlocksListenerTypeV1 as FabricWatchBlocksListenerTypeV1,
WatchBlocksResponseV1 as FabricWatchBlocksResponseV1,
} from "@hyperledger/cactus-plugin-ledger-connector-fabric";
Expand Down Expand Up @@ -242,19 +242,19 @@ export class BusinessLogicAssetTrade extends BusinessLogicBase {
const fabricApiClient = getFabricApiClient();
const watchObservable = fabricApiClient.watchBlocksDelegatedSignV1({
channelName: config.assetTradeInfo.fabric.channelName,
type: FabricWatchBlocksListenerTypeV1.CactusTransactions,
type: FabricWatchBlocksListenerTypeV1.CactiTransactions,
signerCertificate: getSignerIdentity().credentials.certificate,
signerMspID: getSignerIdentity().mspId,
uniqueTransactionData: createSigningToken("watchBlock"),
});
const watchSub = watchObservable.subscribe({
next: (event: FabricWatchBlocksResponseV1) => {
if (!("cactusTransactionsEvents" in event)) {
if (!("cactiTransactionsEvents" in event)) {
logger.error("Wrong input block format!", event);
return;
}

for (const ev of event.cactusTransactionsEvents) {
for (const ev of event.cactiTransactionsEvents) {
logger.debug(`##in onEventFabric()`);

try {
Expand Down Expand Up @@ -363,7 +363,7 @@ export class BusinessLogicAssetTrade extends BusinessLogicBase {
}

executeNextTransaction(
txInfo: FabricWatchBlocksCactusTransactionsEventV1 | Web3TransactionReceipt,
txInfo: CactiBlockTransactionEventV1 | Web3TransactionReceipt,
txId: string,
): void {
let transactionInfo: TransactionInfo | null = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Configuration,
FabricContractInvocationType,
RunTransactionRequest,
GetBlockResponseTypeV1,
} from "@hyperledger/cactus-plugin-ledger-connector-fabric";
import { NetworkDetails, ObtainLedgerStrategy } from "./obtain-ledger-strategy";
import {
Expand Down Expand Up @@ -170,7 +171,7 @@ export class StrategyFabric implements ObtainLedgerStrategy {
query: {
transactionId: txId,
},
skipDecode: false,
type: GetBlockResponseTypeV1.Full,
};

const getBlockResponse = await api.getBlockV1(getBlockReq);
Expand Down
11 changes: 6 additions & 5 deletions packages/cactus-plugin-ledger-connector-fabric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ Corresponds directly to `BlockType` from `fabric-common`:
- `WatchBlocksListenerTypeV1.Full`,
- `WatchBlocksListenerTypeV1.Private`,

##### Cacti (custom)
Parses the data and returns custom formatted block.
- `WatchBlocksListenerTypeV1.CactiTransactions`: Returns transactions summary. Compatible with legacy `fabric-socketio` monitoring operation.
- `WatchBlocksListenerTypeV1.CactiFullBlock`: Returns full block summary.

### 1.6 Delegated Signature
- Custom signature callback can be used when increased security is needed or currently available options are not sufficient.
- Signature callback is used whenever fabric request must be signed.
Expand Down Expand Up @@ -365,17 +370,13 @@ await apiClient.runDelegatedSignTransactionV1({

// Monitor for transactions:
apiClient.watchBlocksDelegatedSignV1({
type: WatchBlocksListenerTypeV1.CactusTransactions,
type: WatchBlocksListenerTypeV1.CactiTransactions,
signerCertificate: adminIdentity.credentials.certificate,
signerMspID: adminIdentity.mspId,
channelName: ledgerChannelName,
})
```

##### Cactus (custom)
Parses the data and returns custom formatted block.
- `WatchBlocksListenerTypeV1.CactusTransactions`: Returns transactions summary. Compatible with legacy `fabric-socketio` monitoring operation.

## 2. Architecture
The sequence diagrams for various endpoints are mentioned below

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"form-data": "4.0.0",
"http-status-codes": "2.1.4",
"jsrsasign": "11.0.0",
"long": "5.2.3",
"multer": "1.4.5-lts.1",
"ngo": "2.7.0",
"node-ssh": "13.1.0",
Expand Down
Loading
Loading