- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有三个客户端应用程序,它们分别使用 Java、Node.js 和 Go SDK 与我的区 block 链 Fabric 进行交互。使用它们,我可以成功查询和更新分类帐。
现在我想测量分类帐更新期间的延迟。所以,我想在提交请求之前取一个时间戳,在交易成功提交到账本之后取另一个时间戳,然后计算差值。
我的问题是我找不到任何关于 SDK 的 Java、Go 和 Node.js API 的完整文档,所以我不知道当提交方法返回时,我是否可以认为事务已正确提交到账本。
这是我的三个客户的代码。 java :
NetworkConfig ccp = NetworkConfig.fromJsonFile(networkConfigPath.toFile());
// initialize default cryptosuite and setup the client
CryptoSuite cryptoSuite = CryptoSuite.Factory.getCryptoSuite();
HFClient client = HFClient.createNewInstance();
client.setCryptoSuite(cryptoSuite);
Channel channel = client.loadChannelFromConfig(ccp.getChannelNames().iterator().next(), ccp);
channel.initialize();
TransactionProposalRequest transactionProposal = client.newTransactionProposalRequest();
// build chaincode id providing the chaincode name
ChaincodeID mychaincodeID = ChaincodeID.newBuilder().setName("mychaincode").build();
transactionProposal.setChaincodeID(mychaincodeID);
// calling chaincode function
transactionProposal.setFcn("mymethod");
transactionProposal.setArgs("a1");
Collection<ProposalResponse> res = channel.sendTransactionProposal(transactionProposal);
channel.sendTransaction(res);
节点.js:
const gateway = new Gateway();
await gateway.connect(ccp, { wallet: wallet, identity: userName, discovery: { enabled: false } });
// Get the network (channel) our contract is deployed to.
const network = await gateway.getNetwork('mychannel');
// Get the contract from the network.
const contract = network.getContract('mychaincode');
const result = await contract.submitTransaction('mymethod', 'a1');
开始:
sdk, err := fabsdk.New(config.FromFile(configFile))
if err != nil {
fmt.Printf("failed to create SDK: %v\n", err)
return
}
fmt.Println("SDK created")
// Prepare channel client context using client context
clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser(userName), fabsdk.WithOrg(orgName))
// ChannelClient is used to query and execute transactions
client, err := channel.New(clientChannelContext)
if err != nil {
fmt.Printf("failed to create new channel client: %v\n", err)
return
}
fmt.Println("channel client created")
response, err := client.Execute(channel.Request{ChaincodeID: ccID, Fcn: "mymethod", Args: [][]byte{[]byte("a1")}}, channel.WithRetry(retry.DefaultChannelOpts))
if err != nil {
fmt.Printf("failed to execute the invoke function: %v\n", err)
} else {
fmt.Println("Proposal responses: ")
for _, element := range response.Responses {
fmt.Printf("Endorser: %s Status: %d ChaincodeStatus: %d\n", element.Endorser, element.Status, element.ChaincodeStatus)
}
fmt.Println("chaincode transaction completed: " + string(response.Payload))
}
// Close SDK
sdk.Close()
这些代码有效。我的问题是:我可以确定在行之后
channel.sendTransaction(res)
(在 Java 中)
const result = await contract.submitTransaction('mymethod', 'a1');
(在 Node.js 中)
response, err := client.Execute(channel.Request{ChaincodeID: ccID, Fcn: "mymethod", Args: [][]byte{[]byte("a1")}}, channel.WithRetry(retry.DefaultChannelOpts))
(围棋)交易已经提交到账本?
我只在文档上发现:
“向分类帐提交交易。交易功能名称将在背书节点上进行评估,然后提交给排序服务以提交到分类帐。”用于 Node.js 中的 submitTransaction https://fabric-sdk-node.github.io/release-1.4/module-fabric-network.Contract.html#submitTransaction__anchor
和
“Execute 使用请求和可选的请求选项准备和执行事务”,用于在 https://godoc.org/github.com/hyperledger/fabric-sdk-go/pkg/client/channel#Client.Execute 中执行 Go
对于 Java,我找不到文档...而且我也不确定 Node.js 和 Go。
最佳答案
另一个答案可以帮助那些可能需要 CLI 中的此功能的人。
默认情况下,当订单收到交易时,CLI 返回成功。
要等到 peer chaincode invoke
提交,commnad 添加标志 --waitForEvent
这样,cli 将等待来自同行的提交事件。
希望对您有所帮助。
关于hyperledger-fabric - super 账本结构 : check if the transaction has been committed to the ledger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56103391/
问题比较Java,但是我想在Android中实现: 假设有 3 个或更多类相互扩展: class A { ... int color; ... } class B extend
我知道标题听起来有点奇怪,但这正是我愿意做的。简单解释:A类是B类的子类,B类也是C类的子类>. 现在,所有这些类都包含方法m()。在我的 A 类中,这是我唯一可以访问的类,因为其他类仅在运行时可用,
我有一个 UIViewController 类 A 和 B。 A 使用以下方式加载 B:[A.view addSubView B.view]。 B 有一个带有“后退”按钮的导航栏。我想在单击时返回到
我有以下(第三方)类结构。我们将调用第三方项目 ProjectSeriously,并注意我使用 System.out.println 代替其他复杂的功能(100 行代码) . class A {
在下面的代码中,我从 Game 扩展了 MyGame。我有两个问题: 我们是否需要为所有render()、dispose()、pause()调用super方法 和 resize(w,h)?很多人都没有
例如,假设我想在调用 super.viewDidLoad() 时跳过一级。所以我希望能够做这样的事情: override func viewDidLoad() { super.super.vi
public class Faculty extends Employee { public static void main(String[] args) { new Fac
假设我有: class Superclass { //fields... methodA() {...} methodB() {...} ... } class Subclass exte
这个问题在这里已经有了答案: Why is super.super.method(); not allowed in Java? (22 个答案) 关闭 9 年前。 我怀疑我想做的事情是否可行。我有
我有一个实现 Initializable 的类。 public abstract class ExampleClass implements Initializable { public vo
我想知道,我有这个大数组,是否可以只在内存中使用一次而不是每个线程一次?以 stackoverflow 上的标签为例。他们几乎从不改变,为什么不为他们留下一个内存点呢?甚至可能将该数组永久保存在内存中
假设这三个类具有这个简单的层次结构: class A { func foo() { print("A") } } class B: A { override fu
有没有办法在 TypeScript 中调用 super.super.methodName。我想避免调用super.methodName,但我想调用二祖的methodName方法。 谢谢。 最佳答案 T
这个问题已经有答案了: When do I use super()? (11 个回答) 已关闭 7 年前。 package Geometry; public abstract class Geomet
我必须执行and()在我的实现 Predicate 的业务对象上. 出现问题的代码是 and() 行调用: Predicate predicate = new M
我有一个实现接口(interface)的抽象父类(super class): public abstract class FooMatrix implements Matrix { publi
我有四个 UIView:viewA 是 Root View ,它有 viewB 作为它的 subview 。 viewB 将 viewC 作为其 subview ,而 viewC 将 viewD 作为
有什么区别: class Child(SomeBaseClass): def __init__(self): super(Child, self).__init__() 和:
我有一个通用接口(interface) interface ListList extends List> .由于某些原因,我无法转换 ListList至 List> .有什么方法可以做到吗?为什么它不
我想调用带有两个参数的父类(super class)的构造函数,所以我调用了 super(arguments),但是编译器说: “类 Person 中的构造函数 Person 不能应用于给定类型; 要
我是一名优秀的程序员,十分优秀!