Commit 99279831 authored by Javier Diaz's avatar Javier Diaz
Browse files

Code Cleanup

parent d2c60740
Loading
Loading
Loading
Loading
+2 −45
Original line number Diff line number Diff line
# ADRENALINE DLT App

<figure>
    <img src="./resources/System.png"
         alt="DLT Gateway for chaincode interaction"
         width="960"
         height="480">
    <figcaption>DLT_APP for chaincode tests.</figcaption>
</figure>
# DLT Gateway

## Description

The DLT app consists of a **fabricConnect.ts** TypeScript file, which contains the logic for identification management (certificates required for the MSP), connection management to the blockchain, and finally, it exposes a contract object with all the required information for interacting with the chaincode. The **fabricConnect.ts** is coded following the Fabric Gateway API recommendations from Hyperledger Fabric 2.4+. The compiled **fabricConnect.ts** logic is imported into a **dltGateway.js** file, which contains the gRPC logic for interaction with the TFS controller. Testing code for various performance tests is included inside the [/dltApp/tests](./dltApp/tests/) folder.
The DLT Gateway consists of a **fabricConnect.ts** TypeScript file, which contains the logic for identification management (certificates required for the MSP), connection management to the blockchain, and finally, it exposes a contract object with all the required information for interacting with the chaincode. The **fabricConnect.ts** is coded following the Fabric Gateway API recommendations from Hyperledger Fabric 2.4+. The compiled **fabricConnect.ts** logic is imported into a **dltGateway.js** file, which contains the gRPC logic for interaction with the TFS controller. Testing code for various performance tests is included inside the [/tests](./tests/) folder.

The chaincode is written in Go, providing a reference for the operations that are recorded in the blockchain. This chaincode must already be deployed in a working Hyperledger Fabric blockchain.

@@ -20,38 +12,3 @@ The chaincode is written in Go, providing a reference for the operations that ar
* Docker
* K8s
## Building the App

Install the dependencies and compile the source code.

```bash
npm install
```

## Packing the App

The [automation](./automation/) folder contains the Dockerfiles and Kubernetes configuration files alongside deployment scripts.

### Build a Docker Image

Using the Dockerfile, create a Docker image of the Gateway.

```bash
docker build -t your-username/dltgateway:v1.0.0 .
```

If necessary, upload the Docker image to a Docker repository for convenience. (You can work with the local image if deploying the Kubernetes service on the same machine.)

```bash
docker push your-username/dltgateway:v1.0.0
```

### Run the Deployment Script

Make the necessary changes to the environment variables inside the **configmap.yaml** according to the specific Fabric deployment. Also, update the path in the **persistent-volume.yaml** with the correct information.

```bash
./deploy_dlt_gateway.sh
```

Once the Kubernetes service is deployed, TFS can perform gRPC requests to as usual.
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
{
    "name": "adrenalineDLT_APP",
    "name": "dlt_gateway",
    "version": "1.0.0",
    "lockfileVersion": 3,
    "requires": true,
    "packages": {
        "": {
            "name": "adrenalineDLT_APP",
            "name": "dlt_gateway",
            "version": "1.0.0",
            "license": "Apache-2.0",
            "dependencies": {
+3 −3
Original line number Diff line number Diff line
{
    "name": "adrenalineDLT_APP",
    "name": "dlt_gateway",
    "version": "1.0.0",
    "description": "A DLT application that record and manages topology data as JSON implemented in typeScript using fabric-gateway",
    "description": "A DLT application that record and manages network related data as JSON, implemented in typeScript using HLF fabric-gateway",
    "main": "dist/index.js",
    "typings": "dist/index.d.ts",
    "engines": {
@@ -13,7 +13,7 @@
        "lint": "eslint . --ext .ts",
        "prepare": "npm run build",
        "pretest": "npm run lint",
        "start": "node dist/adrenalineDLT_app.js"
        "start": "node dist/dlt_gateway.js"
    },
    "engineStrict": true,
    "author": "CTTC-Javier",
+1 −2
Original line number Diff line number Diff line
@@ -9,8 +9,7 @@
        "noImplicitAny": true
    },
    "include": [
        "./src/**/*"
, "src.old/grpcClient.js", "src.old/grpcServer.js", "tests/testEvents.js", "tests/testGateway.js"    ],
        "./src/**/*"   ],
    "exclude": [
        "./src/**/*.spec.ts"
    ]
+3 −3
Original line number Diff line number Diff line
@@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const { connectToNetwork } = require('../dist/fabricConnect');
const { connectToNetwork } = require('../dltApp/dist/fabricConnect');
const fsp = require('fs').promises;
const fs = require('fs');
const util = require('util');

const utf8Decoder = new TextDecoder();
const topoDirectory = '../samples/';
//const topologies = ['topo1.json', 'topo2.json', 'topo3.json', 'topo4.json'];
const topologies = ['topo4.json'];
const topologies = ['topo1.json', 'topo2.json', 'topo3.json', 'topo4.json'];
//const topologies = ['topo4.json'];

const iterations = 1000;

Loading