Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
/**
* @module computation-service
*/
const common = require('coinstac-common');
const Computation = common.models.computation.Computation;
const crypto = require('crypto');
const deepEqual = require('deep-equal');
const getSyncedDatabase = common.utils.getSyncedDatabase;
const ModelService = require('../model-service');
const RemoteComputationResult = common.models.computation.RemoteComputationResult;
/**
* @extends ModelService
*/
class ComputationService extends ModelService {
modelServiceHooks() { // eslint-disable-line class-methods-use-this
return {
dbName: 'computations',
ModelType: Computation,
};
}
/**
function getAllDocuments(dbRegistry, dbName) {
const getSyncedDatabase = coinstacCommon.utils.getSyncedDatabase;
return getSyncedDatabase(dbRegistry, dbName).then((database) => {
const operation = retry.operation({
maxTimeout: 3000,
minTimeout: 250,
retries: 5,
});
return new Promise((resolve, reject) => {
operation.attempt((currentAttempt) => {
database.all()
.then((docs) => {
if (!docs.length) {
throw new Error(`${dbName} database contains no documents`);
}
'use strict';
const common = require('coinstac-common');
const find = require('lodash/find');
const matchesProperty = require('lodash/matchesProperty');
const getSyncedDatabase = common.utils.getSyncedDatabase;
/**
* @abstract
* @property {DBRegistry} this.dbs
* @property {Pouchy} this.db
* @property {Function} this.ModelType
*/
class ModelService {
/**
* model-service base class. abstracts common model methods
* @param {object} opts
* @param {DBRegistry} opts.dbRegistry
* @param {CoinstacClient} opts.client
*/
constructor(opts) {