-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_password_keeper.js
54 lines (42 loc) · 1.34 KB
/
my_password_keeper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"use strict";
var Address2UserStorage = function () {
LocalContractStorage.defineMapProperty(this, "addressUserStorageMap");
};
Address2UserStorage.prototype = {
init: function () {
//todo
},
save: function (key, value) {
let from = Blockchain.transaction.from;
let recordList = this.addressUserStorageMap.get(from);
if (!recordList) {
recordList = [];
recordList[0] = {};
recordList[0].key = value;
} else {
let nextIndex = recordList.length;
recordList[nextIndex] = {};
recordList[nextIndex].key = value;
}
return this.addressUserStorageMap.put(from, recordList);
},
get: function () {
let from = Blockchain.transaction.from;
let recordList = this.addressUserStorageMap.get(from);
let resultList = [];
let j = 0;
if (!recordList){
return "";
} else {
let len = recordList.length;
for (let i = 0; i < len; i++) {
if (recordList[i].hasOwnProperty("isDeleted") && recordList[i].isDeleted === 1) { // save for future
continue;
}
resultList[j++] = recordList[i];
}
}
return resultList;
}
};
module.exports = Address2UserStorage;