本文介绍了Hyperledger Sawtooth:JavaScript中的事务处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这是我的代码,用于在javascript SDK中运行事务处理器

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

推荐答案

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

Change the validator address to the url of the validation which can be either tcp://validator:4004 or tcp://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();

这篇关于Hyperledger Sawtooth:JavaScript中的事务处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 13:05
查看更多