- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我用 Java Card 开发了一个小程序,它运行良好。现在我正在研究这个小程序的坚固性,更准确地说,如果卡在小程序执行期间被拔掉会发生什么。
我想知道是否有处理此类事情的异常?
我正在寻找类似的东西:
try {
...
}
// If the card is disconnected while the applet execution
catch (Exception e) {
...
}
提前谢谢你。
最佳答案
由于智能卡内部没有任何电池,因此您不能像这样进行任何try ... catch ...
。或者,您可以利用 Transactions
。事务 API 只是为了您的目标而提供的。 beginTransation()
和 commitTransation()
方法之间的操作仅在 commitTransation()
成功完成时适用。如果在 commitTransation()
之前发生任何异常/卡片撕裂或卡片重置,一切都会返回到其原始状态(即返回到它在 beginTransaction()
之前的状态)
是这样的:
.
.
JCSystem.beginTransaction();
//put your critical code here.
JCSystem.commitTransaction();
.
.
您还可以使用 JCSystem.commitTransaction();
在特定情况下终止事务,如下所示:
.
.
JCSystem.beginTransaction();
//put your critical code here.
if (condition) {
JCSystem.commitTransaction();
}
JCSystem.commitTransaction();
.
.
注意:
关于java - Java Card 中小程序的坚固性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29917445/
我正在尝试为我正在编写的智能合约编写一些单元测试,但在弄清楚如何在创建时将参数传递给合约的构造函数时遇到困难。下面是我的代码: const assert = require('assert'); co
我正在尝试编写一个去中心化应用程序来购买音乐会门票。出于某种原因,部分 owner.transfer(this.balance) 一直给我错误。此外,由于 solidity 的版本太多,我找不到最适合
Warning: Using contract member "balance" inherited from the address type is deprecated. Convert the
我是一名优秀的程序员,十分优秀!