Skip to content

Commit

Permalink
Fix refresh_upstream_peer_stats (#289)
Browse files Browse the repository at this point in the history
* fix refresh_upstream_peer_stats

* lint error

* update preferences.rs
  • Loading branch information
BBK912 authored Apr 22, 2024
1 parent 8a6d710 commit be18ccd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src-tauri/src/commands/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ pub fn debug_preferences_path() -> Result<PathBuf, CarpeError> {
/// refreshes statistics and returns the synced peers
pub async fn refresh_upstream_peer_stats() -> Result<Vec<Url>, CarpeError> {
let mut app_cfg = get_cfg()?;
app_cfg.refresh_network_profile_and_save(None).await?; // uses app_cfg.chain_info_chain_id
let np = app_cfg.get_network_profile(None)?;
// dbg!(&np);

let np = app_cfg.refresh_network_profile_and_save(None).await?; // uses app_cfg.chain_info_chain_id
app_cfg.network_playlist = vec![np.clone()];
app_cfg.save_file()?;

let peers = match np.the_good_ones() {
Expand Down
16 changes: 6 additions & 10 deletions src-tauri/src/commands/wallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ async fn test_fetch_originating() {
}

#[tauri::command(async)]
pub async fn set_slow_wallet(legacy: bool,) -> Result<(), CarpeError> {
pub async fn set_slow_wallet(legacy: bool) -> Result<(), CarpeError> {
// NOTE: unsure Serde was catching all cases check serialization
let mut config = get_cfg()?;
inject_private_key_to_cfg(&mut config)?;
Expand Down Expand Up @@ -320,9 +320,7 @@ fn add_legacy_accounts(authkey: AuthenticationKey) -> Result<LegacyAccounts, Car
let _ = update_legacy_accounts(&all);
Ok(all)
} else {
Err(CarpeError::misc(
"account already exists",
))
Err(CarpeError::misc("account already exists"))
}
}
fn update_legacy_accounts(accounts: &LegacyAccounts) -> Result<(), CarpeError> {
Expand Down Expand Up @@ -361,10 +359,8 @@ pub fn remove_legacy_accounts() -> Result<String, CarpeError> {
}
}
}
Err(CarpeError::misc(
&format!(
"No legacy accounts to remove. No account file found at {:?}",
&db_path
),
))
Err(CarpeError::misc(&format!(
"No legacy accounts to remove. No account file found at {:?}",
&db_path
)))
}
1 change: 0 additions & 1 deletion src/modules/accountActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const refreshAccounts = async () => {
)
})
if (changedCurrentAccount) {
console.log('ref::::')
signingAccount.set(changedCurrentAccount)
}
}
Expand Down
9 changes: 2 additions & 7 deletions src/modules/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ export const incrementBackoff = () => {
scanning_fullnodes_backoff.set(new_time.getSeconds())
}

let current_network_profile: NetworkPlaylist = defaultPlaylist()
network_profile.subscribe((value) => {
current_network_profile = value
})
let isTest = false
nodeEnvIsTest.subscribe((value) => {
isTest = value
Expand All @@ -170,9 +166,8 @@ export const initNetwork = async () => {
logger(Level.Info, 'initNetwork')
if (!isTest) {
await getNetwork()
if (current_network_profile.chain_id === NamedChain.TESTING) {
return await updateNetwork(playlistJsonUrl, false)
}

return await updateNetwork(playlistJsonUrl, false)
}
return true
}
Expand Down
5 changes: 3 additions & 2 deletions src/modules/tick.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get } from 'svelte/store'
import { getAccounts, refreshAccounts } from './accountActions'
// import { getLocalHeight, getTowerChainView, maybeEmitBacklog } from './miner_invoke'
import { getMetadata } from './networks'
import { getMetadata, refreshUpstreamPeerStats } from './networks'
import { isInit } from './accounts'
import { Level, logger } from './carpeError'

Expand All @@ -21,7 +21,8 @@ export const carpeTick = async () => {
tick_in_progress = true

// don't try to connect while we are booting up the app and looking for fullnodes
// things that need network connectivity e.g. miner happen here

await refreshUpstreamPeerStats()
getMetadata()
.then(refreshAccounts)
// tower things
Expand Down

0 comments on commit be18ccd

Please sign in to comment.