link.js
1 2 // const cron = require('cron') 3 import events from './events.js' 4 import state from './state.js' 5 const {serverState} = state 6 //import connector from './connector.js' 7 import calculations from '../calculations.js' 8 9 // const syncLink = new cron.CronJob({ 10 // cronTime: '* * * * *', 11 // onTick: sync, 12 // start: false, 13 // timeZone: 'America/Los_Angeles' 14 // }) 15 16 function sortAddresses(a,b){ 17 if (a < b){ 18 return a + ':' + b 19 } 20 return b + ':' + a 21 } 22 23 function sync(){ 24 serverState.ao.forEach(a => { 25 console.log('syncing ', a) 26 // a.links.forEach(l => { 27 // let crawlered = calculations.crawler(serverState.tasks, l) 28 // let expectedHash = calculations.crawlerHash(serverState.tasks, l) 29 // connector.checkHash(a.address, a.outboundSecret, l, hashRes => { 30 // if (expectedHash !== hashRes){ 31 // connector.postEvent(a.address, a.outboundSecret, { 32 // type: 'tasks-received', 33 // tasks: getList(crawlered) 34 // }, (connectorRes) => { 35 // // console.log("ao relay response", {connectorRes}) 36 // }) 37 // } 38 // }) 39 // }) 40 }) 41 } 42 43 function getList(taskIds){ 44 return serverState.tasks.filter(t => taskIds.indexOf(t.taskId) > -1) 45 } 46 47 export default function (){ 48 // syncLink.start() 49 }