Hyperledger Sawtooth: Transaction processor in Javascript

雨燕双飞 提交于 2019-12-24 05:22:27

问题


I am trying to implement a transaction processor in javascript SDK based on the following example

https://github.com/hyperledger/sawtooth-core/blob/master/sdk/examples/intkey_javascript/index.js

Here is my code to run a transaction processor in javascript SDK

//validator public key
const validatorAddress = '024c512a6d66917d7d00f52fa299a88594915dab27bddbcd2a80154984d7948c3c';

const IntegerKeyHandler = require('./handler');

const startProcessor = function startProcessor(){

    const transactionProcessor = new TransactionProcessor(validatorAddress);

    transactionProcessor.addHandler(new IntegerKeyHandler())

    transactionProcessor.start()

}

But i am getting invalid argument error

Error: Invalid argument at exports.Socket.Socket.connect (/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/zeromq/lib/index.js:510:13) at Stream.connect (/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/sawtooth-sdk/messaging/stream.js:85:18) at TransactionProcessor.start (/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/sawtooth-sdk/processor/index.js:72:18) at Object.startProcessor (/var/accubits-workspace/hypeerledger-sawtooth/tuts/helpers/transaction-processor.js:15:26) at app.get (/var/accubits-workspace/hypeerledger-sawtooth/tuts/index.js:62:26) at Layer.handle [as handle_request] (/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/layer.js:95:5) at next (/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/layer.js:95:5) at /var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/index.js:281:22


回答1:


Change the validator address to the url of the validation which can be either tcp://validator:4004 or tcp://localhost:4004

Here's the full code:

'use strict'

const { TransactionProcessor } = require('sawtooth-sdk/processor')
const IntegerKeyHandler = require('./integer_key_handler')

const address = 'tcp://validator:4004' // If you are not running it inside docker container then change the address to this tcp://localhost:4004

const transactionProcessor = new TransactionProcessor(address);

transactionProcessor.addHandler(new IntegerKeyHandler());

transactionProcessor.start();


来源:https://stackoverflow.com/questions/51131415/hyperledger-sawtooth-transaction-processor-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!