Skip to content

Commit

Permalink
Network Refactor (#431)
Browse files Browse the repository at this point in the history
* Add missing virtual functions in Network class

* Refactor network creation

* Add missing JSdoc

* Make fetchBlockbook member of ExplorerNetwork

* Add a NetworkManager and refactor

* sleep in network_manager

* Update broken tests

* Move tx error logic to network_manager

* Mark virtual functions as async

* Add /network folder

* remove lookup test function

* Make fetchNode and fetchBlockbook private

* Simplify retryWrapper

* Add defaultNode

* Reset when testnet is toggled

* Add missing network filter

* Make retryWrapper private

* Make safeFetch private

* Remove copy/equal pattern

* Don't export networkManager

* fix typo

* Use static member instead of global variable

* Make all fields private

* Add Missing function callRPC
  • Loading branch information
panleone authored Nov 1, 2024
1 parent 19c1627 commit 1aa7244
Show file tree
Hide file tree
Showing 20 changed files with 534 additions and 455 deletions.
2 changes: 1 addition & 1 deletion scripts/dashboard/CreateWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ref, watch, toRefs } from 'vue';
import { useWallet } from '../composables/use_wallet.js';
import newWalletIcon from '../../assets/icons/icon-new-wallet.svg';
import Password from '../Password.vue';
import { getNetwork } from '../network.js';
import { getNetwork } from '../network/network_manager.js';
const emit = defineEmits(['importWallet']);
const showModal = ref(false);
Expand Down
2 changes: 1 addition & 1 deletion scripts/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
isColdAddress,
isStandardAddress,
} from '../misc.js';
import { getNetwork } from '../network.js';
import { getNetwork } from '../network/network_manager.js';
import { strHardwareName } from '../ledger';
import { guiAddContactPrompt } from '../contacts-book';
import { scanQRCode } from '../scanner';
Expand Down
3 changes: 1 addition & 2 deletions scripts/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TransactionBuilder } from './transaction_builder.js';
import Masternode from './masternode.js';
import { ALERTS, tr, start as i18nStart, translation } from './i18n.js';
import { wallet, hasEncryptedWallet, Wallet } from './wallet.js';
import { getNetwork } from './network.js';
import { getNetwork } from './network/network_manager.js';
import {
start as settingsStart,
strCurrency,
Expand Down Expand Up @@ -259,7 +259,6 @@ export async function start() {
// Register native app service
registerWorker();
await settingsStart();

subscribeToNetworkEvents();
// Make sure we know the correct number of blocks
await refreshChainData();
Expand Down
2 changes: 1 addition & 1 deletion scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ import Masternode from './masternode.js';
export { renderChangelog } from './changelog.js';
export { Masternode };

export { getNetwork } from './network.js';
export { getNetwork } from './network/network_manager.js';

export { FlipDown } from './flipdown.js';
2 changes: 1 addition & 1 deletion scripts/ledger.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import createXpub from 'create-xpub';
import { ALERTS, tr } from './i18n.js';
import { confirmPopup } from './misc.js';
import { getNetwork } from './network.js';
import { getNetwork } from './network/network_manager.js';
import { Transaction } from './transaction.js';
import { COIN, cChainParams } from './chain_params.js';
import { hexToBytes, bytesToHex } from './utils.js';
Expand Down
2 changes: 1 addition & 1 deletion scripts/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { wallet, getNewAddress } from './wallet.js';
import { cChainParams, COIN, COIN_DECIMALS } from './chain_params.js';
import { generateMasternodePrivkey, confirmPopup } from './misc.js';
import { Database } from './database.js';
import { getNetwork } from './network.js';
import { getNetwork } from './network/network_manager.js';
import { ledgerSignTransaction } from './ledger.js';
import { createAlert } from './alerts/alert.js';

Expand Down
2 changes: 1 addition & 1 deletion scripts/masternode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { OP } from './script.js';
import bs58 from 'bs58';
import base32 from 'base32';
import { isStandardAddress } from './misc.js';
import { getNetwork } from './network.js';
import { getNetwork } from './network/network_manager.js';
import { debugError, DebugTopics } from './debug.js';

/**
Expand Down
Loading

0 comments on commit 1aa7244

Please sign in to comment.