feat: switch to replaceable events for nostr source
Some checks failed
BTClock CI / build (push) Failing after 5m31s
BTClock CI / merge (map[name:btclock_rev_b version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:btclock_v8 version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 29epd) (push) Has been skipped
BTClock CI / release (push) Has been skipped

This commit is contained in:
Djuri 2025-02-19 15:15:53 +01:00
parent 0b1a362b53
commit e4ac3c5c94
Signed by: djuri
GPG key ID: 61B9B2DDE5AA3AC1
3 changed files with 13 additions and 3 deletions

2
data

@ -1 +1 @@
Subproject commit 68207a7d95b6cb16df5c991b84ff40c25c23755b
Subproject commit 0116cd68cdfdf383823f74e0f9665a1700cf0500

View file

@ -4,6 +4,6 @@ dependencies:
source:
type: idf
version: 4.4.7
manifest_hash: 04e75badb795f8a851d8b088baff06d145ecf7a66457d960c2f4ede17b45ef05
manifest_hash: cd2f3ee15e776d949eb4ea4eddc8f39b30c2a7905050850eed01ab4928143cff
target: esp32s3
version: 1.0.0

View file

@ -41,7 +41,7 @@ void setupNostrNotify(bool asDatasource, bool zapNotify)
{relay},
{// First filter
{
{"kinds", {"1"}},
{"kinds", {"12203"}},
{"since", {String(getMinutesAgo(60))}},
{"authors", {pubKey}},
}},
@ -146,6 +146,7 @@ void handleNostrEventCallback(const String &subId, nostr::SignedNostrEvent *even
// Use direct value access instead of multiple comparisons
String typeValue;
uint medianFee = 0;
uint blockHeight = 0;
for (JsonArray tag : tags) {
if (tag.size() != 2) continue;
@ -166,6 +167,11 @@ void handleNostrEventCallback(const String &subId, nostr::SignedNostrEvent *even
medianFee = tag[1].as<uint>();
}
break;
case 'b': // blockHeight
if (strcmp(key, "block") == 0) {
blockHeight = tag[1].as<uint>();
}
break;
}
}
@ -173,6 +179,10 @@ void handleNostrEventCallback(const String &subId, nostr::SignedNostrEvent *even
if (!typeValue.isEmpty()) {
if (typeValue == "priceUsd") {
processNewPrice(obj["content"].as<uint>(), CURRENCY_USD);
if (blockHeight != 0) {
auto& blockNotify = BlockNotify::getInstance();
blockNotify.processNewBlock(blockHeight);
}
}
else if (typeValue == "blockHeight") {
auto& blockNotify = BlockNotify::getInstance();