-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.js
More file actions
63 lines (58 loc) · 2.05 KB
/
test2.js
File metadata and controls
63 lines (58 loc) · 2.05 KB
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
55
56
57
58
59
60
61
62
63
const { setTimeout: setTimeoutPromise } = require('node:timers/promises');
let ac2 = new AbortController();
let signal = ac2.signal;
// let signal2 = ac.signal;
const MIN = 1000;
// setTimeout(()=>{
// console.log('here0')
// },1000)
// setTimeoutPromise(1000, null, {signal})
// .then(()=>{
// // time out: end proposal/voting
// console.log('here')
// // setTimeoutPromise(1000, null)
// // .then(()=>{
// // // time out: end proposal/voting
// // console.log('here2')
// // })
// })
// .catch((err) => {
// // lobe owner voted / all members voted, stop timer
// if (err.name === 'AbortError'){
// console.log(`app CreatedProposal: receive lobe owner voting signal, invoking EndProposal`)
// // // contract.submitTransaction('EndProposal', proposalID, lobeOwnerResult);
// }
// });
// ac.abort();
// a = [1,2]
// b = [3,4]
// c = a.concat(b)
// console.log(a)
// let s = `You successfully create a proposal! ProposalID:proposal5`
// console.log(s.substring(s.indexOf('ProposalID:')+'ProposalID:'.length))
setTimeoutPromise(MIN, null, {signal} )
.then(()=>{
console.log(`INFO app createdProposal: no lobe owner voting in 1 min, expert voting available within 1 min`);
// chaincode checks the time interval
// start expert voting timer: 48 h
setTimeoutPromise(MIN, null, {signal} )
.then(()=>{
// time out: proposal closed
console.log(`INFO app createdProposal: expert voting expired`);
// return contract.submitTransaction('ProposalVoteResult', proposalID, 'true');
})
.catch((err) => {
// lobe owner voted / all members voted, stop timer
if (err.name === 'AbortError'){
console.log(`2`)
// contract.submitTransaction('EndProposal', proposalID, lobeOwnerResult);
}
});
})
.catch((err)=>{
if (err.name === 'AbortError'){
// console.log(`app CreatedProposal: receive lobe owner voting signal, invoking EndProposal`)
// // contract.submitTransaction('EndProposal', proposalID, lobeOwnerResult);
}
});
ac2.abort();