我正试图基于以下示例在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()

}

但是我得到了无效的参数错误
错误:无效参数
在exports.socket.socket.connect(/var/accubits workspace/hypeerledger sawtooth/tuts/node廑modules/zeromq/lib/index.js:510:13)
在stream.connect上(/var/acubits 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/acubits workspace/hypeerregder sawtooth/tuts/index.js:62:26)
在layer.handle[作为handle_请求](/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-muds/express/lib/router/route.js:112:3)
在layer.handle[作为handle_请求](/var/accubits workspace/hypeerledger sawtooth/tuts/node_modules/express/lib/router/layer.js:95:5)
at/var/accubits workspace/hypeerledger sawtooth/tuts/node_u modules/express/lib/router/index.js:281:22

最佳答案

将验证器地址更改为验证的url,该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();

关于javascript - Hyperledger Sawtooth:JavaScript中的事务处理器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51131415/

10-09 10:08