Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs
const logger = Logger.create('orbitdb-cli', { color: Logger.Colors.Cyan })
module.exports = (e, displayErrorMessage = true) => {
if (displayErrorMessage) {
console.error('Error:', e.message)
logger.error(e.stack)
} else {
console.error(e.message)
}
process.exit(1)
}
// A helper class to send OGN.
// Used by the payout pipeline.
const BigNumber = require('bignumber.js')
const Logger = require('logplease')
const Token = require('@origin/token/src/token')
Logger.setLogLevel(process.env.LOG_LEVEL || 'INFO')
const logger = Logger.create('tokenDistributor')
// Number of block confirmations required for a transfer to be consider completed.
const NumBlockConfirmation = 3
// Wait up to 10 min for a transaction to get confirmed
const ConfirmationTimeoutSec = 10 * 60
class TokenDistributor {
// Note: we can't use a constructor due to the async call to defaultAccount.
async init(networkId, gasPriceMultiplier) {
this.networkId = networkId
this.gasPriceMultiplier = gasPriceMultiplier
this.token = new Token(networkId)
this.supplier = await this.token.defaultAccount()
this.web3 = this.token.web3
'use strict'
const pSeries = require('p-series')
const PeerMonitor = require('ipfs-pubsub-peer-monitor')
const Logger = require('logplease')
const logger = Logger.create("pubsub", { color: Logger.Colors.Yellow })
Logger.setLogLevel('ERROR')
const maxTopicsOpen = 256
let topicsOpenCount = 0
class IPFSPubsub {
constructor(ipfs, id) {
this._ipfs = ipfs
this._id = id
this._subscriptions = {}
if (this._ipfs.pubsub === null)
logger.error("The provided version of ipfs doesn't have pubsub support. Messages will not be exchanged.")
this._handleMessage = this._handleMessage.bind(this)
// Bump up the number of listeners we can have open,
// Runs periodically and scans active campaigns to update:
// - capUsed: budget used so far.
// - rewardStatus: set to ReadyForCalculation once campaign is over and
// all events during the campaign time window have been verified.
'use strict'
const Logger = require('logplease')
const Sequelize = require('sequelize')
const enums = require('../enums')
const db = require('../models')
const parseArgv = require('../util/args')
Logger.setLogLevel(process.env.LOG_LEVEL || 'INFO')
const logger = Logger.create('verifyEvents', { showTimestamp: false })
class UpdateCampaigns {
constructor(config) {
this.config = config
this.stats = {
numProcessed: 0,
numStatusReady: 0,
numUsedCapUpdated: 0
}
}
// TODO(franck): IMPLEMENT ME
async _updateCapUsed(campaign) {
logger.debug(`Checking capUsed for campaign ${campaign.id}`)
return 0
'use strict'
const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs
const logger = Logger.create('orbitdb-cli-create', { color: Logger.Colors.Green })
const createDatabase = require('../lib/create-database')
const outputTimer = require('../lib/output-timer')
const types = ['eventlog', 'feed', 'docstore', 'keyvalue', 'counter']
exports.command = `create `
exports.aliases = 'new'
exports.desc = `Create a new database. Type can be one of: ${types.join('|')}`
exports.builder = (yargs) => {
return yargs
.usage(`Usage: $0 create <${types.join('|')}>`)
.example('\n$0 create /posts docstore',
'\nCreate a document database called \'/posts\'')
'use strict'
const rmrf = require('rimraf')
const path = require('path')
const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs
const logger = Logger.create('orbitdb-cli-drop', { color: Logger.Colors.Orange })
const openDatabase = require('../lib/open-database')
const outputTimer = require('../lib/output-timer')
const exitOnError = require('../exit-on-error')
/* Export as Yargs command */
exports.command = 'drop yes'
exports.aliases = ['destroy']
exports.desc = 'Remove a database locally. This doesn\'t remove data on other nodes that have the removed database replicated.'
exports.builder = (yargs) => {
return yargs
.usage(`Usage: $0 drop yes`)
}
'use strict'
const openDatabase = require('../lib/open-database')
const outputTimer = require('../lib/output-timer')
const exitOnError = require('../exit-on-error')
const search = require('../lib/docstore/search')
const replicate = require('../lib/replication-loop')
const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs
const logger = Logger.create('get', { color: Logger.Colors.Magenta })
/* Export as Yargs command */
exports.command = 'get []'
exports.aliases = ['query', 'search']
exports.desc = 'Query the database.\n'
exports.builder = (yargs) => {
return yargs
.usage('This command is used to query a database in orbit-db.\n' +
'\nUsage: $0 get|search|query []')
.example('\n$0 get /posts',
'\nQuery all results from /posts when /posts is an eventlog')
.example('\n$0 get /posts --limit 1',
'\nQuery the latest event from /posts when /posts is an eventlog')
.example('\n$0 search /users QmFoo1',
'use strict'
const Logger = require('logplease')
Logger.setLogLevel('DEBUG')
module.exports = Logger.create('origin-dapp-creator-server', {
color: Logger.Colors.Green
})
'use strict'
const Logger = require('logplease')
Logger.setLogLevel('DEBUG')
module.exports = Logger.create('origin-ipfs-proxy', {
color: Logger.Colors.Yellow
})
'use strict'
const Logger = require('logplease')
Logger.setLogLevel('DEBUG')
module.exports = Logger.create('origin-messaging', {
color: Logger.Colors.Yellow
})