为什么我们需要 WalletApi 的 `startWatching` 功能?
Why do we need `startWatching` function from WalletApi?
游戏示例中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
函数被调用)无法连接到游戏吗?
我们真的需要这个功能吗?我们可以只使用 guess
和 lock
函数吗?
我能理解 startWatching
如何对 light wallets/clients(使用 merkle 证明来验证交易)有意义,但不明白 startGame
函数对完整客户。 (其实我不知道,轻客户端应该还是可以从其他需求中询问信息)
如您所述,需要 startWatching
的原因与 Plutus 合约可以访问的钱包的功能有关。
在模拟器的第一次迭代中,我们保守地假设 Plutus 合约只能对区块链状态进行前瞻性查询。也就是说,我们假设由于某些钱包的资源限制,不可能扫描区块链的任意部分。结果是所有针对这个限制性钱包接口编写的合约都必须调用 startWatching
才能做任何有趣的事情。
实施模拟器时,没有 Plutus 合约可以预期的钱包功能规范 - 事实上,构建模拟器的动机之一是帮助我们编写规范。当前的限制性接口(仅限前瞻性查询)很可能会被更强大的东西取代,这样 startGame
端点就不再需要了。
游戏示例中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
函数被调用)无法连接到游戏吗?
我们真的需要这个功能吗?我们可以只使用 guess
和 lock
函数吗?
我能理解 startWatching
如何对 light wallets/clients(使用 merkle 证明来验证交易)有意义,但不明白 startGame
函数对完整客户。 (其实我不知道,轻客户端应该还是可以从其他需求中询问信息)
如您所述,需要 startWatching
的原因与 Plutus 合约可以访问的钱包的功能有关。
在模拟器的第一次迭代中,我们保守地假设 Plutus 合约只能对区块链状态进行前瞻性查询。也就是说,我们假设由于某些钱包的资源限制,不可能扫描区块链的任意部分。结果是所有针对这个限制性钱包接口编写的合约都必须调用 startWatching
才能做任何有趣的事情。
实施模拟器时,没有 Plutus 合约可以预期的钱包功能规范 - 事实上,构建模拟器的动机之一是帮助我们编写规范。当前的限制性接口(仅限前瞻性查询)很可能会被更强大的东西取代,这样 startGame
端点就不再需要了。