首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CryptoKitties是如何跟踪时间的?

CryptoKitties是如何跟踪时间的?
EN

Ethereum用户
提问于 2017-12-05 21:00:17
回答 2查看 1.7K关注 0票数 6

我在看KittyBreeding.sol

代码语言:javascript
复制
 /// @dev Set the cooldownEndTime for the given Kitty, based on its current cooldownIndex.
    ///  Also increments the cooldownIndex (unless it has hit the cap).
    /// @param _kitten A reference to the Kitty in storage which needs its timer started.
    function _triggerCooldown(Kitty storage _kitten) internal {
        // Compute the end of the cooldown time (based on current cooldownIndex)
        _kitten.cooldownEndTime = uint64(now + cooldowns[_kitten.cooldownIndex]);

但我看不出“现在”是在哪里定义的,除非是在他们的kitty-core.test.js

这个DAPP如何跟踪时间,让网站显示计时器?

EN

回答 2

Ethereum用户

回答已采纳

发布于 2017-12-05 21:04:25

now是一个可靠的特殊变量,它等同于自时代以秒计以来的当前时间。

从文件(上文链接):

now (uint):当前块时间戳(别名为block.timestamp)

票数 8
EN

Ethereum用户

发布于 2017-12-05 21:23:00

值得注意的是,矿工可以操纵now,因此不应该依赖于任何敏感的东西,比如播种Psuedo-随机数生成器。

票数 4
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/32557

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档