我试图在基板托盘的外部调用执行范围内获取系统时间。它应该独立于目标架构(wasm、unix 等)和构建模式(std、no_std)
使用 std::time::SystemTime、chrono 或 wasm-timer 库不是一个选项,因为它们严重依赖于 std。
在自定义托盘范围内引用时间戳托盘也不是一种选择,因为它随时提供链上时间戳,即当前或下一个区块时间戳。
问题:
有没有办法使用基板手段在托盘“功能”范围内获取系统/实际当前时间戳
当节点启动并在运行时递增时如何初始化托盘时间戳的时间戳/现在值(它的来源是什么)
您能否建议任何提供此类方法的库,这些方法可以与托盘链接而不会遇到以下类似错误
Compiling pallet-template v3.0.0-monthly-2021-08 (/workspace/supra/examples/concurrency_poc/node/pallets/template)
error: duplicate lang item in crate `std` (which `wasm_timer` depends on): `panic_impl`.
|
= note: the lang item is first defined in crate `sp_io` (which `frame_support` depends on)
= note: first definition in `sp_io` loaded from /workspace/supra/examples/concurrency_poc/node/target/debug/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-e941cef754f8762e.rmeta
= note: second definition in `std` loaded from /home/areg/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-0c448d560077210c.rlib
error: duplicate lang item in crate `std` (which `wasm_timer` depends on): `oom`.
|
= note: the lang item is first defined in crate `sp_io` (which `frame_support` depends on)
= note: first definition in `sp_io` loaded from /workspace/supra/examples/concurrency_poc/node/target/debug/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-e941cef754f8762e.rmeta
= note: second definition in `std` loaded from /home/areg/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-0c448d560077210c.rlib