diff --git a/app/lib/constants.ts b/app/lib/constants.ts index 26180e81d5fb6efe6799f0096f9a914b0091d885..6de53d349a025efb22f3be7cc62ecb497e2a7385 100644 --- a/app/lib/constants.ts +++ b/app/lib/constants.ts @@ -1,6 +1,7 @@ "use strict"; import {CommonConstants} from "./common-libs/constants" import {OtherConstants} from "./other_constants" +import { ProverConstants } from '../modules/prover/lib/constants'; const UDID2 = "udid2;c;([A-Z-]*);([A-Z-]*);(\\d{4}-\\d{2}-\\d{2});(e\\+\\d{2}\\.\\d{2}(\\+|-)\\d{3}\\.\\d{2});(\\d+)(;?)"; const PUBKEY = CommonConstants.FORMATS.PUBKEY @@ -114,7 +115,11 @@ module.exports = { }, PROOF_OF_WORK: { EVALUATION: 1000, - UPPER_BOUND: CommonConstants.PROOF_OF_WORK.UPPER_BOUND.slice() + UPPER_BOUND: CommonConstants.PROOF_OF_WORK.UPPER_BOUND.slice(), + DEFAULT: { + CPU: ProverConstants.DEFAULT_CPU, + PREFIX: ProverConstants.DEFAULT_PEER_ID + } }, DEFAULT_CURRENCY_NAME: "no_currency", diff --git a/app/lib/dal/fileDAL.ts b/app/lib/dal/fileDAL.ts index db28e72c5f3f3721e7247116a87a624fc6575974..a79dc8d8dabfe41814656c40f7f9d9b5297afebd 100644 --- a/app/lib/dal/fileDAL.ts +++ b/app/lib/dal/fileDAL.ts @@ -759,7 +759,7 @@ export class FileDAL { } saveTransaction(tx:DBTx) { - return this.txsDAL.addPending(TransactionDTO.fromJSONObject(tx)) + return this.txsDAL.addPending(tx) } async getTransactionsHistory(pubkey:string) { diff --git a/app/lib/dal/sqliteDAL/CertDAL.ts b/app/lib/dal/sqliteDAL/CertDAL.ts index d854ef16b44668efdd2fbefa75c4f676a2b2b122..d12774e5721706c8756f6e9c29a9101ac1cd9680 100644 --- a/app/lib/dal/sqliteDAL/CertDAL.ts +++ b/app/lib/dal/sqliteDAL/CertDAL.ts @@ -1,10 +1,11 @@ import {SQLiteDriver} from "../drivers/SQLiteDriver" import {AbstractSQLite} from "./AbstractSQLite" -import {SandBox} from "./SandBox" +import { SandBox } from './SandBox'; +import { DBDocument } from './DocumentDAL'; const constants = require('../../constants'); -export interface DBCert { +export interface DBCert extends DBDocument { linked:boolean written:boolean written_block:null diff --git a/app/lib/dal/sqliteDAL/DocumentDAL.ts b/app/lib/dal/sqliteDAL/DocumentDAL.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2097d7f025f31ee507e1b83051bfd36ca3f2f55 --- /dev/null +++ b/app/lib/dal/sqliteDAL/DocumentDAL.ts @@ -0,0 +1,3 @@ +export interface DBDocument { + issuers?: string[] +} \ No newline at end of file diff --git a/app/lib/dal/sqliteDAL/IdentityDAL.ts b/app/lib/dal/sqliteDAL/IdentityDAL.ts index c23f6be99df73a7d0ba3a8efb07e283a2acd7cfb..364eb00cd1e822b82e0c590a491154a160641a11 100644 --- a/app/lib/dal/sqliteDAL/IdentityDAL.ts +++ b/app/lib/dal/sqliteDAL/IdentityDAL.ts @@ -1,8 +1,9 @@ import {AbstractSQLite} from "./AbstractSQLite" import {SQLiteDriver} from "../drivers/SQLiteDriver" -import {SandBox} from "./SandBox" +import { SandBox } from './SandBox'; import {IdentityDTO} from "../../dto/IdentityDTO" import {Cloneable} from "../../dto/Cloneable"; +import { DBDocument } from './DocumentDAL'; const constants = require('../../constants'); export abstract class DBIdentity implements Cloneable { @@ -143,7 +144,7 @@ export class ExistingDBIdentity extends DBIdentity { } } -export interface DBSandboxIdentity extends DBIdentity { +export interface DBSandboxIdentity extends DBIdentity,DBDocument { certsCount: number ref_block: number } diff --git a/app/lib/dal/sqliteDAL/MembershipDAL.ts b/app/lib/dal/sqliteDAL/MembershipDAL.ts index 61ce346e9f9580716d482edd346caf0e7bd3f864..110ed1429ef627d114a54b2937d09396d92c0416 100644 --- a/app/lib/dal/sqliteDAL/MembershipDAL.ts +++ b/app/lib/dal/sqliteDAL/MembershipDAL.ts @@ -1,10 +1,11 @@ import {SQLiteDriver} from "../drivers/SQLiteDriver"; import {AbstractSQLite} from "./AbstractSQLite"; -import {SandBox} from "./SandBox"; +import { SandBox } from './SandBox'; +import { DBDocument } from './DocumentDAL'; const _ = require('underscore'); const constants = require('../../constants'); -export interface DBMembership { +export interface DBMembership extends DBDocument { membership: string issuer: string number: number diff --git a/app/lib/dal/sqliteDAL/SandBox.ts b/app/lib/dal/sqliteDAL/SandBox.ts index c84f9a87fdd1f78ec24ade5dde70d001a536dd84..09431c3aada77ab98f4282737d0270eb5be85ff3 100644 --- a/app/lib/dal/sqliteDAL/SandBox.ts +++ b/app/lib/dal/sqliteDAL/SandBox.ts @@ -1,4 +1,6 @@ -export class SandBox<T> { +import {DBDocument} from './DocumentDAL'; + +export class SandBox<T extends DBDocument> { maxSize:number @@ -10,8 +12,9 @@ export class SandBox<T> { this.maxSize = maxSize || 10 } - async acceptNewSandBoxEntry(element:any, pubkey:string) { - if (element.pubkey === pubkey) { + async acceptNewSandBoxEntry(element:T, pubkey:string) { + // Accept any document which has the exception pubkey (= the node pubkey) + if (element.issuers !== undefined && element.issuers.indexOf(pubkey) !== -1) { return true; } const elements = await this.findElements() diff --git a/app/lib/dal/sqliteDAL/TxsDAL.ts b/app/lib/dal/sqliteDAL/TxsDAL.ts index b6330cb934f2f89f89554d6bca7443d0c7fa2bc3..dbc82ca99d71528ad6fb65580a21d12318ef574d 100644 --- a/app/lib/dal/sqliteDAL/TxsDAL.ts +++ b/app/lib/dal/sqliteDAL/TxsDAL.ts @@ -169,12 +169,10 @@ export class TxsDAL extends AbstractSQLite<DBTx> { return this.saveEntity(dbTx) } - addPending(tx:TransactionDTO) { - const dbTx = DBTx.fromTransactionDTO(tx) + addPending(dbTx:DBTx) { dbTx.received = moment().unix() dbTx.written = false dbTx.removed = false - dbTx.hash = tx.getHash() return this.saveEntity(dbTx) } diff --git a/app/lib/dto/ConfDTO.ts b/app/lib/dto/ConfDTO.ts index 2614318afcc81c1d2be8a4ce96929ac110932c34..2e77e92fc70336c82b99bbb7b908ee9251918d09 100644 --- a/app/lib/dto/ConfDTO.ts +++ b/app/lib/dto/ConfDTO.ts @@ -64,9 +64,9 @@ export interface NetworkConfDTO { export interface WS2PConfDTO { ws2p?: { - privateAccess: boolean - publicAccess: boolean - uuid: string + privateAccess?: boolean + publicAccess?: boolean + uuid?: string upnp?: boolean remotehost?: string|null remoteport?: number|null @@ -131,6 +131,7 @@ export class ConfDTO implements CurrencyConfDTO, KeypairConfDTO, NetworkConfDTO, public remotehost: string|null, public remoteipv4: string|null, public remoteipv6: string|null, + public host: string, public port: number, public ipv4: string, public ipv6: string, @@ -142,9 +143,9 @@ export class ConfDTO implements CurrencyConfDTO, KeypairConfDTO, NetworkConfDTO, public bmaWithCrawler: boolean, public proxiesConf: ProxiesConf|undefined, public ws2p?: { - privateAccess: boolean - publicAccess: boolean - uuid: string + privateAccess?: boolean + publicAccess?: boolean + uuid?: string upnp?: boolean remotehost?: string|null remoteport?: number|null @@ -161,10 +162,11 @@ export class ConfDTO implements CurrencyConfDTO, KeypairConfDTO, NetworkConfDTO, ) {} static mock() { - return new ConfDTO("", "", [], [], 0, 0, 0.6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, false, 0, 0, 0, 0, 0, { pub:'', sec:'' }, null, "", "", 0, "", "", "", 0, "", "", null, false, "", true, false, true, undefined) + return new ConfDTO("", "", [], [], 0, 3600 * 1000, constants.PROOF_OF_WORK.DEFAULT.CPU, 1, constants.PROOF_OF_WORK.DEFAULT.PREFIX, 0, 0, constants.CONTRACT.DEFAULT.C, constants.CONTRACT.DEFAULT.DT, constants.CONTRACT.DEFAULT.DT_REEVAL, 0, constants.CONTRACT.DEFAULT.UD0, 0, 0, constants.CONTRACT.DEFAULT.STEPMAX, constants.CONTRACT.DEFAULT.SIGPERIOD, 0, constants.CONTRACT.DEFAULT.SIGVALIDITY, constants.CONTRACT.DEFAULT.MSVALIDITY, constants.CONTRACT.DEFAULT.SIGQTY, constants.CONTRACT.DEFAULT.SIGSTOCK, constants.CONTRACT.DEFAULT.X_PERCENT, constants.CONTRACT.DEFAULT.PERCENTROT, constants.CONTRACT.DEFAULT.POWDELAY, constants.CONTRACT.DEFAULT.AVGGENTIME, constants.CONTRACT.DEFAULT.MEDIANTIMEBLOCKS, false, 3000, false, constants.BRANCHES.DEFAULT_WINDOW_SIZE, constants.CONTRACT.DEFAULT.IDTYWINDOW, constants.CONTRACT.DEFAULT.MSWINDOW, constants.CONTRACT.DEFAULT.SIGWINDOW, 0, { pub:'', sec:'' }, null, "", "", 0, "", "", "", "", 0, "", "", null, false, "", true, true, false, new ProxiesConf(), undefined) } static defaultConf() { + /*return new ConfDTO("", "", [], [], 0, 3600 * 1000, constants.PROOF_OF_WORK.DEFAULT.CPU, 1, constants.PROOF_OF_WORK.DEFAULT.PREFIX, 0, 0, constants.CONTRACT.DEFAULT.C, constants.CONTRACT.DEFAULT.DT, constants.CONTRACT.DEFAULT.DT_REEVAL, 0, constants.CONTRACT.DEFAULT.UD0, 0, 0, constants.CONTRACT.DEFAULT.STEPMAX, constants.CONTRACT.DEFAULT.SIGPERIOD, 0, constants.CONTRACT.DEFAULT.SIGVALIDITY, constants.CONTRACT.DEFAULT.MSVALIDITY, constants.CONTRACT.DEFAULT.SIGQTY, constants.CONTRACT.DEFAULT.SIGSTOCK, constants.CONTRACT.DEFAULT.X_PERCENT, constants.CONTRACT.DEFAULT.PERCENTROT, constants.CONTRACT.DEFAULT.POWDELAY, constants.CONTRACT.DEFAULT.AVGGENTIME, constants.CONTRACT.DEFAULT.MEDIANTIMEBLOCKS, false, 3000, false, constants.BRANCHES.DEFAULT_WINDOW_SIZE, constants.CONTRACT.DEFAULT.IDTYWINDOW, constants.CONTRACT.DEFAULT.MSWINDOW, constants.CONTRACT.DEFAULT.SIGWINDOW, 0, { pub:'', sec:'' }, null, "", "", 0, "", "", "", "", 0, "", "", null, false, "", true, true)*/ return { "currency": null, "endpoints": [], diff --git a/app/modules/prover/index.ts b/app/modules/prover/index.ts index d4b138265bf301c2e08b5bca2e39c3670e73261f..856e1423761bde02af8b9da064ffb307c0b65d18 100644 --- a/app/modules/prover/index.ts +++ b/app/modules/prover/index.ts @@ -1,6 +1,6 @@ import {ConfDTO} from "../../lib/dto/ConfDTO" import {BlockGenerator, BlockGeneratorWhichProves} from "./lib/blockGenerator" -import {Constants} from "./lib/constants" +import {ProverConstants} from "./lib/constants" import {BlockProver} from "./lib/blockProver" import {Prover} from "./lib/prover" import {Contacter} from "../crawler/lib/contacter" @@ -19,18 +19,18 @@ export const ProverDependency = { config: { onLoading: async (conf:ConfDTO) => { if (conf.cpu === null || conf.cpu === undefined) { - conf.cpu = Constants.DEFAULT_CPU; + conf.cpu = ProverConstants.DEFAULT_CPU; } if (conf.nbCores === null || conf.nbCores === undefined) { - conf.nbCores = Math.min(Constants.CORES_MAXIMUM_USE_IN_PARALLEL, require('os').cpus().length) + conf.nbCores = Math.min(ProverConstants.CORES_MAXIMUM_USE_IN_PARALLEL, require('os').cpus().length) } else if (conf.nbCores <= 0) { conf.nbCores = 1 } if (conf.prefix === null || conf.prefix === undefined) { - conf.prefix = Constants.DEFAULT_PEER_ID; + conf.prefix = ProverConstants.DEFAULT_PEER_ID; } - conf.powSecurityRetryDelay = Constants.POW_SECURITY_RETRY_DELAY; - conf.powMaxHandicap = Constants.POW_MAXIMUM_ACCEPTABLE_HANDICAP; + conf.powSecurityRetryDelay = ProverConstants.POW_SECURITY_RETRY_DELAY; + conf.powMaxHandicap = ProverConstants.POW_MAXIMUM_ACCEPTABLE_HANDICAP; }, beforeSave: async (conf:ConfDTO) => { delete conf.powSecurityRetryDelay; diff --git a/app/modules/prover/lib/blockProver.ts b/app/modules/prover/lib/blockProver.ts index 1c68518f7947d2fd0eb71c009488eec5250b02ae..9cd215d98d478a456857b52f9f5c5388e1afa153 100644 --- a/app/modules/prover/lib/blockProver.ts +++ b/app/modules/prover/lib/blockProver.ts @@ -1,4 +1,4 @@ -import {Constants} from "./constants" +import {ProverConstants} from "./constants" import {Server} from "../../../../server" import {PowEngine} from "./engine" import {DBBlock} from "../../../lib/db/DBBlock" @@ -165,7 +165,7 @@ export class BlockProver { // Start powFarm.setOnAlmostPoW((pow:any, matches:any, aBlock:any, found:boolean) => { this.powEvent(found, pow); - if (matches && matches[1].length >= Constants.MINIMAL_ZEROS_TO_SHOW_IN_LOGS) { + if (matches && matches[1].length >= ProverConstants.MINIMAL_ZEROS_TO_SHOW_IN_LOGS) { this.logger.info('Matched %s zeros %s with Nonce = %s for block#%s by %s', matches[1].length, pow, aBlock.nonce, aBlock.number, aBlock.issuer.slice(0,6)); } }); diff --git a/app/modules/prover/lib/constants.ts b/app/modules/prover/lib/constants.ts index 0602e7de87009833c41fccff032fd1c6b9d8e137..0a454d38fd9c85e58115c2f971bbb6cb1cea812e 100644 --- a/app/modules/prover/lib/constants.ts +++ b/app/modules/prover/lib/constants.ts @@ -1,4 +1,4 @@ -export const Constants = { +export const ProverConstants = { CORES_MAXIMUM_USE_IN_PARALLEL: 8, diff --git a/app/modules/prover/lib/engine.ts b/app/modules/prover/lib/engine.ts index 352de59c7490a1b08aebf6bc60f0a8d25d866105..cc83f46822764786bf91c1c02156c597966cc299 100644 --- a/app/modules/prover/lib/engine.ts +++ b/app/modules/prover/lib/engine.ts @@ -1,4 +1,4 @@ -import {Constants} from "./constants" +import {ProverConstants} from "./constants" import {Master as PowCluster} from "./powCluster" import {ConfDTO} from "../../../lib/dto/ConfDTO" diff --git a/app/modules/prover/lib/powCluster.ts b/app/modules/prover/lib/powCluster.ts index 1e1a6ad3d42afadf5c750a378426d8e7ab50df70..4d4820777cb9b279aebea2d09680d1be0b3aab1f 100644 --- a/app/modules/prover/lib/powCluster.ts +++ b/app/modules/prover/lib/powCluster.ts @@ -1,5 +1,5 @@ import {ConfDTO} from "../../../lib/dto/ConfDTO" -import {Constants} from "./constants" +import {ProverConstants} from "./constants" const _ = require('underscore') const nuuid = require('node-uuid'); @@ -84,7 +84,7 @@ export class Master { })(), // Each worker has his own chunk of possible nonces - nonceBeginning: this.nbCores === 1 ? 0 : (index + 1) * Constants.NONCE_RANGE + nonceBeginning: this.nbCores === 1 ? 0 : (index + 1) * ProverConstants.NONCE_RANGE } return this.slavesMap[worker.id] }) diff --git a/app/modules/prover/lib/proof.ts b/app/modules/prover/lib/proof.ts index cc60a584fec95dae212da94306d05c828ffcff1a..9b15c0be5aaff08b078c5dd495dbb0432be983ea 100644 --- a/app/modules/prover/lib/proof.ts +++ b/app/modules/prover/lib/proof.ts @@ -2,7 +2,7 @@ import {LOCAL_RULES_HELPERS} from "../../../lib/rules/local_rules" import {hashf} from "../../../lib/common" import {DBBlock} from "../../../lib/db/DBBlock" import {ConfDTO} from "../../../lib/dto/ConfDTO" -import {Constants} from "./constants" +import {ProverConstants} from "./constants" import {KeyGen} from "../../../lib/common-libs/crypto/keyring" import {dos2unix} from "../../../lib/common-libs/dos2unix" import {rawer} from "../../../lib/common-libs/index" @@ -84,10 +84,10 @@ function beginNewProofOfWork(stuff:any) { const nbZeros = stuff.zeros; const pair = stuff.pair; const forcedTime = stuff.forcedTime; - currentCPU = conf.cpu || Constants.DEFAULT_CPU; + currentCPU = conf.cpu || ProverConstants.DEFAULT_CPU; prefix = parseInt(conf.prefix || prefix) - if (prefix && prefix < Constants.NONCE_RANGE) { - prefix *= 100 * Constants.NONCE_RANGE + if (prefix && prefix < ProverConstants.NONCE_RANGE) { + prefix *= 100 * ProverConstants.NONCE_RANGE } const highMark = stuff.highMark; const turnDuration = stuff.turnDuration || TURN_DURATION_IN_MILLISEC @@ -184,7 +184,7 @@ function beginNewProofOfWork(stuff:any) { if (charOK) { found = !!(pow[nbZeros].match(new RegExp('[0-' + highMark + ']'))) } - if (!found && nbZeros > 0 && j - 1 >= Constants.POW_MINIMAL_TO_SHOW) { + if (!found && nbZeros > 0 && j - 1 >= ProverConstants.POW_MINIMAL_TO_SHOW) { pSend({ pow: { pow: pow, block: block, nbZeros: nbZeros }}); } diff --git a/app/modules/ws2p/lib/WS2PCluster.ts b/app/modules/ws2p/lib/WS2PCluster.ts index f41ad9cb297093ab957e04d9a4e6652266a79e27..bb76f0b4a44d53e6209b90f4232a49af16116c20 100644 --- a/app/modules/ws2p/lib/WS2PCluster.ts +++ b/app/modules/ws2p/lib/WS2PCluster.ts @@ -15,7 +15,7 @@ import {WS2PServerMessageHandler} from "./interface/WS2PServerMessageHandler" import {WS2PMessageHandler} from "./impl/WS2PMessageHandler" import { CommonConstants } from '../../../lib/common-libs/constants'; import { Package } from "../../../lib/common/package"; -import { Constants } from "../../prover/lib/constants"; +import { ProverConstants } from "../../prover/lib/constants"; import { ProxiesConf } from '../../../lib/proxy'; const es = require('event-stream') @@ -472,7 +472,7 @@ export class WS2PCluster { const software = 'duniter' const softVersion = Package.getInstance().version const ws2pId = (this.server.conf.ws2p && this.server.conf.ws2p.uuid) || '00000000' - const prefix = this.server.conf.prefix || Constants.DEFAULT_PEER_ID + const prefix = this.server.conf.prefix || ProverConstants.DEFAULT_PEER_ID const message = `${api}:HEAD:1:${pub}:${number}-${hash}:${ws2pId}:${software}:${softVersion}:${prefix}` const sig = key.signSync(message) return { sig, message, pub } diff --git a/app/service/IdentityService.ts b/app/service/IdentityService.ts index 81288451dc47dda3de811b1cc02c104d8f994b94..e052aa29a0c04e3172adea6ae0eb044cae15d554 100644 --- a/app/service/IdentityService.ts +++ b/app/service/IdentityService.ts @@ -115,7 +115,7 @@ export class IdentityService extends FIFOService { await GLOBAL_RULES_FUNCTIONS.checkIdentitiesAreWritable({ identities: [idtyObj.inline()], version: (current && current.version) || constants.BLOCK_GENERATED_VERSION }, this.conf, this.dal); if (byAbsorption !== BY_ABSORPTION) { if (!(await this.dal.idtyDAL.sandbox.acceptNewSandBoxEntry({ - pubkey: idty.pubkey, + issuers: [idty.pubkey], ref_block: parseInt(idty.buid.split('-')[0]) }, this.conf.pair && this.conf.pair.pub))) { throw constants.ERRORS.SANDBOX_FOR_IDENTITY_IS_FULL; @@ -166,6 +166,7 @@ export class IdentityService extends FIFOService { }; } const mCert:DBCert = { + issuers: [cert.from], from: cert.from, sig: cert.sig, block_number: cert.block_number, @@ -239,7 +240,7 @@ export class IdentityService extends FIFOService { const idty = IdentityDTO.fromRevocation(revoc); idty.revocation_sig = revoc.revocation; if (!(await this.dal.idtyDAL.sandbox.acceptNewSandBoxEntry({ - pubkey: idty.pubkey, + issuers: [idty.pubkey], ref_block: parseInt(idty.buid.split('-')[0]), certsCount: 0 }, this.conf.pair && this.conf.pair.pub))) { diff --git a/app/service/MembershipService.ts b/app/service/MembershipService.ts index fd27d3d24873ec524b77c2abe855254c405e7248..1cbb2d73cf10bfd00e63619abc638f854bc92a63 100644 --- a/app/service/MembershipService.ts +++ b/app/service/MembershipService.ts @@ -56,13 +56,14 @@ export class MembershipService extends FIFOService { const current = await this.dal.getCurrentBlockOrNull(); const basedBlock = await GLOBAL_RULES_HELPERS.checkMembershipBlock(entry, current, this.conf, this.dal); if (!(await this.dal.msDAL.sandbox.acceptNewSandBoxEntry({ - pubkey: entry.pubkey, + issuers: [entry.pubkey], block_number: entry.block_number }, this.conf.pair && this.conf.pair.pub))) { throw constants.ERRORS.SANDBOX_FOR_MEMERSHIP_IS_FULL; } // Saves entry await this.dal.savePendingMembership({ + issuers: [entry.pubkey], membership: entry.membership, issuer: entry.issuer, number: entry.number, diff --git a/app/service/TransactionsService.ts b/app/service/TransactionsService.ts index ab144b243d20b433221959e1eedf2444ad2ac30c..e6ddf1263234920e509ca684438cc19cec1ecb5f 100644 --- a/app/service/TransactionsService.ts +++ b/app/service/TransactionsService.ts @@ -46,7 +46,7 @@ export class TransactionService extends FIFOService { await GLOBAL_RULES_HELPERS.checkSingleTransaction(dto, nextBlockWithFakeTimeVariation, this.conf, this.dal, CHECK_PENDING_TRANSACTIONS); const server_pubkey = this.conf.pair && this.conf.pair.pub; if (!(await this.dal.txsDAL.sandbox.acceptNewSandBoxEntry({ - pubkey: tx.issuers.indexOf(server_pubkey) !== -1 ? server_pubkey : '', + issuers: tx.issuers, output_base: tx.output_base, output_amount: tx.output_amount }, server_pubkey))) { diff --git a/index.ts b/index.ts index 1086b3aa0bf52983a3c3e05514da232dd6a974c4..ecf7be9d67231df6e4e63ef96c903457272b675d 100644 --- a/index.ts +++ b/index.ts @@ -7,7 +7,7 @@ import {KeypairDependency} from "./app/modules/keypair/index" import {CrawlerDependency} from "./app/modules/crawler/index" import {BmaDependency} from "./app/modules/bma/index" import {WS2PDependency} from "./app/modules/ws2p/index" -import {Constants} from "./app/modules/prover/lib/constants" +import {ProverConstants} from "./app/modules/prover/lib/constants" import { ProxiesConf } from './app/lib/proxy'; const path = require('path'); @@ -486,7 +486,7 @@ function commandLineConf(program:any, conf:any = {}) { if (cli.currency) conf.currency = cli.currency; if (cli.server.port) conf.port = cli.server.port; if (cli.cpu) conf.cpu = Math.max(0.01, Math.min(1.0, cli.cpu)); - if (cli.prefix) conf.prefix = Math.max(Constants.MIN_PEER_ID, Math.min(Constants.MAX_PEER_ID, cli.prefix)); + if (cli.prefix) conf.prefix = Math.max(ProverConstants.MIN_PEER_ID, Math.min(ProverConstants.MAX_PEER_ID, cli.prefix)); if (cli.logs.http) conf.httplogs = true; if (cli.logs.nohttp) conf.httplogs = false; if (cli.isolate) conf.isolate = cli.isolate; diff --git a/test/dal/triming.js b/test/dal/triming.js index db2c0cb849343c53b7db558a368729cf7185b440..501ec550e41e568107bbcd4ff9b803038a4e7684 100644 --- a/test/dal/triming.js +++ b/test/dal/triming.js @@ -124,10 +124,6 @@ describe("Triming", function(){ it('should be able to trim the bindex', () => co(function *() { // Triming const server = (yield toolbox.simpleNodeWith2Users({ - pair: { - pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', - sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP' - }, forksize: 9, sigQty: 1, dtDiffEval: 2, diff --git a/test/integration/branches_revert2.js b/test/integration/branches_revert2.js index f5ed04b46d403db7a6e038dbe101fcd5df2b1896..bc85ff5b69d24e2351a9d5710fded4939775ede5 100644 --- a/test/integration/branches_revert2.js +++ b/test/integration/branches_revert2.js @@ -10,7 +10,7 @@ const httpTest = require('./tools/http'); const commit = require('./tools/commit'); const shutDownEngine = require('./tools/shutDownEngine'); -require('../../app/modules/prover/lib/constants').Constants.CORES_MAXIMUM_USE_IN_PARALLEL = 1 +require('../../app/modules/prover/lib/constants').ProverConstants.CORES_MAXIMUM_USE_IN_PARALLEL = 1 require('../../app/modules/bma').BmaDependency.duniter.methods.noLimit(); // Disables the HTTP limiter const expectJSON = httpTest.expectJSON; diff --git a/test/integration/documents-currency.ts b/test/integration/documents-currency.ts index c066ab2a45db115898320eb1a894f793ded8cd0a..a97afd54206967a360beb54e2ba528117ae7c2eb 100644 --- a/test/integration/documents-currency.ts +++ b/test/integration/documents-currency.ts @@ -1,4 +1,7 @@ -import {NewTestingServer} from './tools/toolbox'; +import { NewTestingServer, TestingServer } from './tools/toolbox'; +import { unlock } from '../../app/lib/common-libs/txunlock'; +import { ConfDTO, CurrencyConfDTO } from '../../app/lib/dto/ConfDTO'; +import { Server } from '../../server'; const co = require('co'); const should = require('should'); @@ -15,20 +18,20 @@ describe("Document pool currency", function() { s1 = NewTestingServer({ currency: 'currency_one', pair: { - pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', - sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP' - }, - udTime0: now - 1, - dt: 1, - ud0: 1500 - }); - s2 = NewTestingServer({ - currency: 'currency_two', - pair: { - pub: 'DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo', - sec: '64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F' - } - }); + pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', + sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP' + }, + udTime0: now - 1, + dt: 1, + ud0: 1500 + }); + s2 = NewTestingServer({ + currency: 'currency_two', + pair: { + pub: 'DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo', + sec: '64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F' + } + }); cat1 = new TestUser('cat', { pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'}, { server: s1 }); tac1 = new TestUser('tac', { pub: '2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc', sec: '2HuRLWgKgED1bVio1tdpeXrf7zuUszv1yPHDsDj7kcMC4rVSN9RC58ogjtKNfTbH1eFz7rn38U1PywNs3m6Q7UxE'}, { server: s1 }); diff --git a/test/integration/http_api.js b/test/integration/http_api.js index 088909ecfb74aecafbd7b4eefa3df18412ee8f19..83cd3ccb202b102879c48a2bbed2170436992c67 100644 --- a/test/integration/http_api.js +++ b/test/integration/http_api.js @@ -13,7 +13,7 @@ const shutDownEngine = require('./tools/shutDownEngine'); const rp = require('request-promise'); const ws = require('ws'); -require('../../app/modules/prover/lib/constants').Constants.CORES_MAXIMUM_USE_IN_PARALLEL = 1 +require('../../app/modules/prover/lib/constants').ProverConstants.CORES_MAXIMUM_USE_IN_PARALLEL = 1 let server, server2, cat, toc diff --git a/test/integration/server-shutdown.ts b/test/integration/server-shutdown.ts index 854e20eae037d8e801a7d1fab6b827033b43b0e9..033ef307691e3a2ea9d19c879c69a967fc81fae4 100644 --- a/test/integration/server-shutdown.ts +++ b/test/integration/server-shutdown.ts @@ -1,3 +1,5 @@ +import { ConfDTO } from '../../app/lib/dto/ConfDTO'; +import { setTimeout } from 'timers'; import {NewTestingServer} from "./tools/toolbox" const should = require('should') diff --git a/yarn.lock b/yarn.lock index 1eb4771b3e9bcb9e2754620a0b6c49a056790519..e31a5cf3ec6018745c32e2924443a74d95dfaf8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -51,6 +51,10 @@ acorn@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.1.tgz#53fe161111f912ab999ee887a90a0bc52822fd75" +adm-zip@0.4.7: + version "0.4.7" + resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.7.tgz#8606c2cbf1c426ce8c8ec00174447fd49b6eafc1" + ajv-keywords@^1.0.0: version "1.5.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" @@ -902,6 +906,28 @@ doctrine@^1.2.2: esutils "^2.0.2" isarray "^1.0.0" +duniter-ui@^1.6.13: + version "1.6.13" + resolved "https://registry.yarnpkg.com/duniter-ui/-/duniter-ui-1.6.13.tgz#3f203152fc0e3e1cbae74c1a0353a620c82d72ee" + dependencies: + adm-zip "0.4.7" + body-parser "1.17.1" + co "4.6.0" + cors "2.8.2" + event-stream "3.3.4" + express "4.15.2" + express-fileupload "0.0.5" + fs-extra "2.1.2" + materialize-css "0.98.1" + moment "2.18.1" + node-pre-gyp "0.6.34" + q "1.5.0" + request "2.81.0" + request-promise "4.2.0" + rimraf "2.6.1" + tmp "0.0.31" + underscore "1.8.3" + duplexer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" @@ -1410,6 +1436,13 @@ from@~0: version "0.1.7" resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" +fs-extra@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-2.1.2.tgz#046c70163cef9aad46b0e4a7fa467fb22d71de35" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + fs-extra@^0.22.1: version "0.22.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.22.1.tgz#5fd6f8049dc976ca19eb2355d658173cabcce056" @@ -1577,6 +1610,10 @@ growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" +hammerjs@^2.0.4: + version "2.0.8" + resolved "https://registry.yarnpkg.com/hammerjs/-/hammerjs-2.0.8.tgz#04ef77862cff2bb79d30f7692095930222bf60f1" + handlebars@^4.0.3: version "4.0.10" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" @@ -1997,6 +2034,10 @@ jison@0.4.17: lex-parser "~0.1.3" nomnom "1.5.2" +jquery@^2.1.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-2.2.4.tgz#2c89d6889b5eac522a7eea32c14521559c6cbf02" + js-tokens@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" @@ -2254,6 +2295,14 @@ map-stream@~0.1.0: buffers "~0.1.1" readable-stream "~1.0.0" +materialize-css@0.98.1: + version "0.98.1" + resolved "https://registry.yarnpkg.com/materialize-css/-/materialize-css-0.98.1.tgz#7276895b2c998b53e26deaa0c23a0484c0851d99" + dependencies: + hammerjs "^2.0.4" + jquery "^2.1.4" + node-archiver "^0.3.0" + md5-hex@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-1.3.0.tgz#d2c4afe983c4370662179b8cad145219135046c4" @@ -2482,6 +2531,13 @@ nnupnp@1.0.2: request "2.10.0" xml2js "0.1.14" +node-archiver@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/node-archiver/-/node-archiver-0.3.0.tgz#b9f1afe5006d0bdf29260181833a070978bc6947" + dependencies: + fstream "^1.0.10" + tar "^2.2.1" + node-pre-gyp@0.6.23: version "0.6.23" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.23.tgz#155bf3683abcfcde008aedab1248891a0773db95" @@ -2899,7 +2955,7 @@ q-io@1.13.2: qs "^1.2.1" url2 "^0.0.0" -q@^1.0.1: +q@1.5.0, q@^1.0.1: version "1.5.0" resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1" @@ -3204,7 +3260,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1: +rimraf@2, rimraf@2.6.1, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" dependencies: @@ -3311,7 +3367,7 @@ setprototypeof@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" -sha1@: +sha1@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/sha1/-/sha1-1.1.1.tgz#addaa7a93168f393f19eb2b15091618e2700f848" dependencies: @@ -3714,7 +3770,7 @@ tmp@0.0.29: dependencies: os-tmpdir "~1.0.1" -tmp@^0.0.31: +tmp@0.0.31, tmp@^0.0.31: version "0.0.31" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7" dependencies: