problem: can't get current Bitcoin block height and hash

This commit is contained in:
Bob
2024-08-03 13:00:58 +08:00
parent 601b6c4261
commit e182c0fb30
5 changed files with 87 additions and 11 deletions

View File

@@ -5,6 +5,8 @@
import { ndk } from '@/ndk';
import type { NDKUser } from '@nostr-dev-kit/ndk';
import { currentUser, prepareUserSession } from '@/stores/session';
import { unixTimeNow } from '@/helpers';
import { getBitcoinTip } from '@/stores/bitcoin';
let sessionStarted = false;
let connected = false;
@@ -24,6 +26,18 @@
});
sessionStarted = true;
}
let lastRequestTime = 0;
$: {
if (unixTimeNow() > lastRequestTime + 30000) {
getBitcoinTip().then((x) => {
if (x) {
lastRequestTime = unixTimeNow();
}
});
}
}
</script>
<ModeWatcher defaultMode="dark" />