Hyperledger Sawtooth:JavaScript中的事务处理器

时间:2018-07-02 07:53:44

标签: javascript node.js express hyperledger-sawtooth

我正在尝试根据以下示例在javascript SDK中实现交易处理器

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

这是我的代码,用于在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()

}

但是我收到无效的参数错误

  

错误:参数无效       在export.Socket.Socket.connect(/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/zeromq/lib/index.js:510:13)       在Stream.connect(/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/sawtooth-sdk/messaging/stream.js:85:18)       在TransactionProcessor.start(/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/sawtooth-sdk/processor/index.js:72:18)       在Object.startProcessor(/var/accubits-workspace/hypeerledger-sawtooth/tuts/helpers/transaction-processor.js:15:26)       在app.get(/var/accubits-workspace/hypeerledger-sawtooth/tuts/index.js:62:26)       在Layer.handle [作为handle_request](/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/layer.js:95:5)       在下一个(/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/route.js:137:13)       在Route.dispatch(/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/route.js:112:3)       在Layer.handle [作为handle_request](/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/layer.js:95:5)       在/var/accubits-workspace/hypeerledger-sawtooth/tuts/node_modules/express/lib/router/index.js:281:22

1 个答案:

答案 0 :(得分:2)

将验证者地址更改为验证的URL,可以为tcp://validator:4004tcp://localhost:4004

这是完整的代码:

'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();