Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Gets blockchain storage info. #37

Merged
merged 3 commits into from Jul 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/commands/blockchain/storage.ts
@@ -0,0 +1,52 @@
/*
*
* Copyright 2018 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import chalk from 'chalk';
import {command, metadata} from 'clime';
import {BlockchainHttp} from 'nem2-sdk';
import {ProfileCommand, ProfileOptions} from '../../profile.command';

@command({
description: 'Blockchain storage',
dgarcia360 marked this conversation as resolved.
Show resolved Hide resolved
})
export default class extends ProfileCommand {

constructor() {
super();
}

@metadata
execute(options: ProfileOptions) {
this.spinner.start();

const profile = this.getProfile(options);

const blockchainHttp = new BlockchainHttp(profile.url);
dgarcia360 marked this conversation as resolved.
Show resolved Hide resolved
blockchainHttp.getDiagnosticStorage().subscribe((storage) => {
this.spinner.stop(true);

console.log('numBlocks: ' + storage.numBlocks);
dgarcia360 marked this conversation as resolved.
Show resolved Hide resolved
console.log('numTransactions: ' + storage.numTransactions);
console.log('numAccounts: ' + storage.numAccounts);
}, (err) => {
this.spinner.stop(true);
let text = '';
text += chalk.red('Error');
console.log(text, err.response !== undefined ? err.response.text : err);
});
}
}