trac-peer 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/feature.js +1 -1
- package/src/functions.js +3 -3
- package/src/index.js +1 -1
- package/src/protocol.js +1 -1
package/package.json
CHANGED
package/src/feature.js
CHANGED
package/src/functions.js
CHANGED
|
@@ -90,7 +90,7 @@ export async function setAutoAddWriters(input, peer){
|
|
|
90
90
|
const splitted = input.split(' ');
|
|
91
91
|
const value = splitted[1];
|
|
92
92
|
if(value !== 'on' && value !== 'off') throw new Error('setAutoAddWriters: use on and off values.');
|
|
93
|
-
const msg = { type: 'setAutoAddWriters', key: value, nonce : Math.random() }
|
|
93
|
+
const msg = { type: 'setAutoAddWriters', key: value, nonce : Math.random() + '-' + Date.now() }
|
|
94
94
|
const signature = {
|
|
95
95
|
msg: msg
|
|
96
96
|
};
|
|
@@ -108,7 +108,7 @@ export async function addAdmin(input, peer){
|
|
|
108
108
|
export async function addWriter(input, peer){
|
|
109
109
|
const splitted = input.split(' ');
|
|
110
110
|
if(splitted[0] === '/add_indexer'){
|
|
111
|
-
const msg = { type: 'addIndexer', key: splitted[splitted.length - 1], nonce : Math.random() }
|
|
111
|
+
const msg = { type: 'addIndexer', key: splitted[splitted.length - 1], nonce : Math.random() + '-' + Date.now() }
|
|
112
112
|
const signature = {
|
|
113
113
|
msg: msg
|
|
114
114
|
};
|
|
@@ -116,7 +116,7 @@ export async function addWriter(input, peer){
|
|
|
116
116
|
signature['hash'] = hash;
|
|
117
117
|
peer.emit('announce', { op : 'append_writer', type: 'addIndexer', key: splitted[splitted.length - 1], value: signature });
|
|
118
118
|
} else if(splitted[0] === '/add_writer') {
|
|
119
|
-
const msg = { type: 'addWriter', key: splitted[splitted.length - 1], nonce : Math.random() }
|
|
119
|
+
const msg = { type: 'addWriter', key: splitted[splitted.length - 1], nonce : Math.random() + '-' + Date.now() }
|
|
120
120
|
const signature = {
|
|
121
121
|
msg: msg
|
|
122
122
|
};
|
package/src/index.js
CHANGED
|
@@ -92,7 +92,7 @@ export class Peer extends ReadyResource {
|
|
|
92
92
|
typeof op.value.dispatch.value !== "undefined" &&
|
|
93
93
|
null === await view.get('sh/'+op.value.dispatch.hash)){
|
|
94
94
|
const verified = _this.wallet.verify(op.value.dispatch.hash, JSON.stringify(op.value.dispatch.value), admin.value);
|
|
95
|
-
if(verified){
|
|
95
|
+
if(verified) {
|
|
96
96
|
await _this.contract_instance.dispatch(op, node, view);
|
|
97
97
|
}
|
|
98
98
|
await view.put('sh/'+op.value.dispatch.hash, '');
|
package/src/protocol.js
CHANGED
|
@@ -30,7 +30,7 @@ class Protocol{
|
|
|
30
30
|
this.base.localWriter !== null &&
|
|
31
31
|
this.tokenized_input !== null)
|
|
32
32
|
{
|
|
33
|
-
this.nonce = Date.now();
|
|
33
|
+
this.nonce = Math.random() + '-' + Date.now();
|
|
34
34
|
const MSBwriter = writer;
|
|
35
35
|
const content_hash = createHash('sha256').update(JSON.stringify(obj)).digest('hex');
|
|
36
36
|
let tx = createHash('sha256').update(
|