Skip to content
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
47 changes: 0 additions & 47 deletions e2e/infrastructure/DiagnosticHttp.spec.ts

This file was deleted.

25 changes: 25 additions & 0 deletions e2e/infrastructure/NodeHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,29 @@ describe('NodeHttp', () => {
expect(nodeTime.sendTimeStamp).not.to.be.undefined;
});
});

describe('getStorageInfo', () => {
it('should return storage info', async () => {
const blockchainStorageInfo = await nodeRepository.getStorageInfo().toPromise();
expect(blockchainStorageInfo.numBlocks).to.be.greaterThan(0);
expect(blockchainStorageInfo.numTransactions).to.be.greaterThan(0);
expect(blockchainStorageInfo.numAccounts).to.be.greaterThan(0);
});
});

describe('getServerInfo', () => {
it('should return server info', async () => {
const serverInfo = await nodeRepository.getServerInfo().toPromise();
expect(serverInfo.restVersion).not.to.be.null;
expect(serverInfo.sdkVersion).not.to.be.null;
});
});

describe('getNodeHealth', () => {
it('should return node health', async () => {
const health = await nodeRepository.getNodeHealth().toPromise();
expect(health.apiNode).not.to.be.null;
expect(health.db).not.to.be.null;
});
});
});
22 changes: 10 additions & 12 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"js-sha3": "^0.8.0",
"long": "^4.0.0",
"merkletreejs": "^0.1.7",
"nem2-sdk-openapi-typescript-node-client": "0.7.22",
"nem2-sdk-openapi-typescript-node-client": "0.8.2",
"request": "^2.88.0",
"request-promise-native": "^1.0.5",
"ripemd160": "^2.0.2",
Expand Down
73 changes: 0 additions & 73 deletions src/infrastructure/DiagnosticHttp.ts

This file was deleted.

43 changes: 43 additions & 0 deletions src/infrastructure/NodeHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import { NodeRoutesApi } from 'nem2-sdk-openapi-typescript-node-client';
import { from as observableFrom, Observable, throwError } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { StorageInfo } from '../model/blockchain/StorageInfo';
import { NodeHealth } from '../model/node/NodeHealth';
import { NodeInfo } from '../model/node/NodeInfo';
import { NodeTime } from '../model/node/NodeTime';
import { ServerInfo } from '../model/node/ServerInfo';
import { UInt64 } from '../model/UInt64';
import { Http } from './Http';
import { NodeRepository } from './NodeRepository';
Expand Down Expand Up @@ -81,4 +84,44 @@ export class NodeHttp extends Http implements NodeRepository {
catchError((error) => throwError(this.errorHandling(error))),
);
}

/**
* Gets blockchain storage info.
* @returns Observable<BlockchainStorageInfo>
*/
public getStorageInfo(): Observable<StorageInfo> {
return observableFrom(
this.nodeRoutesApi.getNodeStorage()).pipe(
map(({body}) => new StorageInfo(
body.numBlocks,
body.numTransactions,
body.numAccounts,
)),
catchError((error) => throwError(this.errorHandling(error))),
);
}

/**
* Gets blockchain server info.
* @returns Observable<Server>
*/
public getServerInfo(): Observable<ServerInfo> {
return observableFrom(
this.nodeRoutesApi.getServerInfo()).pipe(
map(({body}) => new ServerInfo(body.serverInfo.restVersion, body.serverInfo.sdkVersion)),
catchError((error) => throwError(this.errorHandling(error))),
);
}

/**
* Gets blockchain server info.
* @returns Observable<Server>
*/
public getNodeHealth(): Observable<NodeHealth> {
return observableFrom(
this.nodeRoutesApi.getNodeHealth()).pipe(
map(({body}) => new NodeHealth(body.status.apiNode, body.status.db)),
catchError((error) => throwError(this.errorHandling(error))),
);
}
}
23 changes: 23 additions & 0 deletions src/infrastructure/NodeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
*/

import {Observable} from 'rxjs';
import { StorageInfo } from '../model/blockchain/StorageInfo';
import { NodeHealth } from '../model/node/NodeHealth';
import { NodeInfo } from '../model/node/NodeInfo';
import { NodeTime } from '../model/node/NodeTime';
import { ServerInfo } from '../model/node/ServerInfo';

/**
* Node interface repository.
Expand All @@ -36,4 +39,24 @@ export interface NodeRepository {
* @summary Get the node time
*/
getNodeTime(): Observable<NodeTime>;

/**
* Get node health information
*
* @return {@link NodeHealth} of NodeHealth
*/
getNodeHealth(): Observable<NodeHealth>;

/**
* Gets blockchain storage info.
* @returns Observable<StorageInfo>
*/
getStorageInfo(): Observable<StorageInfo>;

/**
* Gets blockchain server info.
* @returns Observable<Server>
*/
getServerInfo(): Observable<ServerInfo>;

}
6 changes: 0 additions & 6 deletions src/infrastructure/RepositoryFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { NetworkType } from '../model/blockchain/NetworkType';
import { AccountRepository } from './AccountRepository';
import { BlockRepository } from './BlockRepository';
import { ChainRepository } from './ChainRepository';
import { DiagnosticRepository } from './DiagnosticRepository';
import { IListener } from './IListener';
import { MetadataRepository } from './MetadataRepository';
import { MosaicRepository } from './MosaicRepository';
Expand Down Expand Up @@ -76,11 +75,6 @@ export interface RepositoryFactory {
*/
createChainRepository(): ChainRepository;

/**
* @returns a newly created {@link DiagnosticRepository}
*/
createDiagnosticRepository(): DiagnosticRepository;

/**
* @returns a newly created {@link MosaicRepository}
*/
Expand Down
6 changes: 0 additions & 6 deletions src/infrastructure/RepositoryFactoryHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import { BlockHttp } from './BlockHttp';
import { BlockRepository } from './BlockRepository';
import { ChainHttp } from './ChainHttp';
import { ChainRepository } from './ChainRepository';
import { DiagnosticHttp } from './DiagnosticHttp';
import { DiagnosticRepository } from './DiagnosticRepository';
import { IListener } from './IListener';
import { Listener } from './Listener';
import { MetadataHttp } from './MetadataHttp';
Expand Down Expand Up @@ -85,10 +83,6 @@ export class RepositoryFactoryHttp implements RepositoryFactory {
return new ChainHttp(this.url);
}

createDiagnosticRepository(): DiagnosticRepository {
return new DiagnosticHttp(this.url);
}

createMetadataRepository(): MetadataRepository {
return new MetadataHttp(this.url);
}
Expand Down
2 changes: 0 additions & 2 deletions src/infrastructure/infrastructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
export * from './AccountHttp';
export * from './BlockHttp';
export * from './ChainHttp';
export * from './DiagnosticHttp';
export * from './Http';
export * from './MosaicHttp';
export * from './MetadataHttp';
Expand All @@ -36,7 +35,6 @@ export * from './transaction/NamespaceMosaicIdGenerator';
export * from './AccountRepository';
export * from './BlockRepository';
export * from './ChainRepository';
export * from './DiagnosticRepository';
export * from './IListener';
export * from './MetadataRepository';
export * from './MosaicRepository';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* The blockchain storage info structure describes stored data.
*/
export class BlockchainStorageInfo {
export class StorageInfo {

/**
* @param numBlocks
Expand Down
Loading