-
Notifications
You must be signed in to change notification settings - Fork 0
/
sess.js
37 lines (25 loc) · 1.03 KB
/
sess.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
function generate_request(did, service){
console.log('generating request # for ' + did)
if (typeof outstanding_requests[did] === 'undefined') {
console.log('creating new request space for ' + did)
outstanding_requests[did] = {}
}
var randy = gen_somewhat_random(REQUEST_BYTES)
// probably housekeeping error, aka bug
if (typeof outstanding_requests[did][randy] != 'undefined') {
console.warn('request number already used...?')
// try once more, if this doesn't work, something is screwed, I'd wager
randy = gen_somewhat_random(REQUEST_BYTES)
if (typeof outstanding_requests[did][randy] != 'undefined') {
console.error('request number generation failed, abort, abort...')
return 0
}
}
var request = {}
request.time = (new Date).getTime()
request.service = service
outstanding_requests[did][randy] = request
console.log(JSON.stringify(outstanding_requests))
console.log('coolio')
return randy
}