diff --git a/package.json b/package.json index f0fb96ec..cc72ffcb 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "bchat-desktop", "productName": "BChat", "description": "Private messaging from your desktop", - "version": "2.1.0", + "version": "2.1.1", "license": "GPL-3.0", "author": { "name": "Beldex team", diff --git a/preload.js b/preload.js index 8d5682f0..6dc4387d 100644 --- a/preload.js +++ b/preload.js @@ -228,7 +228,7 @@ window.Signal = data.initData(); // Linux seems to periodically let the event loop stop, so this is a global workaround setInterval(() => { // tslint:disable-next-line: no-empty - window.nodeSetImmediate(() => {}); + window.nodeSetImmediate(() => { }); }, 1000); window.React = require('react'); @@ -241,15 +241,15 @@ if (window.networkType == 'mainnet') { window.getSeedNodeList = () => process.env.NODE_ENV == 'development' ? [ - 'https://publicnode1.rpcnode.stream:443', - 'https://publicnode2.rpcnode.stream:443', - 'https://publicnode3.rpcnode.stream:443', - ] + 'https://publicnode1.rpcnode.stream:443', + 'https://publicnode2.rpcnode.stream:443', + 'https://publicnode3.rpcnode.stream:443', + ] : [ - 'https://publicnode1.rpcnode.stream:443', - 'https://publicnode2.rpcnode.stream:443', - 'https://publicnode3.rpcnode.stream:443', - ]; + 'https://publicnode1.rpcnode.stream:443', + 'https://publicnode2.rpcnode.stream:443', + 'https://publicnode3.rpcnode.stream:443', + ]; const remotes = [ { @@ -294,18 +294,18 @@ if (window.networkType == 'mainnet') { } else { window.getSeedNodeList = () => process.env.NODE_ENV == 'development' - ? ['http://38.242.196.72:19095', 'http://154.26.139.105:19095'] - : ['http://38.242.196.72:19095', 'http://154.26.139.105:19095']; + ? ['http://149.102.156.174:19095'] + : ['http://149.102.156.174:19095']; const remotes = [ { - host: '38.242.196.72', + host: '149.102.156.174', port: '19095', active: 0, type: 'Remote', }, { - host: '154.26.139.105', + host: '149.102.156.174', port: '19095', active: 0, type: 'Remote', diff --git a/ts/bchat/apis/snode_api/hfHandling.ts b/ts/bchat/apis/snode_api/hfHandling.ts index dc349e28..557f0264 100644 --- a/ts/bchat/apis/snode_api/hfHandling.ts +++ b/ts/bchat/apis/snode_api/hfHandling.ts @@ -1,71 +1,71 @@ import { isNumber } from 'lodash'; import { createOrUpdateItem, getItemById } from '../../../data/channelsItem'; -let hasSeenHardfork190: boolean | undefined; -let hasSeenHardfork191: boolean | undefined; +let hasSeenHardfork170: boolean | undefined; +let hasSeenHardfork180: boolean | undefined; /** * this is only intended for testing. Do not call this in production. */ export function resetHardForkCachedValues() { - hasSeenHardfork190 = hasSeenHardfork191 = undefined; + hasSeenHardfork170 = hasSeenHardfork180 = undefined; } -export async function getHasSeenHF190() { - if (hasSeenHardfork190 === undefined) { +export async function getHasSeenHF170() { + if (hasSeenHardfork170 === undefined) { // read values from db and cache them as it looks like we did not - const oldHhasSeenHardfork190 = (await getItemById('hasSeenHardfork190'))?.value; + const oldHhasSeenHardfork170 = (await getItemById('hasSeenHardfork170'))?.value; // values do not exist in the db yet. Let's store false for now in the db and update our cached value. - if (oldHhasSeenHardfork190 === undefined) { - await createOrUpdateItem({ id: 'hasSeenHardfork190', value: false }); - hasSeenHardfork190 = false; + if (oldHhasSeenHardfork170 === undefined) { + await createOrUpdateItem({ id: 'hasSeenHardfork170', value: false }); + hasSeenHardfork170 = false; } else { - hasSeenHardfork190 = oldHhasSeenHardfork190; + hasSeenHardfork170 = oldHhasSeenHardfork170; } } - return hasSeenHardfork190; + return hasSeenHardfork170; } -export async function getHasSeenHF191() { - if (hasSeenHardfork191 === undefined) { +export async function getHasSeenHF180() { + if (hasSeenHardfork180 === undefined) { // read values from db and cache them as it looks like we did not - const oldHhasSeenHardfork191 = (await getItemById('hasSeenHardfork191'))?.value; + const oldHhasSeenHardfork180 = (await getItemById('hasSeenHardfork180'))?.value; // values do not exist in the db yet. Let's store false for now in the db and update our cached value. - if (oldHhasSeenHardfork191 === undefined) { - await createOrUpdateItem({ id: 'hasSeenHardfork191', value: false }); - hasSeenHardfork191 = false; + if (oldHhasSeenHardfork180 === undefined) { + await createOrUpdateItem({ id: 'hasSeenHardfork180', value: false }); + hasSeenHardfork180 = false; } else { - hasSeenHardfork191 = oldHhasSeenHardfork191; + hasSeenHardfork180 = oldHhasSeenHardfork180; } } - return hasSeenHardfork191; + return hasSeenHardfork180; } export async function handleHardforkResult(json: Record) { - if (hasSeenHardfork190 === undefined || hasSeenHardfork191 === undefined) { + if (hasSeenHardfork170 === undefined || hasSeenHardfork180 === undefined) { // read values from db and cache them as it looks like we did not - const oldHhasSeenHardfork190 = (await getItemById('hasSeenHardfork190'))?.value; - const oldHasSeenHardfork191 = (await getItemById('hasSeenHardfork191'))?.value; + const oldHhasSeenHardfork170 = (await getItemById('hasSeenHardfork170'))?.value; + const oldHasSeenHardfork180 = (await getItemById('hasSeenHardfork180'))?.value; // values do not exist in the db yet. Let's store false for now in the db and update our cached value. - if (oldHhasSeenHardfork190 === undefined) { - await createOrUpdateItem({ id: 'hasSeenHardfork190', value: false }); - hasSeenHardfork190 = false; + if (oldHhasSeenHardfork170 === undefined) { + await createOrUpdateItem({ id: 'hasSeenHardfork170', value: false }); + hasSeenHardfork170 = false; } else { - hasSeenHardfork190 = oldHhasSeenHardfork190; + hasSeenHardfork170 = oldHhasSeenHardfork170; } - if (oldHasSeenHardfork191 === undefined) { - await createOrUpdateItem({ id: 'hasSeenHardfork191', value: false }); - hasSeenHardfork191 = false; + if (oldHasSeenHardfork180 === undefined) { + await createOrUpdateItem({ id: 'hasSeenHardfork180', value: false }); + hasSeenHardfork180 = false; } else { - hasSeenHardfork191 = oldHasSeenHardfork191; + hasSeenHardfork180 = oldHasSeenHardfork180; } } - if (hasSeenHardfork191 && hasSeenHardfork190) { + if (hasSeenHardfork180 && hasSeenHardfork170) { // no need to do any of this if we already know both forks happened - window.log.info('hardfork 19.1 already happened. No need to go any further'); + window.log.info('hardfork 18.0 already happened. No need to go any further'); return; } @@ -77,15 +77,15 @@ export async function handleHardforkResult(json: Record) { isNumber(json.hf[0]) && isNumber(json.hf[1]) ) { - if (!hasSeenHardfork190 && json.hf[0] >= 19 && json.hf[1] >= 0) { - window.log.info('[HF]: We just detected HF 19.0 on "retrieve"'); - await createOrUpdateItem({ id: 'hasSeenHardfork190', value: true }); - hasSeenHardfork190 = true; + if (!hasSeenHardfork170 && json.hf[0] >= 17 && json.hf[1] >= 0) { + window.log.info('[HF]: We just detected HF 17.0 on "retrieve"'); + await createOrUpdateItem({ id: 'hasSeenHardfork170', value: true }); + hasSeenHardfork170 = true; } - if (!hasSeenHardfork191 && json.hf[0] >= 19 && json.hf[1] >= 1) { - window.log.info('[HF]: We just detected HF 19.1 on "retrieve"'); - await createOrUpdateItem({ id: 'hasSeenHardfork191', value: true }); - hasSeenHardfork191 = true; + if (!hasSeenHardfork180 && json.hf[0] >= 18 && json.hf[1] >= 0) { + window.log.info('[HF]: We just detected HF 18.0 on "retrieve"'); + await createOrUpdateItem({ id: 'hasSeenHardfork180', value: true }); + hasSeenHardfork180 = true; } } } diff --git a/ts/bchat/apis/snode_api/swarmPolling.ts b/ts/bchat/apis/snode_api/swarmPolling.ts index 5debba79..2782e8f2 100644 --- a/ts/bchat/apis/snode_api/swarmPolling.ts +++ b/ts/bchat/apis/snode_api/swarmPolling.ts @@ -20,7 +20,7 @@ import { perfEnd, perfStart } from '../../utils/Performance'; import { ed25519Str } from '../../onions/onionPath'; import { updateIsOnline } from '../../../state/ducks/onion'; import pRetry from 'p-retry'; -import { getHasSeenHF190, getHasSeenHF191 } from './hfHandling'; +import { getHasSeenHF170, getHasSeenHF180 } from './hfHandling'; interface Message { hash: string; @@ -163,8 +163,8 @@ export class SwarmPolling { ?.idForLogging() || group.pubkey.key; if (diff >= convoPollingTimeout) { - const hardfork190Happened = await getHasSeenHF190(); - const hardfork191Happened = await getHasSeenHF191(); + const hardfork190Happened = await getHasSeenHF170(); + const hardfork191Happened = await getHasSeenHF180(); window?.log?.info( `Polling for ${loggingId}; timeout: ${convoPollingTimeout}; diff: ${diff} ; hardfork190Happened: ${hardfork190Happened}; hardfork191Happened: ${hardfork191Happened} ` ); diff --git a/ts/bchat/sending/MessageSender.ts b/ts/bchat/sending/MessageSender.ts index 16ad8148..8d9b080a 100644 --- a/ts/bchat/sending/MessageSender.ts +++ b/ts/bchat/sending/MessageSender.ts @@ -22,7 +22,7 @@ import { getConversationController } from '../conversations'; import { ed25519Str } from '../onions/onionPath'; import { EmptySwarmError } from '../utils/errors'; import ByteBuffer from 'bytebuffer'; -import { getHasSeenHF190, getHasSeenHF191 } from '../apis/snode_api/hfHandling'; +import { getHasSeenHF170, getHasSeenHF180 } from '../apis/snode_api/hfHandling'; const DEFAULT_CONNECTIONS = 1; @@ -141,8 +141,8 @@ export async function sendMessageToSnode( const conversation = getConversationController().get(pubKey); const isClosedGroup = conversation?.isClosedGroup(); - const hardfork190Happened = await getHasSeenHF190(); - const hardfork191Happened = await getHasSeenHF191(); + const hardfork190Happened = await getHasSeenHF170(); + const hardfork191Happened = await getHasSeenHF180(); const namespace = isClosedGroup ? -10 : 0; window?.log?.debug( diff --git a/ts/test/bchat/unit/onion/hfHandling_test.ts b/ts/test/bchat/unit/onion/hfHandling_test.ts index 525e1909..1165687f 100644 --- a/ts/test/bchat/unit/onion/hfHandling_test.ts +++ b/ts/test/bchat/unit/onion/hfHandling_test.ts @@ -1,8 +1,8 @@ import { expect } from 'chai'; import Sinon from 'sinon'; import { - getHasSeenHF190, - getHasSeenHF191, + getHasSeenHF170, + getHasSeenHF180, handleHardforkResult, resetHardForkCachedValues, } from '../../../../bchat/apis/snode_api/hfHandling'; @@ -10,7 +10,7 @@ import { TestUtils } from '../../../test-utils'; // tslint:disable-next-line: max-func-body-length describe('hardfork handling', () => { - describe('getHasSeenHF190', () => { + describe('getHasSeenHF170', () => { afterEach(() => { Sinon.restore(); resetHardForkCachedValues(); @@ -20,8 +20,8 @@ describe('hardfork handling', () => { const getItemById = TestUtils.stubDataItem('getItemById').resolves(undefined); const createItem = TestUtils.stubDataItem('createOrUpdateItem').resolves(); - const ret = await getHasSeenHF190(); - expect(ret).to.be.eq(false, 'getHasSeenHF190 should return false'); + const ret = await getHasSeenHF170(); + expect(ret).to.be.eq(false, 'getHasSeenHF170 should return false'); expect(getItemById.calledOnce).to.be.eq(true, 'getItemById should have been called'); expect(createItem.calledOnce).to.be.eq(true, 'createItem should have been called'); @@ -33,13 +33,13 @@ describe('hardfork handling', () => { it('fetches from db if undefined, and does not write to db if db value is not undefined', async () => { const getItemById = TestUtils.stubDataItem('getItemById').resolves({ - id: 'getHasSeenHF190', + id: 'getHasSeenHF170', value: false, }); const createItem = TestUtils.stubDataItem('createOrUpdateItem').resolves(); - const ret = await getHasSeenHF190(); - expect(ret).to.be.eq(false, 'getHasSeenHF190 should return false'); + const ret = await getHasSeenHF170(); + expect(ret).to.be.eq(false, 'getHasSeenHF170 should return false'); expect(getItemById.calledOnce).to.be.eq(true, 'getItemById should have been called'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called'); @@ -47,13 +47,13 @@ describe('hardfork handling', () => { it('fetches from db if undefined, and does not write to db if db value is not undefined - 2', async () => { const getItemById = TestUtils.stubDataItem('getItemById').resolves({ - id: 'getHasSeenHF190', + id: 'getHasSeenHF170', value: true, }); const createItem = TestUtils.stubDataItem('createOrUpdateItem').resolves(); - const ret = await getHasSeenHF190(); - expect(ret).to.be.eq(true, 'getHasSeenHF190 should return false'); + const ret = await getHasSeenHF170(); + expect(ret).to.be.eq(true, 'getHasSeenHF170 should return false'); expect(getItemById.calledOnce).to.be.eq(true, 'getItemById should have been called'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called'); @@ -61,22 +61,22 @@ describe('hardfork handling', () => { it('fetches from db only the value is not cached already', async () => { const getItemById = TestUtils.stubDataItem('getItemById').resolves({ - id: 'getHasSeenHF190', + id: 'getHasSeenHF170', value: true, }); const createItem = TestUtils.stubDataItem('createOrUpdateItem').resolves(); - const ret = await getHasSeenHF190(); - const ret2 = await getHasSeenHF190(); - expect(ret).to.be.eq(true, 'getHasSeenHF190 should return false'); - expect(ret2).to.be.eq(true, 'getHasSeenHF190 should return false - 2'); + const ret = await getHasSeenHF170(); + const ret2 = await getHasSeenHF170(); + expect(ret).to.be.eq(true, 'getHasSeenHF170 should return false'); + expect(ret2).to.be.eq(true, 'getHasSeenHF170 should return false - 2'); expect(getItemById.calledOnce).to.be.eq(true, 'getItemById should have been called'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called'); }); }); - describe('getHasSeenHF191', () => { + describe('getHasSeenHF180', () => { afterEach(() => { Sinon.restore(); resetHardForkCachedValues(); @@ -86,8 +86,8 @@ describe('hardfork handling', () => { const getItemById = TestUtils.stubDataItem('getItemById').resolves(undefined); const createItem = TestUtils.stubDataItem('createOrUpdateItem').resolves(); - const ret = await getHasSeenHF191(); - expect(ret).to.be.eq(false, 'getHasSeenHF191 should return false'); + const ret = await getHasSeenHF180(); + expect(ret).to.be.eq(false, 'getHasSeenHF180 should return false'); expect(getItemById.calledOnce).to.be.eq(true, 'getItemById should have been called'); expect(createItem.calledOnce).to.be.eq(true, 'createItem should have been called'); @@ -99,13 +99,13 @@ describe('hardfork handling', () => { it('fetches from db if undefined, and does not write to db if db value is not undefined', async () => { const getItemById = TestUtils.stubDataItem('getItemById').resolves({ - id: 'getHasSeenHF191', + id: 'getHasSeenHF180', value: false, }); const createItem = TestUtils.stubDataItem('createOrUpdateItem').resolves(); - const ret = await getHasSeenHF191(); - expect(ret).to.be.eq(false, 'getHasSeenHF191 should return false'); + const ret = await getHasSeenHF180(); + expect(ret).to.be.eq(false, 'getHasSeenHF180 should return false'); expect(getItemById.calledOnce).to.be.eq(true, 'getItemById should have been called'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called'); @@ -113,13 +113,13 @@ describe('hardfork handling', () => { it('fetches from db if undefined, and does not write to db if db value is not undefined - 2', async () => { const getItemById = TestUtils.stubDataItem('getItemById').resolves({ - id: 'getHasSeenHF191', + id: 'getHasSeenHF180', value: true, }); const createItem = TestUtils.stubDataItem('createOrUpdateItem').resolves(); - const ret = await getHasSeenHF191(); - expect(ret).to.be.eq(true, 'getHasSeenHF191 should return false'); + const ret = await getHasSeenHF180(); + expect(ret).to.be.eq(true, 'getHasSeenHF180 should return false'); expect(getItemById.calledOnce).to.be.eq(true, 'getItemById should have been called'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called'); @@ -127,15 +127,15 @@ describe('hardfork handling', () => { it('fetches from db only the value is not cached already', async () => { const getItemById = TestUtils.stubDataItem('getItemById').resolves({ - id: 'getHasSeenHF191', + id: 'getHasSeenHF180', value: true, }); const createItem = TestUtils.stubDataItem('createOrUpdateItem').resolves(); - const ret = await getHasSeenHF191(); - const ret2 = await getHasSeenHF191(); - expect(ret).to.be.eq(true, 'getHasSeenHF191 should return false'); - expect(ret2).to.be.eq(true, 'getHasSeenHF191 should return false - 2'); + const ret = await getHasSeenHF180(); + const ret2 = await getHasSeenHF180(); + expect(ret).to.be.eq(true, 'getHasSeenHF180 should return false'); + expect(ret2).to.be.eq(true, 'getHasSeenHF180 should return false - 2'); expect(getItemById.calledOnce).to.be.eq(true, 'getItemById should have been called'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called'); @@ -291,7 +291,7 @@ describe('hardfork handling', () => { getItemById.resetHistory(); createItem.resetHistory(); - expect(await getHasSeenHF190()).to.be.eq(true, 'getHasSeenHF190 should have been true'); + expect(await getHasSeenHF170()).to.be.eq(true, 'getHasSeenHF170 should have been true'); expect(getItemById.notCalled).to.be.eq(true, 'getItemById should not have been called more'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called more'); }); @@ -322,8 +322,8 @@ describe('hardfork handling', () => { ); getItemById.resetHistory(); createItem.resetHistory(); - expect(await getHasSeenHF190()).to.be.eq(true, 'getHasSeenHF190 should have been true'); - expect(await getHasSeenHF191()).to.be.eq(true, 'getHasSeenHF191 should have been true'); + expect(await getHasSeenHF170()).to.be.eq(true, 'getHasSeenHF170 should have been true'); + expect(await getHasSeenHF180()).to.be.eq(true, 'getHasSeenHF180 should have been true'); expect(getItemById.notCalled).to.be.eq(true, 'getItemById should not have been called more'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called more'); }); @@ -338,8 +338,8 @@ describe('hardfork handling', () => { getItemById.resetHistory(); createItem.resetHistory(); - expect(await getHasSeenHF190()).to.be.eq(true, 'getHasSeenHF190 should have been true'); - expect(await getHasSeenHF191()).to.be.eq(true, 'getHasSeenHF191 should have been true'); + expect(await getHasSeenHF170()).to.be.eq(true, 'getHasSeenHF170 should have been true'); + expect(await getHasSeenHF180()).to.be.eq(true, 'getHasSeenHF180 should have been true'); expect(getItemById.notCalled).to.be.eq(true, 'getItemById should not have been called more'); expect(createItem.notCalled).to.be.eq(true, 'createItem should not have been called more'); }); diff --git a/ts/test/bchat/unit/swarm_polling/SwarmPolling_test.ts b/ts/test/bchat/unit/swarm_polling/SwarmPolling_test.ts index fac97d98..da5025a5 100644 --- a/ts/test/bchat/unit/swarm_polling/SwarmPolling_test.ts +++ b/ts/test/bchat/unit/swarm_polling/SwarmPolling_test.ts @@ -209,7 +209,7 @@ describe('SwarmPolling', () => { expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, 0]); }); - it('does run for group pubkey on start no matter the old timestamp if HF >= 19.0 & < 19.1 ', async () => { + it('does run for group pubkey on start no matter the old timestamp if HF >= 17.0 & < 18.0 ', async () => { const convo = getConversationController().getOrCreate( TestUtils.generateFakePubKeyStr(), ConversationTypeEnum.GROUP @@ -239,7 +239,7 @@ describe('SwarmPolling', () => { getItemByIdStub.resolves(); }); - it('does only poll from -10 for closed groups if HF >= 19.1 ', async () => { + it('does only poll from -10 for closed groups if HF >= 18.0 ', async () => { const convo = getConversationController().getOrCreate( TestUtils.generateFakePubKeyStr(), ConversationTypeEnum.GROUP diff --git a/ts/wallet/wallet-rpc.ts b/ts/wallet/wallet-rpc.ts index 57a027f3..2318cd09 100644 --- a/ts/wallet/wallet-rpc.ts +++ b/ts/wallet/wallet-rpc.ts @@ -369,7 +369,7 @@ class Wallet { if (window.networkType === 'mainnet') { url = 'http://explorer.beldex.io:19091'; } else { - url = 'http://154.26.139.105:19095'; + url = 'http://149.102.156.174:19095'; } const response = await insecureNodeFetch(`${url}/get_height`, { method: 'POST',