nebulasio / wiki

This repository is out of date, please check the new wiki:
http://wiki.nebulas.io/en/latest/
GNU General Public License v3.0
421 stars 153 forks source link

defineMapProperty有办法获取里面存的元素的个数吗 #183

Open t4Wang opened 6 years ago

t4Wang commented 6 years ago

比如这样定义

LocalContractStorage.defineMapProperty(this, "map", {
                         stringify(o) {
                                 return o.toString();
                        },
                         parse(text) {
                                 retrun new _Bottle(text);
                         }

                 });

怎么获取map的大小?

ChengOrangeJu commented 6 years ago

可以维护一个变量size,在插入数据时增加1

yupnano commented 6 years ago

可以参考tutorial中的例子:Map数据遍历

t4Wang commented 6 years ago

@ChengOrangeJu 但是这样会有多线程问题,比如size增加了1但是方法执行失败了,或者几个人同时请求等等

dreamflyfengzi commented 6 years ago

并发处理是在调用智能合约之前该做的事儿

weiht12 commented 6 years ago

你好,此版本为星云旧版wiki(后期逐步停止维护),欢迎将您的问题提交星云新版wiki,以便于获得及时解答。同时,参与wiki的编辑维护工作还会有奖励哦。新版wiki链接:https://wiki.nebulas.io/en/latest/ (英文);https://wiki.nebulas.io/zh_CN/latest/ (中文) Hello, this version is the nebulas old wiki (later stop maintenance), welcome to submit your question to the new nebulas wiki, in order to get timely answers. At the same time, there will be rewards for editing and maintaining the wiki. New wiki link: https://wiki.nebulas.io/en/latest/ (English); https://wiki.nebulas.io/zh_CN/latest/ (Chinese)