【问题标题】:Why do we need `startWatching` function from WalletApi?为什么我们需要 WalletApi 的 startWatching 函数?
【发布时间】:2019-09-07 14:18:05
【问题描述】:

在游戏示例中的 plutus playground 中有一个功能

-- | The "startGame" contract endpoint, telling the wallet to start watching
--   the address of the game script. See note [Contract endpoints]
startGame :: MonadWallet m => m ()
startGame =
    -- 'startWatching' is a function of the wallet API. It instructs the wallet
    -- to keep track of all outputs at the address. Player 2 needs to call
    -- 'startGame' before Player 1 uses the 'lock' endpoint, to ensure that
    -- Player 2's wallet is aware of the game address.
    startWatching gameAddress

我不喜欢

Player 2 needs to call
'startGame' before Player 1 uses the 'lock' endpoint, to ensure that
Player 2's wallet is aware of the game address.

真的没有办法连接到游戏之后游戏启动(lock函数被调用)?

我们需要这个功能吗?我们可以只使用guesslock 函数吗?

我可以理解 startWatching 对轻钱包/客户端(使用 merkle 证明来验证交易)有何意义,但不理解 startGame 函数对完整客户端有何用处。 (其实我不会,轻量级的客户端应该还是可以从其他需求中询问信息的)

【问题讨论】:

    标签: haskell smartcontracts cardano plutus


    【解决方案1】:

    正如您所说的那样,需要startWatching 的原因与 Plutus 合约可以访问的钱包的功能有关。

    在模拟器的第一次迭代中,我们采用了 Plutus 合约只能对区块链状态进行前瞻性查询的保守假设。也就是说,我们假设由于某些钱包的资源限制,不可能扫描区块链的任意部分。结果是所有针对这个限制性钱包接口编写的合约都必须调用startWatching,然后才能做任何有趣的事情。

    在实施模拟器时,没有 Plutus 合约可以预期的钱包功能规范 - 事实上,构建模拟器的动机之一是帮助我们编写规范。而且很有可能当前的限制性界面(仅限前瞻性查询)将被更强大的功能所取代,这样startGame 端点就不再需要了。

    【讨论】:

    • 期待更换!
    • 有问题我可以在 github 上跟踪吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-24
    • 2019-06-09
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多