-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.js
30 lines (21 loc) · 915 Bytes
/
service.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
console.log("If module not found, install express globally `npm i express -g`!");
var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.VCAP_APP_PORT || process.env.PORT || process.argv[2] || 8765;
var express = require('express');
var Gun = require('gun');
var app = express();
app.use(Gun.serve);
app.use(express.static(__dirname));
var server = app.listen(port);
var gun = Gun({ file: 'data', web: server });
global.Gun = Gun; /// make global to `node --inspect` - debug only
global.gun = gun; /// make global to `node --inspect` - debug only
console.log('Server started on port ' + port + ' with /gun');
let evidence = gun.get('evidence3').put(null);
// Emulate event stream
for (let i = 0; i < 10000; i++) {
setTimeout(function () {
const txrecord = { txhash: i, filehash: i, metadata: 'test' }
evidence.put( txrecord );
console.log(i);
}, 2000 * i);
}