Remove development PoW

pull/294/head
Beaudan 6 years ago
parent dad52a784d
commit f01d8088b7

@ -31,10 +31,10 @@ const filterIncomingMessages = async messages => {
};
const calcNonce = (messageEventData, pubKey, data64, timestamp, ttl) => {
const difficulty = window.storage.get('PoWDifficulty', null);
// Nonce is returned as a base64 string to include in header
window.Whisper.events.trigger('calculatingPoW', messageEventData);
const development = window.getEnvironment() !== 'production';
return callWorker('calcPoW', timestamp, ttl, pubKey, data64, development);
return callWorker('calcPoW', timestamp, ttl, pubKey, data64, difficulty);
};
const trySendP2p = async (pubKey, data64, isPing, messageEventData) => {

@ -1,8 +1,7 @@
/* global dcodeIO, crypto, JSBI */
const NONCE_LEN = 8;
// Modify this value for difficulty scaling
const DEV_DIFFICULTY = 10;
const PROD_DIFFICULTY = 100;
const FALLBACK_DIFFICULTY = 10;
const pow = {
// Increment Uint8Array nonce by '_increment' with carrying
@ -62,7 +61,6 @@ const pow = {
ttl,
pubKey,
data,
development = false,
_difficulty = null,
increment = 1,
startNonce = 0
@ -74,8 +72,7 @@ const pow = {
).toArrayBuffer()
);
const difficulty =
_difficulty || (development ? DEV_DIFFICULTY : PROD_DIFFICULTY);
const difficulty = _difficulty || FALLBACK_DIFFICULTY;
const target = pow.calcTarget(ttl, payload.length, difficulty);
let nonce = new Uint8Array(NONCE_LEN);
@ -103,7 +100,7 @@ const pow = {
return pow.bufferToBase64(nonce);
},
calcTarget(ttl, payloadLen, difficulty = PROD_DIFFICULTY) {
calcTarget(ttl, payloadLen, difficulty = FALLBACK_DIFFICULTY) {
// payloadLength + NONCE_LEN
const totalLen = JSBI.add(JSBI.BigInt(payloadLen), JSBI.BigInt(NONCE_LEN));
// ttl converted to seconds

Loading…
Cancel
Save