substrate - 如何将 AccountId 转换为 Vec或相反亦然
问题描述
我有一个接受T::AccountId类型的函数
Citizen get(fn candidate_name): map hasher(blake2_128_concat) T::AccountId => Option<Vec<u8>>;
例如
fn add_count(origin, account:T::AccountId, phrase: Vec<u8>) {
// I need to concatenate : account + _ + phrase, then convert it to Vec<u8> or bytes
// Then change the Citizen storage using account
}
另一种方法是:
fn add_count(origin, account:Vec<u8>, phrase: Vec<u8>) {
// Concatenate : account + _ + phrase, then convert it to Vec<u8> or bytes
// Then change account to T::AccountId and then change the Citizen storage
}
但我无法将 T::AccountId 类型转换为 bytes/vec<u8> ,反之亦然。
解决方案
推荐阅读
- javascript - HTML 输入类型文件只支持拖放但限制文件浏览和上传
- javascript - 在切换单击的项目之前将全部切换到原始状态
- javascript - 播放按钮不适用于外部视频
- javascript - NodeJS:根据短语从 html 文本中提取句子
- c# - 统一的音频为零
- javascript - Jquery排序表 - >文本前的数字
- android - 如何在循环中为android中的图像设置动画?
- sql - SQL 如何解释括号及其中的顺序?
- c# - umbraco 7 无法使用#key 从字典中获取选项卡名称
- python - 从 4 维 Numpy 数组中获取图像作为 4 维 Numpy 数组