Skip to content

Commit

Permalink
Merge pull request #497 from DemocracyEarth/simplelogger
Browse files Browse the repository at this point in the history
Updates all NPM packages
  • Loading branch information
santisiri authored Feb 10, 2020
2 parents a5cd0ac + 5c50ca6 commit f7821ac
Show file tree
Hide file tree
Showing 7 changed files with 2,541 additions and 7,386 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ const _setReplicaScore = (user) => {
}
};


/**
* @summary general function to call oracles
*/
const _oracleReplicas = () => {
const pendingReplicas = Meteor.users.find({ 'profile.replica': { $exists: false } }).fetch();
log(`[oracle] Refreshing replica scores for ${pendingReplicas.length} users...`);
Expand Down
2 changes: 0 additions & 2 deletions imports/ui/templates/layout/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Buckminster Fuller, Great San Francisco Architect.
A Roma, <3
*/

/* global alert */

import { Meteor } from 'meteor/meteor';
Expand Down
21 changes: 21 additions & 0 deletions lib/dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import { getEvents, syncDAOGuilds, getBlockHeight } from '/lib/web3';
import { log, defaults } from '/lib/const';
import { Contracts } from '/imports/api/contracts/Contracts';
import { Tokens } from '/imports/api/tokens/tokens';
import { oracleReplicas } from '/imports/startup/both/modules/oracles';

import { CronJob } from 'cron';

const daoCollectives = [];
let lastServerSyncedBlock = 0;
let finishedSetup = false;

const _daoToCollective = (dao) => {
Collectives.insert(dao, (error, result) => {
Expand Down Expand Up @@ -178,6 +182,7 @@ const _setupDAOs = async () => {
await _insertDAOs().then(async (res) => {
if (res) {
await _refresh();
finishedSetup = true;
}
});
};
Expand All @@ -187,8 +192,24 @@ const _main = async () => {
await _setupDAOs();
};


if (Meteor.isServer) {
_main();

const cronjob = new CronJob({
cronTime: defaults.CRON_JOB_TIMER,
onTick: Meteor.bindEnvironment(async () => {
if (finishedSetup) {
log('[cron] Syncing with blockchain...');
await _refresh();
oracleReplicas();
} else {
log('[cron] Awaiting setup to finish...');
}
}),
start: true,
});
log(`[startup] Cron job started with schedule: '${cronjob.cronTime}'`);
}

export const computeDAOStats = _computeDAOStats;
Expand Down
4 changes: 2 additions & 2 deletions lib/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ const _writeEvents = async (event, smartContract, state, collectiveId) => {
*/
const _getStructLength = async (dao, lengthGetter) => {
let result;
await dao.methods[lengthGetter].call({}, (err, res) => {
await dao.methods[lengthGetter]().call({}, (err, res) => {
if (err) {
log(err);
}
Expand Down Expand Up @@ -907,7 +907,7 @@ const _getState = async (smartContract) => {
default:
log(`[web3] Getting information for method ${smartContract.parameter[i].name}...`);
if (dao.methods[smartContract.parameter[i].name]) {
await dao.methods[smartContract.parameter[i].name].call({}, (err, res) => {
await dao.methods[smartContract.parameter[i].name]().call({}, (err, res) => {
if (err) {
log(err);
}
Expand Down
Loading

0 comments on commit f7821ac

Please sign in to comment.