dshackle cli tool
This commit is contained in:
25
dshackle-cli/src/grpc-clent.js
Normal file
25
dshackle-cli/src/grpc-clent.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const grpc = require("@grpc/grpc-js");
|
||||
const path = require('path')
|
||||
const protoLoader = require("@grpc/proto-loader");
|
||||
|
||||
const PROTO_PATH = path.join(__dirname, "../proto/blockchain.proto");
|
||||
|
||||
const options = {
|
||||
keepCase: true,
|
||||
longs: String,
|
||||
enums: String,
|
||||
defaults: true,
|
||||
oneofs: true,
|
||||
};
|
||||
|
||||
const packageDefinition = protoLoader.loadSync(PROTO_PATH, options);
|
||||
const emerald = grpc.loadPackageDefinition(packageDefinition).emerald
|
||||
|
||||
export function describe(url, handler) {
|
||||
const client = new emerald.Blockchain(
|
||||
url,
|
||||
grpc.credentials.createInsecure()
|
||||
);
|
||||
console.log('Connecting to: ' + url + '...')
|
||||
client.Describe({}, handler);
|
||||
}
|
||||
Reference in New Issue
Block a user