Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

存储区变量赋值操作生效时机及是否是原子操作的问题? #49

Closed
hiliushuo opened this issue Jun 9, 2018 · 8 comments

Comments

@hiliushuo
Copy link

现在有个需求是想【满足某个条件的时候触发一方法执行,且该方法只允许执行一次】

目前实现思路是在中心化 server 判断当区块高度变化时轮询合约runGame方法,runGame方法中通过修改gameStatus的值

case 2:
if ( nowBlockH > openPrizeH) {
      this.gameStatus = 3;
}
break;
case 3:
if( !hasEnterOpenPriceMethod(period)) {    //hasEnterOpenPriceMethod方法中修改了一个存储区的变量用来标记当期游戏已进入过开奖方法
      openPrizeH();
}
break;

问题 this.gameStatus = 3; 这个操作的生效是需要整个 tx success 之后呢 还是说方法体中执行过这个语句之后立即生效呢?
这个赋值操作是原子操作吗?(会立即反应到存储区吗?)

感谢!~

@hiliushuo

This comment has been minimized.

@zhangzq94
Copy link

召唤大神

@hiliushuo
Copy link
Author

问题用一句话描述就是 如何在合约里保证某一方法只能被执行一次😂,求大神帮忙~

@yupnano
Copy link
Contributor

yupnano commented Jun 11, 2018

合约的链上数据的更改是在交易执行成功之后才会生效的,不过对同一合约的调用不会并发执行的,所以不用担心数据的同步问题。

@hiliushuo
Copy link
Author

好的,感谢~~

@hiliushuo
Copy link
Author

我们对事务的控制是Serializable级别的吗?

@ChengOrangeJu
Copy link
Contributor

@hiliushuo 是的,可以理解为是Serializable级别

@hiliushuo
Copy link
Author

好的,感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants