Adding async publish to relay pool
This commit is contained in:
10
POOL_API.md
10
POOL_API.md
@@ -16,7 +16,7 @@ This document describes the public API for the Nostr Relay Pool implementation i
|
||||
| [`nostr_relay_pool_poll()`](nostr_core/core_relay_pool.c:1232) | Single iteration poll and dispatch |
|
||||
| [`nostr_relay_pool_query_sync()`](nostr_core/core_relay_pool.c:695) | Synchronous query returning event array |
|
||||
| [`nostr_relay_pool_get_event()`](nostr_core/core_relay_pool.c:825) | Get single most recent event |
|
||||
| [`nostr_relay_pool_publish()`](nostr_core/core_relay_pool.c:866) | Publish event and wait for OK responses |
|
||||
| [`nostr_relay_pool_publish_async()`](nostr_core/core_relay_pool.c:866) | Publish event with async callbacks |
|
||||
| [`nostr_relay_pool_get_relay_status()`](nostr_core/core_relay_pool.c:944) | Get connection status for a relay |
|
||||
| [`nostr_relay_pool_list_relays()`](nostr_core/core_relay_pool.c:960) | List all relays and their statuses |
|
||||
| [`nostr_relay_pool_get_relay_stats()`](nostr_core/core_relay_pool.c:992) | Get detailed statistics for a relay |
|
||||
@@ -438,9 +438,9 @@ int get_latest_note_from_pubkey(nostr_relay_pool_t* pool, const char* pubkey_hex
|
||||
```
|
||||
|
||||
### Publish Event
|
||||
**Function:** [`nostr_relay_pool_publish()`](nostr_core/core_relay_pool.c:866)
|
||||
**Function:** [`nostr_relay_pool_publish_async()`](nostr_core/core_relay_pool.c:866)
|
||||
```c
|
||||
int nostr_relay_pool_publish(
|
||||
int nostr_relay_pool_publish_async(
|
||||
nostr_relay_pool_t* pool,
|
||||
const char** relay_urls,
|
||||
int relay_count,
|
||||
@@ -471,8 +471,8 @@ int publish_text_note(nostr_relay_pool_t* pool, const char* content) {
|
||||
|
||||
printf("Publishing note: %s\n", content);
|
||||
|
||||
int success_count = nostr_relay_pool_publish(
|
||||
pool, relay_urls, 3, event);
|
||||
int success_count = nostr_relay_pool_publish_async(
|
||||
pool, relay_urls, 3, event, my_callback, user_data);
|
||||
|
||||
cJSON_Delete(event);
|
||||
|
||||
|
||||
233
debug.log
233
debug.log
@@ -1052,3 +1052,236 @@
|
||||
[04:51:30.102] SEND relay.laantungir.net:443: ["CLOSE", "pool_1_1759481260"]
|
||||
[04:51:30.102] SEND relay.laantungir.net:443: ["CLOSE", "pool_2_1759481341"]
|
||||
[04:51:30.102] SEND nos.lol:443: ["CLOSE", "pool_2_1759481341"]
|
||||
|
||||
=== NOSTR WebSocket Debug Log Started ===
|
||||
[11:36:03.026] SEND relay.laantungir.net:443: ["EVENT", {
|
||||
"pubkey": "650b42b2d501cd03b490ee27205444d1e507c200c3a137b99710564317eea65d",
|
||||
"created_at": 1759678563,
|
||||
"kind": 1,
|
||||
"tags": [],
|
||||
"content": "Test post at 2025-10-05 11:36:03",
|
||||
"id": "2a77ce51810b77073a7873fd00c56babde944a2520a49f852121f2438155e282",
|
||||
"sig": "a933a5f072a3a122bb7c685f6810781aaec47493e62f3f2540f49d7a8e7506be5d3dc319d98781a1807f4837acbb5ae1b76d8f99ce92ea55553a2e6eeec2697a"
|
||||
}]
|
||||
[11:36:03.104] RECV relay.laantungir.net:443: ["OK","2a77ce51810b77073a7873fd00c56babde944a2520a49f852121f2438155e282",true,""]
|
||||
|
||||
=== NOSTR WebSocket Debug Log Started ===
|
||||
[14:00:19.331] SEND localhost:7555: ["EVENT", {
|
||||
"pubkey": "7c2065299249ff1b4316c07af0d03d67ad145da80b907cc22aa608218c6d2687",
|
||||
"created_at": 1759687219,
|
||||
"kind": 1,
|
||||
"tags": [],
|
||||
"content": "Test post at 2025-10-05 14:00:19",
|
||||
"id": "15dbe2cfe9237b93992a3b4de9d90224032e8b613031748da92c46c1aeaa2e9c",
|
||||
"sig": "c0aa610658d8cfd76aca25894276a7f3f0573c2993429feff8b1ff10eeb5608ff18cfd79126de5f54e77f5b45a9d39f9006df65b56e4246e50cf72d212509569"
|
||||
}]
|
||||
[14:00:19.334] RECV localhost:7555: ["OK", "15dbe2cfe9237b93992a3b4de9d90224032e8b613031748da92c46c1aeaa2e9c", true, ""]
|
||||
[14:00:49.419] SEND localhost:7555: ["EVENT", {
|
||||
"pubkey": "2a0c81450868960944c17b0f57f6aa2b5307b56bc8d9cc1b213674c561a3ab85",
|
||||
"created_at": 1759687249,
|
||||
"kind": 1,
|
||||
"tags": [],
|
||||
"content": "Test post at 2025-10-05 14:00:49",
|
||||
"id": "c70d6c5c8745c088bd3b99e5f529bb69cd3d162cb9db28aa433a798fa8d811c3",
|
||||
"sig": "76ac20012e84d49a528db140e48024d6a390033df75bfbad64e822208a6a4a3f863b84860da8bcf78c6d8c8933e30fba92f11ebca5f4602ba4428b10584c7ceb"
|
||||
}]
|
||||
[14:01:23.848] SEND localhost:7555: ["EVENT", {
|
||||
"pubkey": "aa3b44608a9e52473a631d596c395dd297443237d56e34e31bdcd4272a1cf558",
|
||||
"created_at": 1759687283,
|
||||
"kind": 1,
|
||||
"tags": [],
|
||||
"content": "Test post at 2025-10-05 14:01:23",
|
||||
"id": "ec98292f570049ed00ae541cba716dcf6c8252b523ce036d9d3d79946ff62927",
|
||||
"sig": "3e5ffa59e881c4e772e3c0e65b26d5396b7687de2ae8e930b505fc2617ecfa4b392df32b3af41f8c989e5cb1eeb00d5c1fbedfba2729eb43a3838e49ebfffc8f"
|
||||
}]
|
||||
[14:01:23.851] RECV localhost:7555: ["OK", "ec98292f570049ed00ae541cba716dcf6c8252b523ce036d9d3d79946ff62927", true, ""]
|
||||
[14:02:12.846] SEND localhost:7555: ["REQ", "pool_1_1759687332", {
|
||||
"kinds": [1],
|
||||
"since": 1759687324,
|
||||
"limit": 10
|
||||
}]
|
||||
[14:02:13.462] SEND nos.lol:443: ["REQ", "pool_1_1759687332", {
|
||||
"kinds": [1],
|
||||
"since": 1759687324,
|
||||
"limit": 10
|
||||
}]
|
||||
[14:02:13.462] SEND nos.lol:443: ["REQ", "pool_1_1759687332", {
|
||||
"kinds": [1],
|
||||
"since": 1759687324,
|
||||
"limit": 10
|
||||
}]
|
||||
[14:02:13.614] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"The current price of Bitcoin is ~$123135.80\n\nBlock Height : 917792\n\n[2025-10-05 18:02:03 UTC] \n\n #bitcoin #nxus #nyx #oracle","created_at":1759687324,"id":"dfd294e7e51a9d8d323a56061dc93402b01766e64bb8da0b68e564c780c3db8a","kind":1,"pubkey":"ff8464aa592cdec49f76bf3c0b505433c47427d04eeaec1fa4c4e104709dabc3","sig":"0309e8ff8a0f1d0d36f990fcdde78d2d9e9125229d1ab850fe92fbbabffe5f26ca5204a48c44bab0044aeeb1824b7dd54d9e9074bad5e3263691c445553ed2de","tags":[]}]
|
||||
[14:02:13.675] RECV nos.lol:443: ["EOSE","pool_1_1759687332"]
|
||||
[14:02:14.774] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"Why?","created_at":1759687333,"id":"c0c29a6a16ed277868962e6664c07a8be2afd416c8b0212c9f17eff1a073ac15","kind":1,"pubkey":"8a719d42268aa925f6b12bcbe6b645f6ec82efe64eac91daf935fdcccf1f0fe5","sig":"db6174f60d86859989e34f6963c0ad25bfe67002a35d47933ad3c7ce7b271d061d82a7ed702c0aa6419eafb83cc0c93675b675bdc180d5d859df8691c52de38d","tags":[["alt","A short note: Why?"],["e","c2d6913771cbbbdd3fefaf8f016a142841b5d00278bd16359c6e011ec1a33539","wss://relay.snort.social/","root","341db5a7e3a931f49095d82a4acc939cf8a67293b1e4179fd4b5c0544c4fc2ef"],["p","341db5a7e3a931f49095d82a4acc939cf8a67293b1e4179fd4b5c0544c4fc2ef","wss://nostr.bitcoiner.social/"]]}]
|
||||
[14:02:15.737] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"check out ⒷⒶⓃⒼⒻⓄⓇⒻⓊⓃ .ⒸⓄⓂ its filled with nothing but everyday girls who are lonely due to covid and want to exchange contact info with her again if you would be appreciated","created_at":1759687335,"id":"02982bdbc18d00777cd274270cee086b30847a93f875b5d0417135c406443156","kind":1,"pubkey":"fe5f59754d2e3a2579b4c95d67f7ff12da4bfffbf8f1c6b0a8de3970407ef974","sig":"cfa9ad66756503599e83a0ec77897cf0170b44a71ced1bf6e1843a146f1d0a381ffdf951e20d1f05814ffac549425435b4519a138ccec691f6d2a2e7648d19bf","tags":[]}]
|
||||
[14:02:22.358] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"Sunday\ndon’t forget to stretch \nhttps://blossom.primal.net/d18ce68340127803a368333762a18caf6083762b9bb29e6a48ca806d5fc89f92.mov","created_at":1759687342,"id":"97e92a02de8c446067ed5fef48307139eac31caa81bde9152c0bfe7b4b33f5c9","kind":1,"pubkey":"8fda2199c4399fad7ff4126b402f1f5ee157fdbe4c0951e64dfe31aaec877ff1","sig":"e599ca1b54e9fe930083a6c8d1a967be347656b5a45939ead9156cba7f3e89946613a259bb38816778eee22a5bffb9c825eb3555edd09f79304ce529774349b0","tags":[]}]
|
||||
[14:02:24.129] SEND localhost:7555: ["REQ", "pool_1_1759687332", {
|
||||
"kinds": [1],
|
||||
"since": 1759687324,
|
||||
"limit": 10
|
||||
}]
|
||||
[14:02:24.130] RECV localhost:7555: ["EOSE", "pool_1_1759687332"]
|
||||
[14:02:24.890] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"Indeed he is 😅🫡","created_at":1759687345,"id":"097a6a383c2fbc3f65dd37752ad941545a1295e786758392df0bf9a6b2327a30","kind":1,"pubkey":"db8f291dcf949373f5224070cbef4fab80b9a8d3434246aca1fe34114cc51dd0","sig":"2d0cf79a141c3bb06245bee49c601b5f415c601f8d40f2d444ccdf90e79ec6254d1dc46b729b136030f19775a65a5a4655d5f40e9954df0c894a1149ca3305ec","tags":[["p","493a5a07be1dc06a1dd2d8e943d8924fd469f057857e26f7b99ebdebe00c2557","","mention"],["p","db8f291dcf949373f5224070cbef4fab80b9a8d3434246aca1fe34114cc51dd0","","mention"],["p","496bf22b76e63553b2cac70c44b53867368b4b7612053a2c78609f3144324807","","mention"],["e","bd01a782c099d9a4121063df8d89e6722d4b54d3015624870b7c80acd047f739","","root"],["e","c0ac6ca2931e1e22ab99c3daf5f1c85be1644ab13848d5d136eda170b95e0911","","reply"]]}]
|
||||
[14:02:41.565] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"I never know when to stfu","created_at":1759687362,"id":"291797f5b41d6a22e41b7001ddb8f68c60175408f13633d686f6f738366fa304","kind":1,"pubkey":"341db5a7e3a931f49095d82a4acc939cf8a67293b1e4179fd4b5c0544c4fc2ef","sig":"003486d469652f3485106de99d3c156d23625df98748471b36ffe207a966ad414621d36dd36cb1206ae17dd41741cc4f047a3ce2d706abc296cde351752f6c24","tags":[["alt","A short note: I never know when to stfu"],["e","c2d6913771cbbbdd3fefaf8f016a142841b5d00278bd16359c6e011ec1a33539","wss://nostr.bitcoiner.social/","root","341db5a7e3a931f49095d82a4acc939cf8a67293b1e4179fd4b5c0544c4fc2ef"],["e","c0c29a6a16ed277868962e6664c07a8be2afd416c8b0212c9f17eff1a073ac15","wss://wot.nostr.net/","reply","8a719d42268aa925f6b12bcbe6b645f6ec82efe64eac91daf935fdcccf1f0fe5"],["p","341db5a7e3a931f49095d82a4acc939cf8a67293b1e4179fd4b5c0544c4fc2ef","wss://nostr.bitcoiner.social/"],["p","8a719d42268aa925f6b12bcbe6b645f6ec82efe64eac91daf935fdcccf1f0fe5","ws://agwwuih4l66mb6oxnqk42lfsubhatux3bmcnpmki6cd7nmx5lz2ys6yd.onion/"]]}]
|
||||
[14:02:42.621] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"歯を磨きました えらいです","created_at":1759687359,"id":"b0c6315ae6940ec80b90f3fd5afaa87bbc608e266da91a5d69a62455ccb1ada0","kind":1,"pubkey":"8c59239319637f97e007dad0d681e65ce35b1ace333b629e2d33f9465c132608","sig":"84cae19a484de2d28cf0458920ebf918af55c5c244796301ddc2c050adc6f8d177f6dd833a2bd3c2fe0cbde82a1c4ab5ac29fba3f7d88829b18d3717fbdcc4de","tags":[]}]
|
||||
[14:02:45.057] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"FREEDOM!!!🥴","created_at":1759687364,"id":"7bc750b643cda5fd7b38e4ff9c2bc085b7af1ea3710617d8fc13d5c84af74c41","kind":1,"pubkey":"b7baced2435c5a2427cadcefd9257786aaab6ab688b105f32e2657374da9e74c","sig":"816efcd39f190de6b21ced158e1c86611a1892ff2bf4b0a5f3ee22bce3fdd8f9488865aab28705527f19062d86f1848ecb94a107a63818c3c094c7c4a624cc10","tags":[["e","8536277b5d44700c12e4c1d2d3571f22d810bb90baa3559ae4cbba36e0f3b8dc","","root"],["p","526b4dba54b3f4a1bdac3548f0b8195e2b8ea36ba1920c801eb6388ed67de4ec"]]}]
|
||||
[14:02:46.930] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"GN https://blossom.primal.net/9e0dee7527fe3a20428bcfd20f1a3057f21991d0eb34b69b328a636a5a05a5b9.jpg","created_at":1759687367,"id":"e0415b2de12951a6b0b4274ad1c7898c6d4ff0ed3f5169dc2dd2329583aa6ac7","kind":1,"pubkey":"621889de151ed29c32424bfb150066dc274808dd8545898b62154e20595deab5","sig":"15821cd116d0086ce5e8d6ba7320eff13ccc27edaeba958e4e122d9b3123026aae17d2350e7f0ad4b1723b871e26b0b75980b3f0291a4a5ffc7306ed49c0a93e","tags":[["alt","A short note: GN https://blossom.primal.net/9e0dee7527fe3a20428b..."],["r","https://blossom.primal.net/9e0dee7527fe3a20428bcfd20f1a3057f21991d0eb34b69b328a636a5a05a5b9.jpg"],["imeta","url https://blossom.primal.net/9e0dee7527fe3a20428bcfd20f1a3057f21991d0eb34b69b328a636a5a05a5b9.jpg","x 9e0dee7527fe3a20428bcfd20f1a3057f21991d0eb34b69b328a636a5a05a5b9","size 1296120","m image/jpeg","dim 4032x3024","blurhash #nH2G--TWAR-WCoLoeofj@_NodjYfkayj[fPj[fQJqR+oes.oeazWCWCazE3WXj[j@j[azf6f6f7V@ofWVafayjtj[j[j@%0oeayf6f6j[bHbHa|t6ayj[j[j[a|ayaya|","ox 9e0dee7527fe3a20428bcfd20f1a3057f21991d0eb34b69b328a636a5a05a5b9","alt "]]}]
|
||||
[14:02:56.059] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"#hipwaist ratios \nhttps://images2.imgbox.com/b1/0c/wCxDWNqC_o.jpg \n#JoyOfLife ","created_at":1759687364,"id":"7c2f33b25929cc70c60f0165b5fde62753bdde14a5a9daad012073f7189919b5","kind":1,"pubkey":"ebb93aa6c2d04d7368ba52ef69884bf6e5779d7e418187e33371a20c7d9e5f6f","sig":"bb0c6ea5bd499637d454459a349aeddf10594af224ab12ded0fb3152ee17f53e7a75c6c784cabb2e8ad4d9c59c1f2bd1ed21f3ef31c674fd82f9a8d3e43e4cc2","tags":[]}]
|
||||
[14:03:03.608] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"ほろ酔いマスカットティーサワーを飲んでいます","created_at":1759687383,"id":"df1a4aa1e449f96295902ac73d6f85dbb10273a063a91de90406522cf78ae98b","kind":1,"pubkey":"e62f27d2814a25171c466d2d7612ad1a066db1362b4e259db5c076f9e6b21cb7","sig":"3a6e49bad5b31a5218465c9bf9fbe4dba46731fefc4ad09e85139d256f471904662397b9100aec8beedb3635324356ea25370c957543b7e47fb75817db70c1f6","tags":[]}]
|
||||
[14:03:07.944] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"🟠 BTC: $123,118\n⛏️ Hashrate: 1109744.2 EH/s\n📦 Mempool size: 38.97 MB\n💸 Fees (sat/vB): low 1, med 3, high 4\n📊 Fear & Greed Index: 74 (Greed)\n#bitcoin #stats","created_at":1759687387,"id":"2ffa7922bb8706b4961a56cea3a4df70c85b79f2a366d9add75e65a23ed44cfb","kind":1,"pubkey":"e185c2ad0b87b3207ac2b96d6b8fb1ff10fbf25f93eef4d04fb6dbb9039f19fb","sig":"fe684f31bc65d3a7f524d9ad2c437cab752c18f05c5332761f35cbb67894a62a4c58efc5c94dedf285357e4fdc3c7f31c2a93818e1aed9745983de272c56a1cc","tags":[]}]
|
||||
[14:03:11.336] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"Fees incentivize long-term security. #bitcoinfees | BTC: $123,109 | Educational Post","created_at":1759687390,"id":"f1d0cb6a9409534a33320905a34ab1569a46e3f2d5cf429f669002dea789ec38","kind":1,"pubkey":"e185c2ad0b87b3207ac2b96d6b8fb1ff10fbf25f93eef4d04fb6dbb9039f19fb","sig":"34c033fa98e7248e7b4f038fd0180ca52b9309be707d3b6d33c9dbc6234ec5abecfd5dffb5d3ec053c6e58829c74ccda6369bcabcc89cfaff278451bafc23525","tags":[]}]
|
||||
[14:03:15.656] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"📈 BTC Price Last 7 Days #bitcoin #chart\n\n(Chart could not be uploaded)","created_at":1759687395,"id":"aa169c771966a25c3b6342868d8f3d903b22c1c778cc44d8d3c26c8d5141b5e4","kind":1,"pubkey":"e185c2ad0b87b3207ac2b96d6b8fb1ff10fbf25f93eef4d04fb6dbb9039f19fb","sig":"057ad92d9597617646ebf4c6acc0b428ac3e3b95e6c1cb6789a61900f1c385513441a0b380bb43af8b683f93f33837f6a195c94e3905bed6ef3556fab0d68397","tags":[]}]
|
||||
[14:03:16.063] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"Anybody lurk on \"X\" using nitter?","created_at":1759687397,"id":"abc512ddf94c69c4311c5d3067d43d6359d679daaa2655fb80a228a9428b0272","kind":1,"pubkey":"fd31d0a4910f7ce9c46ac63df62781a9981e79a11de16d1664f1feb14f6a8c94","sig":"8abeb53756cea6e042172ffaba2158d824f62accc795bc1d9b4b360b5b7060ad45ec550a39fc456d7f19dce4c06a6b92be61199f10af3ecb8b0077c9cc3768a0","tags":[]}]
|
||||
[14:03:19.498] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"😳","created_at":1759687399,"id":"2bd27d8cc846e0fb6ef37df032f3a26cdab82c837c9ec5e5845b3c0df0b0fa84","kind":1,"pubkey":"8fda2199c4399fad7ff4126b402f1f5ee157fdbe4c0951e64dfe31aaec877ff1","sig":"dc584de809ae64fabb33f3e4ddc677f8e94c6c3639931e9e600cd83804b3d6085eaf3dd591b3d5ff4b20e08baeec30904c7cee156a30d92c9fe5f99ed621c246","tags":[["e","0cd929d752df6c6f50071054986bcd34e4618e2c24c9d943cf66dd3e5d7ccc3f","wss://relay.damus.io/","root","8fda2199c4399fad7ff4126b402f1f5ee157fdbe4c0951e64dfe31aaec877ff1"],["e","e27f1ec0adeba973bd0858b76e74836df2d68fc57fc003ec3fb0f1603280f660","","reply"],["p","cdecc31c6d9406e9a7d6b0067412aa661d9d31c8035c3fd65c06301d1cac3b92","","mention"]]}]
|
||||
[14:03:22.260] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"Looks like a great time, good luck. \n\n","created_at":1759687402,"id":"e9430e5efb1beb33963c112d0d92387d4165ae41d66e81439a2405630b1ae129","kind":1,"pubkey":"9ce3f065a7f384c1927263b968726d08e3895b5823be6e322545e89c3ee31a15","sig":"670788f0c36701cbfddfc101c64134b4eee98225bbf31d982afb2e90a617278ba84c00a9bb530ccded4d2e0bee347c9620298791bedb9894bfe379e3b82ecea0","tags":[["p","15652c499840af95bf52d8eb93bfbdd734b92d40f21c4eb974b124e5997d57cb","wss://relay.primal.net"],["e","a411057eb22fe7ceda41de50d34259f974ff434e370b157ac51850b4802d31ba","wss://relay.primal.net","root","15652c499840af95bf52d8eb93bfbdd734b92d40f21c4eb974b124e5997d57cb"]]}]
|
||||
[14:03:30.391] SEND localhost:7555: ["EVENT", {
|
||||
"pubkey": "17323141f3a98b014f96ee85df59ee1ce6295e1502644c8e1f86439b20908198",
|
||||
"created_at": 1759687410,
|
||||
"kind": 1,
|
||||
"tags": [],
|
||||
"content": "Test post at 2025-10-05 14:03:30",
|
||||
"id": "8433206a6e00ff021ddd1f162af38bf724aabd6a7ca5fb9e57bda74f26d46e3a",
|
||||
"sig": "058a3bc6872e44e8d30cfba1d75267929ec3d73fbafa4c77f99897b700020a42478b51ee3bf4a4901beb376b9d3deca2854b3bca2f18eab169f9f5babdfeccb6"
|
||||
}]
|
||||
[14:03:30.394] RECV localhost:7555: ["EVENT", "pool_1_1759687332", {
|
||||
"pubkey": "17323141f3a98b014f96ee85df59ee1ce6295e1502644c8e1f86439b20908198",
|
||||
"created_at": 1759687410,
|
||||
"kind": 1,
|
||||
"tags": [],
|
||||
"content": "Test post at 2025-10-05 14:03:30",
|
||||
"id": "8433206a6e00ff021ddd1f162af38bf724aabd6a7ca5fb9e57bda74f26d46e3a",
|
||||
"sig": "058a3bc6872e44e8d30cfba1d75267929ec3d73fbafa4c77f99897b700020a42478b51ee3bf4a4901beb376b9d3deca2854b3bca2f18eab169f9f5babdfeccb6"
|
||||
}]
|
||||
[14:03:30.394] RECV localhost:7555: EVENT", "pool_1_1759687332", {
|
||||
"pubkey": "17323141f3a98b014f96ee85df59ee1ce6295e1502644c8e1f86439b20908198",
|
||||
"created_at": 1759687410,
|
||||
"kind": 1,
|
||||
"tags": [],
|
||||
"content": "Test post at 2025-10-05 14:03:30",
|
||||
"id": "8433206a6e00ff021ddd1f162af38bf724aabd6a7ca5fb9e57bda74f26d46e3a",
|
||||
"sig": "058a3bc6872e44e8d30cfba1d75267929ec3d73fbafa4c77f99897b700020a42478b51ee3bf4a4901beb376b9d3deca2854b3bca2f18eab169f9f5babdfeccb6"
|
||||
}]2a
|
||||
[14:03:30.746] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"You will eventually","created_at":1759687410,"id":"f8bad59298e8afa0cceb9a4dee73c28648b62846b1fedc13b450316b29e3c460","kind":1,"pubkey":"8a719d42268aa925f6b12bcbe6b645f6ec82efe64eac91daf935fdcccf1f0fe5","sig":"4313cc6ee55b482e67f9a1f2e33761b9c68158b59eee38419d540ce5bb6564f2d5982428e0cde14c260edc4354a9c2cd3f0b848f7dca25af8f5b8930b9577f1e","tags":[["alt","A short note: You will eventually"],["e","c2d6913771cbbbdd3fefaf8f016a142841b5d00278bd16359c6e011ec1a33539","wss://relay.snort.social/","root","341db5a7e3a931f49095d82a4acc939cf8a67293b1e4179fd4b5c0544c4fc2ef"],["e","c0c29a6a16ed277868962e6664c07a8be2afd416c8b0212c9f17eff1a073ac15","wss://sendit.nosflare.com/","","8a719d42268aa925f6b12bcbe6b645f6ec82efe64eac91daf935fdcccf1f0fe5"],["e","291797f5b41d6a22e41b7001ddb8f68c60175408f13633d686f6f738366fa304","wss://nostr.mom/","reply","341db5a7e3a931f49095d82a4acc939cf8a67293b1e4179fd4b5c0544c4fc2ef"],["p","341db5a7e3a931f49095d82a4acc939cf8a67293b1e4179fd4b5c0544c4fc2ef","wss://nostr.bitcoiner.social/"],["p","8a719d42268aa925f6b12bcbe6b645f6ec82efe64eac91daf935fdcccf1f0fe5","ws://agwwuih4l66mb6oxnqk42lfsubhatux3bmcnpmki6cd7nmx5lz2ys6yd.onion/"]]}]
|
||||
[14:03:34.291] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"お茶系のお酒あんまり得意じゃないんだけど、お茶って感じあんまりしないし大丈夫だった","created_at":1759687413,"id":"790a85a90ef5d2bfbd9c70fc1c54830333066477c63e0026ae304037e6272814","kind":1,"pubkey":"e62f27d2814a25171c466d2d7612ad1a066db1362b4e259db5c076f9e6b21cb7","sig":"47eea4b740aeba09a6ec595dd7fcd2d7a682d8091301a9cef3c014693ca639679eaabbca981030bbb23c7f683a9ee1faa7c18fc78a254d6b965b1723f77c8172","tags":[]}]
|
||||
[14:03:35.459] RECV nos.lol:443: ["EVENT","pool_1_1759687332",{"content":"No, this is Albuquerque, NM ","created_at":1759687415,"id":"edc6b801a73667504bb197b8315f9b4c0533f726c108f8932d3fdc31a6495553","kind":1,"pubkey":"da26e54b86c9a395a4233cbb540fe2aa93cdad4a9b657ed5a724efed5859d23d","sig":"b6b822662302cc6b21b09b6e50f3ecf45c09c90c3750b308e6e293f5037352bacd8e4f96706af43dfe584d9c6c295dc7a92420ab4262e73759af71f35e2bf25e","tags":[["e","021147fc341540353e9cf639b7d6d1ba28af3ece5cf0625484716b0228a9348d","wss://feeds.nostr.band/lang/en","root"],["e","0dc0f9c4a0f5f37d93742e7dcf7c0f9b72f9be48dd5503f49004975b0073c235","wss://relay.primal.net","reply"],["p","c1503e4a2ef14908127d373530480c133bd5a0d9bb47a4be4a25a41d8f27447c","","mention"]]}]
|
||||
[14:03:40.010] SEND nos.lol:443: ["EVENT", {
|
||||
"pubkey": "17323141f3a98b014f96ee85df59ee1ce6295e1502644c8e1f86439b20908198",
|
||||
"created_at": 1759687410,
|
||||
"kind": 1,
|
||||
"tags": [],
|
||||
"content": "Test post at 2025-10-05 14:03:30",
|
||||
"id": "8433206a6e00ff021ddd1f162af38bf724aabd6a7ca5fb9e57bda74f26d46e3a",
|
||||
"sig": "058a3bc6872e44e8d30cfba1d75267929ec3d73fbafa4c77f99897b700020a42478b51ee3bf4a4901beb376b9d3deca2854b3bca2f18eab169f9f5babdfeccb6"
|
||||
}]
|
||||
[14:03:40.207] RECV nos.lol:443: ["OK","8433206a6e00ff021ddd1f162af38bf724aabd6a7ca5fb9e57bda74f26d46e3a",true,""]
|
||||
[14:03:50.096] SEND localhost:7555: ["REQ", "pool_1_1759687332", {
|
||||
"kinds": [1],
|
||||
"since": 1759687324,
|
||||
"limit": 10
|
||||
}]
|
||||
[14:03:50.097] RECV localhost:7555: ["EVENT", "pool_1_1759687332", {
|
||||
"id": "8433206a6e00ff021ddd1f162af38bf724aabd6a7ca5fb9e57bda74f26d46e3a",
|
||||
"pubkey": "17323141f3a98b014f96ee85df59ee1ce6295e1502644c8e1f86439b20908198",
|
||||
"created_at": 1759687410,
|
||||
"kind": 1,
|
||||
"content": "Test post at 2025-10-05 14:03:30",
|
||||
"sig": "058a3bc6872e44e8d30cfba1d75267929ec3d73fbafa4c77f99897b700020a42478b51ee3bf4a4901beb376b9d3deca2854b3bca2f18eab169f9f5babdfeccb6",
|
||||
"tags": []
|
||||
}]
|
||||
[14:03:50.108] RECV localhost:7555: ["EOSE", "pool_1_1759687332"]
|
||||
|
||||
=== NOSTR WebSocket Debug Log Started ===
|
||||
[18:53:08.601] SEND localhost:7555: ["REQ", "pool_1_1759791188", {
|
||||
"kinds": [1],
|
||||
"since": 1759791185,
|
||||
"limit": 10
|
||||
}]
|
||||
[18:53:08.601] SEND nos.lol:443: ["REQ", "pool_1_1759791188", {
|
||||
"kinds": [1],
|
||||
"since": 1759791185,
|
||||
"limit": 10
|
||||
}]
|
||||
[18:53:08.648] RECV localhost:7555: ["EOSE", "pool_1_1759791188"]
|
||||
[18:53:08.783] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"🟩BUY BTC with USD\nPrice: 123770.37USD (-1%)\nBTC: 0.005 - 0.01\nUSD: 619 - 1238\nMethod: ACH\nCreated: 2025-10-06T22:52:29Z","created_at":1759791187,"id":"29689c1ef5366dfd01b5ecf9262b2da34cb02bafa1a8429bb6a490d04909d37d","kind":1,"pubkey":"832b77d5ecb09381ac37d75d6392424526d0923dced687b03d96ba03a5e3d55c","sig":"a5f9ea9b6867ee1be7ef756320fb156de99fe74187fbe6eb279481994e6633cea83e79d962ca01ff561be79172df352cc6a20e0db9cf7cc06c2e40b8361d374d","tags":[]}]
|
||||
[18:53:08.844] RECV nos.lol:443: ["EOSE","pool_1_1759791188"]
|
||||
[18:53:20.271] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"The Libertarians are the only political party promising to protect education choices in Australia. If you're a homeschooler the Libertarian party is the political party for you 🇦🇺 https://image.nostr.build/b5b36427856dfaee5ecdd4679977e6863a7cdc00ecef996d18b8b69b23c917c0.jpg ","created_at":1759791199,"id":"3da55d474418278f7ea7e5e08a853cc28d3dbf7e0f32f6f70636d6db80164b29","kind":1,"pubkey":"692b8a786c3be59c1e855a86e710215b35e32c55580500421407e740263f04cb","sig":"465d5819db53039d0c6b5d712c1bf1dc5611a4a3f49bfcf1ba6ac36d9f0eefd220f18a8cc43ef2522bf321882250ce5d660c42de4c8e839072ec5632269c2cbf","tags":[["imeta","url https://image.nostr.build/b5b36427856dfaee5ecdd4679977e6863a7cdc00ecef996d18b8b69b23c917c0.jpg","blurhash eXH-uqJU%zRP%f~BS4x]afxuR4xajEs:V@kW%LfkjZV[%MxttRNHkC","dim 1070x1338"],["r","https://image.nostr.build/b5b36427856dfaee5ecdd4679977e6863a7cdc00ecef996d18b8b69b23c917c0.jpg"]]}]
|
||||
[18:53:33.079] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"They are getting closer to realizing Bitcoin is the answer to physic.\n\nConservation without axiom is a big deal.","created_at":1759791212,"id":"87aadf3b737615ab0ba2208fdb7d61cbfa36f8bd4a31ed0c0c06f6818d724bf2","kind":1,"pubkey":"3c4f51561243524f307ed2ee272c7cf4a782404fbe3a176606043b6ad427ee77","sig":"8c832c83f784bdff2698021382b96acc63daa8ba605398044910cb4780222c4b37fb4eb90cb5322a2ae52dafd9db8d10fca3b7a99f3f2865386883427240c188","tags":[["e","81c9d02c125ae68ff39820d822de54ed6e8121e6804532f1bcd3afdd41e33c7a","wss://feeds.nostr.band/newstr","root"],["p","b4403b2415a020c20691bb18c51ada5acb64b71d2f60966cb3c78ba683542d4e","","mention"]]}]
|
||||
[18:53:34.774] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"一人称隣ニキで草 https://lumilumi.app/nevent1qvzqqqqqqypzq8tsnl8lcgukj2584c3t7mye5y835fc6ttz3s7kl9f3hvd2lf8d9qyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqqypyhsn5gs4l2dnkwjgy2rz9kerad0lw773xngw640cq4stafvr57cp7sfq0","created_at":1759791214,"id":"178b376d3ed06cbd316f4daad7c5c215e2dc5d9586fe742b7e24cc4156949463","kind":1,"pubkey":"a19caaa8404721584746fb0e174cf971a94e0f51baaf4c4e8c6e54fa88985eaf","sig":"ec377113c06d030e0202511744496383ca4cfc5fb468d6106dc0391728511db175e31c8b18be17bacf19937ec4967e948ca31e5c793ae65197900fbc14b489a6","tags":[["r","https://lumilumi.app/nevent1qvzqqqqqqypzq8tsnl8lcgukj2584c3t7mye5y835fc6ttz3s7kl9f3hvd2lf8d9qyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqqypyhsn5gs4l2dnkwjgy2rz9kerad0lw773xngw640cq4stafvr57cp7sfq0"],["client","lumilumi","31990:84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5:1727506446612","wss://relay.nostr.band"]]}]
|
||||
[18:53:35.041] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"How do people feel about #privacy apps that come from app stores vs direct from the developer? Even if the same developer? Does it make a difference? I'm trying to wrap my head around #Adnroid changes in the future...","created_at":1759791214,"id":"b997be2339010e78eb35747ad8b5e5e7ff9a352de0f6f143773e1a3888a865a9","kind":1,"pubkey":"8dc8688200b447ec2e4018ea5e42dc5d480940cb3f19ca8f361d28179dc4ba5e","sig":"67a82ec73da6eae1c157eaa8dea08b1ba0fccdc68c305c236150eeebd3f8aff1a897b52421b0821f9144dbbabe91032d7ad105d3b152f76638ae040f3e053668","tags":[]}]
|
||||
[18:53:44.914] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"please tell me this is satire. ","created_at":1759791224,"id":"93101e1379fc3564631bb22c1f92418e4a308453c00694229d66480e13e754f7","kind":1,"pubkey":"ff2ceb63833534d6e5b294b268501d62c53dcd2f05ee169f624ca1dc7cffe234","sig":"beee744a916041500fbe0cb2373f256948090ceafe3404a1b435544ea94ea392c70e5294cd56f02148556e4db6e6b81fc5274ac048200b8576610c04e4659278","tags":[["e","243c0fdc0879a37cb103dd8a9124889d40080741d67b04685409c7bfe2d445fb","wss://relay.mostr.pub/","root","11c63ffe2f02bce7e558470427deb0937d299af1140c4e24720804a1e0a7b08f"],["e","243c0fdc0879a37cb103dd8a9124889d40080741d67b04685409c7bfe2d445fb","wss://relay.mostr.pub/","reply","11c63ffe2f02bce7e558470427deb0937d299af1140c4e24720804a1e0a7b08f"],["p","11c63ffe2f02bce7e558470427deb0937d299af1140c4e24720804a1e0a7b08f"],["client","noStrudel","31990:266815e0c9210dfa324c6cba3573b14bee49da4209a9456f9484e5106cd408a5:1686066542546"]]}]
|
||||
[18:53:54.736] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"Transparency is in the favor of the people, not the greedy, slimy thieves who hide behind gov. https://image.nostr.build/8b5e9826ba98a2e90d0ae51a341bf20f6f525ea67ed4459d4dfe516c2a50c1ee.gif","created_at":1759791232,"id":"f0add365d13b283475f5aea939b6aa03b1dad5ecf363a7814249251f5e35c944","kind":1,"pubkey":"519d2fb3c354f44f5d4c7cdfc532633daf029bcc7d54beb0cb0f770646f8350f","sig":"6c7f8250e2f0efd421aa808760254a1d53d979c213efd23b0431c1ed634514ad6c7267762b2d3124df3e8925c0c557a899a4ddd4ec0f332276cde6b5ad6ea707","tags":[["r","https://image.nostr.build/8b5e9826ba98a2e90d0ae51a341bf20f6f525ea67ed4459d4dfe516c2a50c1ee.gif"],["imeta","url https://image.nostr.build/8b5e9826ba98a2e90d0ae51a341bf20f6f525ea67ed4459d4dfe516c2a50c1ee.gif","ox 8b5e9826ba98a2e90d0ae51a341bf20f6f525ea67ed4459d4dfe516c2a50c1ee","x 8707bfc0dacb4aafcc6f27d25639d93fe0c0ac4cafeea6ebbfb7c0aad9217ed9","m image/gif","dim 360x266","bh LH9s*cfk0eay~Vay4:ax-pfkIVWB","blurhash LH9s*cfk0eay~Vay4:ax-pfkIVWB","thumb https://image.nostr.build/thumb/8b5e9826ba98a2e90d0ae51a341bf20f6f525ea67ed4459d4dfe516c2a50c1ee.gif"]]}]
|
||||
[18:53:57.845] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"まずはピンク・フロイドを聴こうかなと思う","created_at":1759791237,"id":"fa7bfe34420bae341de5a1fc73bd2f4d5cb4283d6ab3b4c66dc697ebd5085ca5","kind":1,"pubkey":"f40832e26b1d12f8a27717b606996baef68bc4b6b86c4a35ca827f6fbcbf511e","sig":"0659b2963ff0e7c5e97e6a451ab572bcb0735f5371e8e20db3a82b0db555dcac449529c2cd0571f5c348ceb1f193a73a8437ec92062d4796b984c071e5b74542","tags":[]}]
|
||||
[18:54:03.482] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"#Bitcoin Block Art by Blockstr!\nHeight: 917953\nWeight: 3998184\nhttps://thebitcoinblockclock.com/blockstr/00000000000000000001707014fb634d4c3b44790f8e51da2fd89816d704d74c.png","created_at":1759791242,"id":"5342d9d61cf46692a331fe48c126bd671d8cf8b5fd0c99f8000669c7e606aeff","kind":1,"pubkey":"3fdf8b43d2e6eb59fc399f7cb1b81923d1dff0215d45a11e1c1f279827eaaad8","sig":"abaf2db95aafa23f9152cdf5f6a683c41696c732540d94e5da5ce0bece91dbc886c53a9d25be131eef93355456f857720eedbbfb26bb282eeba5347a360768a6","tags":[]}]
|
||||
[18:54:17.275] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"I would imagine hashrate goes up in northern countries where people mine4heat. But by how much I don’t know","created_at":1759791255,"id":"63e537f5b8047a577f3b3099295cc15916274e3e87997b65e54592e8166c1e30","kind":1,"pubkey":"18905d0a5d623ab81a98ba98c582bd5f57f2506c6b808905fc599d5a0b229b08","sig":"43c1092b80ab2fdd3c1dcdfd1a8bd47422be5b89d393ed8c8ad519d782a8ee9b137de2fe30ef6282c43e4882f9b57947d51bbaeb842fad03757d58c305d08af7","tags":[["p","18905d0a5d623ab81a98ba98c582bd5f57f2506c6b808905fc599d5a0b229b08","","mention"],["p","2b0ea532b3c3045d590c3dc982794d495d08bc497f554ccbcc30fcc8e9fbe2e9","","mention"],["e","d052b254eb2b402c4bc57035316885e4b5a39289083e69687408a5601123bea2","","root"],["e","6db869e46f7bdbaace29668104d99a0f1bbe91e2581a3b03dd53254f79159764","","reply"]]}]
|
||||
[18:54:18.389] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"I would recommend self-hosting with MusicSideProject.com to retain 100% control and 100% value sent to your songs. But if you're between Fountain and WL, Fountain shows the value splits in the RSS feed which is nice for listeners to see where their sats are flowing","created_at":1759791259,"id":"252cc6c9886902f4dfbdf9a120c14f7e1f4c7828fa3b0007445cbe93d1afe00b","kind":1,"pubkey":"2dfbe5cb955e4018b76e6542a3b8782144dd5f5735914db9921fd24c3b3d106d","sig":"f7db0d52d86e3099a0ddabe16eac696123f997ec6981a2fc51e32d24b3658eeb18e28086fd9460feccf96133b3a3b182ee31b6aaa420352c632607eb727f93fc","tags":[["alt","A short note: I would recommend self-hosting with MusicSideProje..."],["e","390de5cd45e4e0a8fae43ad405e6e194b4e23566ae66d0c145d7ea1e676cbb40","wss://nostr.oxtr.dev/","root","2b349bb9ae581ab6092365a16aef15c0ffc8f1a593e22f79b04fdb122543c1f9"],["e","49a3b9e700e684a0711184ecba7bb16b58ab5dba63feb0c27bb1ee6e80776331","wss://relay.damus.io/","reply","2c9a02818e5b9b4582c19823b69c55f5945e837aa9cc8342856f43b8ea61f979"],["p","2b349bb9ae581ab6092365a16aef15c0ffc8f1a593e22f79b04fdb122543c1f9","wss://zap.watch/"],["p","2c9a02818e5b9b4582c19823b69c55f5945e837aa9cc8342856f43b8ea61f979","wss://zap.watch/"],["r","https://musicsideproject.com/"]]}]
|
||||
[18:54:22.406] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"もう7時か、おはよう","created_at":1759791258,"id":"5fbce68be4f6fd34aca6115e294e5b790daf4ae210256556244b8ef33eff4b44","kind":1,"pubkey":"2bb2abbfc5892b7bda8f78d53682d913cc9a446b45e11929f0935d8fdfcb40bd","sig":"da49b572171e454aad4b9198443017dd25c1bd2e3313d5dac95931ea0db79198f47a29a31b0de7d9b20dd7e5fb0eac80916e00068b11a0c34c786e8ce50c8552","tags":[["e","cedbf52ea402b56b75069b64afeb7b9c9ce4e4063f607f76f715743e3a2b3707","","root","21ac29561b5de90cdc21995fc0707525cd78c8a52d87721ab681d3d609d1e2df"],["p","21ac29561b5de90cdc21995fc0707525cd78c8a52d87721ab681d3d609d1e2df"]]}]
|
||||
[18:54:23.521] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"Tell your family and friends you love them.\n\nI just had a friend pass away at 40 years old 😢\nHe was in pretty good health. I had known him for 35 years\n\nWe dont know when our time is up, enjoy the ride. Spend as much time as you can with loved ones. ","created_at":1759791262,"id":"dae2b9bb92b229a2b4e0cda21416a0545c5c87682c5e51bba909dce87db14298","kind":1,"pubkey":"7a6b8c7de171955c214ded7e35cc782cd6dddfd141abb1929c632f69348e6f49","sig":"bd3a18aa715ae940cc4744112abcc4e5b388bb6c351aaa559bd420e1b1336c1141824789645810d0f9ce7bcf49ef79922e6bee99367949ee14d616724fca928b","tags":[]}]
|
||||
[18:54:25.794] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"Personal experience agrees. Health took a very big, very noticeable dive after returning to America, from a country that bans the poisons.","created_at":1759791266,"id":"d31f8840cc9b9243e516aade74ced33dc37ce304f308ffaad19bcb786b6dd22c","kind":1,"pubkey":"55f573b651eff351db57b0601d23022d8c532f9825db10a5733ebf39be4aa21b","sig":"bdb42e44b1647cd77b59b8a3f01308aa8df89a1503b6c5d4984bd79ad4c20d50d6c4615589866985235719512519c54ec7ca863bca5f4f6cb8f9e19ae7e908cc","tags":[["e","0499a028291e2a5fff5cad342d19e985e4e1d16bc92170fd3ae4d700f5add047","","root"],["p","45b35521c312a5da4c2558703ad4be3d2e6d08c812551514c7a1eb7ab5fa0f04"],["p","da19b5d291e06ed09ba545bc5366408dc82ba8c9e9f97d32ea8ea60f1f6cbfaa"]]}]
|
||||
[18:54:26.842] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"08:02 @ 917,953","created_at":1759791266,"id":"17aaebb2d9e3d4b1cbb0eb085f0d031c91c8b982eb182b9c1737467ac312eba1","kind":1,"pubkey":"7c5f24e1c95f6f1f75555498f0019be1259a65c75ae851c235f7b15c9f88e0ee","sig":"5f216afb163dedf705741149fc4a7b1d3c7586eb61ff90aca6d78d08ef5e3a050e97c3e1628ad126b1d26b38c4236e3b6cd7b12799ef6129649d27f16bcd75b3","tags":[["t","bitcoin"],["t","moscowtime"],["t","nostr"]]}]
|
||||
[18:54:31.689] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":" \n\n\n\nhttps://blossom.primal.net/f69a2025125ef2f239621f96a9318f227df567f11db9aded4b57469e298e3317.mp4","created_at":1759791275,"id":"d89fe8ddd5874c17453cc6c8c9a23caae43d2e3fba6dc580d4b2527d3e00a240","kind":1,"pubkey":"e3a59924933c9f9f2df83449055eb3858f1480fdd0c5edb95df08bedcd2e6624","sig":"d1476ff7f3d3aac8aa042700fd4879f4d8c700294b0435fb63da314025aaaa03a5c2fc4e7ce2dd863a23779a007e6076b44b7286ca612f3d959a759b4ce79a03","tags":[]}]
|
||||
[18:54:36.744] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"去中心化“公链”的基本判断标准:\n节点门槛——低,众易上链;\n共识机制——牢,广受支持;\n代码开源——全,行为透明;\n治理机制——简,长链佐证;\n通证分布——散,没有寡头。\n#去中心化 #Decentralization\n#心空化\nhttps://cdn.nostrcheck.me/382d67ec6a31dc8d0c5b3099753a0044261a70e694aadd49eb58fce529cb3089/336be1277293f2d53fb97ab301957736be3e0a82eb16626e625bb9a2e1d26cd4.webp","created_at":1759791265,"id":"c37b409b25a77db2d43e19c85b957ceccd4650b04d1ad51130f00fc526a003ee","kind":1,"pubkey":"382d67ec6a31dc8d0c5b3099753a0044261a70e694aadd49eb58fce529cb3089","sig":"8116df2ad43a6126f68c6f26c5a8ba2a861227a76ff67123677113cf5f2319da7f558b94be946b80f7b49a9a13ed1edd422fa799346bf8cb6e9def3d9f4c9881","tags":[["imeta","url https://cdn.nostrcheck.me/382d67ec6a31dc8d0c5b3099753a0044261a70e694aadd49eb58fce529cb3089/336be1277293f2d53fb97ab301957736be3e0a82eb16626e625bb9a2e1d26cd4.webp","dim 827x814","sha256 336be1277293f2d53fb97ab301957736be3e0a82eb16626e625bb9a2e1d26cd4"],["t","去中心化"],["t","Decentralization"],["t","decentralization"],["t","心空化"],["client","Nostur","31990:9be0be0fc079548233231614e4e1efc9f28b0db398011efeecf05fe570e5dd33:1685868693432"]]}]
|
||||
[18:54:37.706] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"nostr:nprofile1qqszzf4msf9pxddg4hkre9a4ehdc67m9yhvapzg86chvs0enyzw80qqpypmhxue69uhky6t5vdhkjmndv9uxjmtpd35hxarn9ehkumrfdejj7qgkwaehxw309ajkgetw9ehx7um5wghxcctwvshsq3d5s2 \n\n","created_at":1759791276,"id":"4a5c21b093bc6b01a7535759e2bed8618876c00e97160d59867115306e8a7a7b","kind":1,"pubkey":"f6150173b5d6f079b43540d84a8a95d50cf01a48c9d6037984e3d9600d5522af","sig":"cfd5476a1a8477842fdbe66cc5d962f3a2e61f7909e94c36ce05557a4d740d0a69e99c72a4fedccfeb703083afdd3863b828688415efb5d25474dde74c61b1f1","tags":[["p","2126bb824a1335a8adec3c97b5cddb8d7b6525d9d08907d62ec83f33209c7780","wss://bitcoinmaximalists.online/","mention"],["p","683211bd155c7b764e4b99ba263a151d81209be7a566a2bb1971dc1bbd3b715e","wss://nos.lol/%20wss://nostr.land/%20%20avatar%20wss://nostr.wine/%20%20avatar%20wss://purplerelay.com/%20wss://relay.damus.io/%20wss://relay.snort.social/"],["e","be2ddd66a3d151a5fa6a38c0a43ffd4de5b20357abaf28b11954102348664624","wss://nos.lol/%20wss://nostr.land/%20%20avatar%20wss://nostr.wine/%20%20avatar%20wss://purplerelay.com/%20wss://relay.damus.io/%20wss://relay.snort.social/","root","683211bd155c7b764e4b99ba263a151d81209be7a566a2bb1971dc1bbd3b715e"]]}]
|
||||
[18:54:40.101] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"Day 67 of the $10/day DCA Tracker\n\nToday’s Results:\nBest Performer: Ethereum (+4.11%)\nWorst Performer: REIT (-0.94%)\n\n*graphic shows performance based on the total time since invested. It's tracking how a consistent $10/day DCA performs in each asset over time so you can see cumulative returns, not just daily fluctuations.\n\nFollow along for the ride!\nhttps://blossom.primal.net/659442920b5bf5f07fd154c896d20ea6433ad009e71cffe7aa83332837d98aec.png\n\n","created_at":1759791279,"id":"d9a4b37ca9b5c9fd6a7092cb95fd9d53f4b38ef257a9d4ca45a16ba94aaaf9ef","kind":1,"pubkey":"fac513a1ceded1eabc7407c12997485de8bbb28eddecefa016817fc8d4f407a5","sig":"e3ddab44f0f4e50ff45a72f56000a0d667290697017f93c093a901773c04c029c8060bd0261eff623c745b036332547d56ebcfb59498d9537f27d4fbdde569be","tags":[["r","wss://brb.io/"],["r","wss://eden.nostr.land/"],["r","wss://nos.lol/"],["r","wss://nostr.orangepill.dev/"],["r","wss://nostr.wine/"],["r","wss://relay.current.fyi/"],["r","wss://relay.damus.io/"],["r","wss://relay.snort.social/"],["client","Primal Studio"]]}]
|
||||
[18:54:42.363] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"GM ☕ 🌅👊","created_at":1759791281,"id":"0d89586ceaa523256647c1089090a7ad097b86a05c502f14772ea2a835fd9713","kind":1,"pubkey":"2822d3a6ae22a0af31193b03f2b2e84b5b2060bccdbefc0ee6696e128a3513bf","sig":"8205dfac792fd37147771dcd77a4b80fe68b6d41680727af7864090c4a5494270dbf7beccebe14e4fc773047ddc04a0b7af5bc3a72837a86085b86059b5a7f3c","tags":[["e","4024ce568c85efe6fc177367976f48bb080717589498fa7f8d5d4e1d0c17b3dd","wss://nostr-verified.wellorder.net","root"],["p","2c65940725bbf10bfbbf52b76c41606754441264f707d3d9cc1ceab86d73fd7f","","mention"]]}]
|
||||
[18:55:00.398] RECV nos.lol:443: ["EVENT","pool_1_1759791188",{"content":"✄------------ 7:55 ------------✄","created_at":1759791300,"id":"9ef33fbe34d3efe55cb9e4b4cd3b1281da6770c3b65ac761b260214937f3aa48","kind":1,"pubkey":"3ce2b51dca8b67b69c0ccb7c6a226437f7dbcc44a32426e70e52c78336fc72c7","sig":"dc83b7d49a2567540434f3041d5219e8c02c5f58566c6ff8a2b22e6c5e95391d1dc9f0244a149124d3aeeb2ec38515daef837656861cfd2f45f16dfc479fe30c","tags":[]}]
|
||||
[18:55:03.089] SEND localhost:7555: ["CLOSE", "pool_1_1759791188"]
|
||||
[18:55:03.089] SEND nos.lol:443: ["CLOSE", "pool_1_1759791188"]
|
||||
|
||||
=== NOSTR WebSocket Debug Log Started ===
|
||||
[05:52:03.588] SEND localhost:7555: ["REQ", "pool_1_1759830723", {
|
||||
"limit": 10
|
||||
}]
|
||||
[05:52:03.589] RECV localhost:7555: ["EVENT", "pool_1_1759830723", {
|
||||
"id": "8433206a6e00ff021ddd1f162af38bf724aabd6a7ca5fb9e57bda74f26d46e3a",
|
||||
"pubkey": "17323141f3a98b014f96ee85df59ee1ce6295e1502644c8e1f86439b20908198",
|
||||
"created_at": 1759687410,
|
||||
"kind": 1,
|
||||
"content": "Test post at 2025-10-05 14:03:30",
|
||||
"sig": "058a3bc6872e44e8d30cfba1d75267929ec3d73fbafa4c77f99897b700020a42478b51ee3bf4a4901beb376b9d3deca2854b3bca2f18eab169f9f5babdfeccb6",
|
||||
"tags": []
|
||||
}]
|
||||
[05:52:03.599] RECV localhost:7555: ["EVENT", "pool_1_1759830723", {
|
||||
"id": "ec98292f570049ed00ae541cba716dcf6c8252b523ce036d9d3d79946ff62927",
|
||||
"pubkey": "aa3b44608a9e52473a631d596c395dd297443237d56e34e31bdcd4272a1cf558",
|
||||
"created_at": 1759687283,
|
||||
"kind": 1,
|
||||
"content": "Test post at 2025-10-05 14:01:23",
|
||||
"sig": "3e5ffa59e881c4e772e3c0e65b26d5396b7687de2ae8e930b505fc2617ecfa4b392df32b3af41f8c989e5cb1eeb00d5c1fbedfba2729eb43a3838e49ebfffc8f",
|
||||
"tags": []
|
||||
}]
|
||||
[05:52:03.610] RECV localhost:7555: ["EVENT", "pool_1_1759830723", {
|
||||
"id": "c70d6c5c8745c088bd3b99e5f529bb69cd3d162cb9db28aa433a798fa8d811c3",
|
||||
"pubkey": "2a0c81450868960944c17b0f57f6aa2b5307b56bc8d9cc1b213674c561a3ab85",
|
||||
"created_at": 1759687249,
|
||||
"kind": 1,
|
||||
"content": "Test post at 2025-10-05 14:00:49",
|
||||
"sig": "76ac20012e84d49a528db140e48024d6a390033df75bfbad64e822208a6a4a3f863b84860da8bcf78c6d8c8933e30fba92f11ebca5f4602ba4428b10584c7ceb",
|
||||
"tags": []
|
||||
}]
|
||||
[05:52:03.620] RECV localhost:7555: ["EVENT", "pool_1_1759830723", {
|
||||
"id": "15dbe2cfe9237b93992a3b4de9d90224032e8b613031748da92c46c1aeaa2e9c",
|
||||
"pubkey": "7c2065299249ff1b4316c07af0d03d67ad145da80b907cc22aa608218c6d2687",
|
||||
"created_at": 1759687219,
|
||||
"kind": 1,
|
||||
"content": "Test post at 2025-10-05 14:00:19",
|
||||
"sig": "c0aa610658d8cfd76aca25894276a7f3f0573c2993429feff8b1ff10eeb5608ff18cfd79126de5f54e77f5b45a9d39f9006df65b56e4246e50cf72d212509569",
|
||||
"tags": []
|
||||
}]
|
||||
[05:52:03.631] RECV localhost:7555: ["EOSE", "pool_1_1759830723"]
|
||||
[05:52:31.497] SEND localhost:7555: ["REQ", "pool_2_1759830751", {
|
||||
"since": 1759830747,
|
||||
"limit": 10
|
||||
}]
|
||||
[05:52:31.498] RECV localhost:7555: ["EOSE", "pool_2_1759830751"]
|
||||
[14:47:46.012] SEND localhost:7555: ["REQ", "pool_1_1759687332", {
|
||||
"kinds": [1],
|
||||
"since": 1759687324,
|
||||
"limit": 10
|
||||
}]
|
||||
[14:47:48.014] SEND localhost:7555: ["REQ", "pool_1_1759830723", {
|
||||
"limit": 10
|
||||
}]
|
||||
[14:47:48.014] SEND localhost:7555: ["REQ", "pool_2_1759830751", {
|
||||
"since": 1759830747,
|
||||
"limit": 10
|
||||
}]
|
||||
|
||||
Binary file not shown.
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#define _DEFAULT_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -109,7 +110,7 @@ void* poll_thread_func(void* arg) {
|
||||
// Print menu
|
||||
void print_menu() {
|
||||
printf("\n=== NOSTR Relay Pool Test Menu ===\n");
|
||||
printf("1. Start Pool (wss://relay.laantungir.net)\n");
|
||||
printf("1. Start Pool (ws://localhost:7555)\n");
|
||||
printf("2. Stop Pool\n");
|
||||
printf("3. Add relay to pool\n");
|
||||
printf("4. Remove relay from pool\n");
|
||||
@@ -117,7 +118,8 @@ void print_menu() {
|
||||
printf("6. Remove subscription\n");
|
||||
printf("7. Show pool status\n");
|
||||
printf("8. Test reconnection (simulate disconnect)\n");
|
||||
printf("9. Exit\n");
|
||||
printf("9. Publish Event\n");
|
||||
printf("0. Exit\n");
|
||||
printf("Choice: ");
|
||||
}
|
||||
|
||||
@@ -405,11 +407,24 @@ void show_pool_status() {
|
||||
|
||||
printf("├── %s: %s\n", relay_urls[i], status_str);
|
||||
|
||||
// Show connection and publish error details
|
||||
const char* conn_error = nostr_relay_pool_get_relay_last_connection_error(pool, relay_urls[i]);
|
||||
const char* pub_error = nostr_relay_pool_get_relay_last_publish_error(pool, relay_urls[i]);
|
||||
|
||||
if (conn_error) {
|
||||
printf("│ ├── Connection error: %s\n", conn_error);
|
||||
}
|
||||
if (pub_error) {
|
||||
printf("│ ├── Last publish error: %s\n", pub_error);
|
||||
}
|
||||
|
||||
const nostr_relay_stats_t* stats = nostr_relay_pool_get_relay_stats(pool, relay_urls[i]);
|
||||
if (stats) {
|
||||
printf("│ ├── Events received: %d\n", stats->events_received);
|
||||
printf("│ ├── Connection attempts: %d\n", stats->connection_attempts);
|
||||
printf("│ ├── Connection failures: %d\n", stats->connection_failures);
|
||||
printf("│ ├── Events published: %d (OK: %d, Failed: %d)\n",
|
||||
stats->events_published, stats->events_published_ok, stats->events_published_failed);
|
||||
printf("│ ├── Ping latency: %.2f ms\n", stats->ping_latency_current);
|
||||
printf("│ └── Query latency: %.2f ms\n", stats->query_latency_avg);
|
||||
}
|
||||
@@ -422,6 +437,148 @@ void show_pool_status() {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
// Async publish callback context
|
||||
typedef struct {
|
||||
int total_relays;
|
||||
int responses_received;
|
||||
int success_count;
|
||||
time_t start_time;
|
||||
} async_publish_context_t;
|
||||
|
||||
// Async publish callback - called for each relay response
|
||||
void async_publish_callback(const char* relay_url, const char* event_id,
|
||||
int success, const char* message, void* user_data) {
|
||||
async_publish_context_t* ctx = (async_publish_context_t*)user_data;
|
||||
|
||||
ctx->responses_received++;
|
||||
if (success) {
|
||||
ctx->success_count++;
|
||||
}
|
||||
|
||||
// Calculate elapsed time
|
||||
time_t now = time(NULL);
|
||||
double elapsed = difftime(now, ctx->start_time);
|
||||
|
||||
// Log to file with real-time feedback
|
||||
char timestamp[26];
|
||||
ctime_r(&now, timestamp);
|
||||
timestamp[24] = '\0';
|
||||
|
||||
if (success) {
|
||||
printf("✅ %s: Published successfully (%.1fs)\n", relay_url, elapsed);
|
||||
dprintf(log_fd, "[%s] ✅ ASYNC: %s published successfully (%.1fs)\n",
|
||||
timestamp, relay_url, elapsed);
|
||||
} else {
|
||||
printf("❌ %s: Failed - %s (%.1fs)\n", relay_url, message ? message : "unknown error", elapsed);
|
||||
dprintf(log_fd, "[%s] ❌ ASYNC: %s failed - %s (%.1fs)\n",
|
||||
timestamp, relay_url, message ? message : "unknown error", elapsed);
|
||||
}
|
||||
|
||||
// Show progress
|
||||
printf(" Progress: %d/%d responses received\n", ctx->responses_received, ctx->total_relays);
|
||||
|
||||
if (ctx->responses_received >= ctx->total_relays) {
|
||||
printf("\n🎉 All relays responded! Final result: %d/%d successful\n",
|
||||
ctx->success_count, ctx->total_relays);
|
||||
dprintf(log_fd, "[%s] 🎉 ASYNC: All relays responded - %d/%d successful\n\n",
|
||||
timestamp, ctx->success_count, ctx->total_relays);
|
||||
}
|
||||
}
|
||||
|
||||
// Publish test event with async callbacks
|
||||
void publish_event() {
|
||||
if (!pool) {
|
||||
printf("❌ Pool not started\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\n--- Publish Test Event ---\n");
|
||||
|
||||
// Generate random keypair
|
||||
unsigned char private_key[32], public_key[32];
|
||||
if (nostr_generate_keypair(private_key, public_key) != NOSTR_SUCCESS) {
|
||||
printf("❌ Failed to generate keypair\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get current timestamp
|
||||
time_t now = time(NULL);
|
||||
|
||||
// Format content with date/time
|
||||
char content[256];
|
||||
struct tm* tm_info = localtime(&now);
|
||||
strftime(content, sizeof(content), "Test post at %Y-%m-%d %H:%M:%S", tm_info);
|
||||
|
||||
// Create kind 1 event
|
||||
cJSON* event = nostr_create_and_sign_event(1, content, NULL, private_key, now);
|
||||
if (!event) {
|
||||
printf("❌ Failed to create event\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get relay URLs from pool
|
||||
char** relay_urls = NULL;
|
||||
nostr_pool_relay_status_t* statuses = NULL;
|
||||
int relay_count = nostr_relay_pool_list_relays(pool, &relay_urls, &statuses);
|
||||
|
||||
if (relay_count <= 0) {
|
||||
printf("❌ No relays in pool\n");
|
||||
cJSON_Delete(event);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("📤 Publishing event to %d relay(s)...\n", relay_count);
|
||||
printf("Watch for real-time responses below:\n\n");
|
||||
|
||||
// Setup callback context
|
||||
async_publish_context_t ctx = {0};
|
||||
ctx.total_relays = relay_count;
|
||||
ctx.start_time = time(NULL);
|
||||
|
||||
// Log the event
|
||||
char* event_json = cJSON_Print(event);
|
||||
char timestamp[26];
|
||||
ctime_r(&now, timestamp);
|
||||
timestamp[24] = '\0';
|
||||
dprintf(log_fd, "[%s] 📤 Publishing test event\n", timestamp);
|
||||
dprintf(log_fd, "Event: %s\n\n", event_json);
|
||||
free(event_json);
|
||||
|
||||
// Publish using async function
|
||||
int sent_count = nostr_relay_pool_publish_async(pool, (const char**)relay_urls,
|
||||
relay_count, event,
|
||||
async_publish_callback, &ctx);
|
||||
|
||||
if (sent_count > 0) {
|
||||
printf("📡 Event sent to %d/%d relays, waiting for responses...\n\n",
|
||||
sent_count, relay_count);
|
||||
|
||||
// Wait for all responses or timeout (10 seconds)
|
||||
time_t wait_start = time(NULL);
|
||||
while (ctx.responses_received < ctx.total_relays &&
|
||||
(time(NULL) - wait_start) < 10) {
|
||||
// Let the polling thread process messages
|
||||
usleep(100000); // 100ms
|
||||
}
|
||||
|
||||
if (ctx.responses_received < ctx.total_relays) {
|
||||
printf("\n⏰ Timeout reached - %d/%d relays responded\n",
|
||||
ctx.responses_received, ctx.total_relays);
|
||||
}
|
||||
} else {
|
||||
printf("❌ Failed to send event to any relays\n");
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
for (int i = 0; i < relay_count; i++) {
|
||||
free(relay_urls[i]);
|
||||
}
|
||||
free(relay_urls);
|
||||
free(statuses);
|
||||
cJSON_Delete(event);
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Setup logging to file
|
||||
log_fd = open("pool.log", O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
@@ -489,14 +646,14 @@ int main() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (nostr_relay_pool_add_relay(pool, "wss://relay.laantungir.net") != NOSTR_SUCCESS) {
|
||||
if (nostr_relay_pool_add_relay(pool, "ws://localhost:7555") != NOSTR_SUCCESS) {
|
||||
printf("❌ Failed to add default relay\n");
|
||||
nostr_relay_pool_destroy(pool);
|
||||
pool = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
printf("✅ Pool started with wss://relay.laantungir.net\n");
|
||||
printf("✅ Pool started with ws://localhost:7555\n");
|
||||
|
||||
now = time(NULL);
|
||||
ctime_r(&now, timestamp);
|
||||
@@ -544,13 +701,49 @@ int main() {
|
||||
if (url && strlen(url) > 0) {
|
||||
if (nostr_relay_pool_add_relay(pool, url) == NOSTR_SUCCESS) {
|
||||
printf("✅ Relay added: %s\n", url);
|
||||
printf("⏳ Attempting to connect...\n");
|
||||
|
||||
// Give it a moment to attempt connection
|
||||
sleep(2);
|
||||
|
||||
// Check connection status and show any errors
|
||||
nostr_pool_relay_status_t status = nostr_relay_pool_get_relay_status(pool, url);
|
||||
const char* error_msg = nostr_relay_pool_get_relay_last_connection_error(pool, url);
|
||||
|
||||
switch (status) {
|
||||
case NOSTR_POOL_RELAY_CONNECTED:
|
||||
printf("🟢 Successfully connected to %s\n", url);
|
||||
break;
|
||||
case NOSTR_POOL_RELAY_CONNECTING:
|
||||
printf("🟡 Still connecting to %s...\n", url);
|
||||
break;
|
||||
case NOSTR_POOL_RELAY_DISCONNECTED:
|
||||
printf("⚪ Disconnected from %s\n", url);
|
||||
if (error_msg) {
|
||||
printf(" Last error: %s\n", error_msg);
|
||||
}
|
||||
break;
|
||||
case NOSTR_POOL_RELAY_ERROR:
|
||||
printf("🔴 Connection error for %s\n", url);
|
||||
if (error_msg) {
|
||||
printf(" Error details: %s\n", error_msg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("❓ Unknown status for %s\n", url);
|
||||
break;
|
||||
}
|
||||
|
||||
now = time(NULL);
|
||||
ctime_r(&now, timestamp);
|
||||
timestamp[24] = '\0';
|
||||
dprintf(log_fd, "[%s] ➕ Relay added: %s\n\n", timestamp, url);
|
||||
dprintf(log_fd, "[%s] ➕ Relay added: %s (status: %d)\n", timestamp, url, status);
|
||||
if (error_msg) {
|
||||
dprintf(log_fd, " Connection error: %s\n", error_msg);
|
||||
}
|
||||
dprintf(log_fd, "\n");
|
||||
} else {
|
||||
printf("❌ Failed to add relay\n");
|
||||
printf("❌ Failed to add relay to pool\n");
|
||||
}
|
||||
}
|
||||
free(url);
|
||||
@@ -655,7 +848,11 @@ int main() {
|
||||
break;
|
||||
}
|
||||
|
||||
case '9': // Exit
|
||||
case '9': // Publish Event
|
||||
publish_event();
|
||||
break;
|
||||
|
||||
case '0': // Exit
|
||||
running = 0;
|
||||
break;
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#define NOSTR_POOL_SUBSCRIPTION_ID_SIZE 32
|
||||
#define NOSTR_POOL_PING_INTERVAL 59 // 59 seconds - keeps connections alive
|
||||
#define NOSTR_POOL_MAX_PENDING_SUBSCRIPTIONS 8 // Max concurrent subscription timings per relay
|
||||
#define NOSTR_POOL_MAX_PENDING_PUBLISHES 32 // Max concurrent publish operations
|
||||
|
||||
// High-resolution timing helper
|
||||
static double get_current_time_ms(void) {
|
||||
@@ -60,6 +61,17 @@ typedef struct subscription_timing {
|
||||
int active;
|
||||
} subscription_timing_t;
|
||||
|
||||
// Publish operation tracking for async callbacks
|
||||
typedef struct publish_operation {
|
||||
char event_id[65]; // Event ID being published
|
||||
publish_response_callback_t callback; // User callback function
|
||||
void* user_data; // User data for callback
|
||||
time_t publish_time; // When publish was initiated
|
||||
int pending_relay_count; // Number of relays still pending response
|
||||
char** pending_relay_urls; // URLs of relays still pending
|
||||
int total_relay_count; // Total number of relays for this publish
|
||||
} publish_operation_t;
|
||||
|
||||
// Internal structures
|
||||
typedef struct relay_connection {
|
||||
char* url;
|
||||
@@ -147,6 +159,10 @@ struct nostr_relay_pool {
|
||||
nostr_pool_subscription_t* subscriptions[NOSTR_POOL_MAX_SUBSCRIPTIONS];
|
||||
int subscription_count;
|
||||
|
||||
// Active publish operations for async callbacks
|
||||
publish_operation_t* publish_operations[NOSTR_POOL_MAX_PENDING_PUBLISHES];
|
||||
int publish_operation_count;
|
||||
|
||||
// Pool-wide settings
|
||||
int default_timeout_ms;
|
||||
};
|
||||
@@ -217,6 +233,122 @@ static double remove_subscription_timing(relay_connection_t* relay, const char*
|
||||
return -1.0; // Not found
|
||||
}
|
||||
|
||||
// Helper functions for managing publish operations
|
||||
static int add_publish_operation(nostr_relay_pool_t* pool, const char* event_id,
|
||||
const char** relay_urls, int relay_count,
|
||||
publish_response_callback_t callback, void* user_data) {
|
||||
if (!pool || !event_id || !relay_urls || relay_count <= 0) return -1;
|
||||
|
||||
// Check if we have space for another operation
|
||||
if (pool->publish_operation_count >= NOSTR_POOL_MAX_PENDING_PUBLISHES) {
|
||||
return -1; // No space available
|
||||
}
|
||||
|
||||
// Create new publish operation
|
||||
publish_operation_t* op = calloc(1, sizeof(publish_operation_t));
|
||||
if (!op) return -1;
|
||||
|
||||
// Copy event ID
|
||||
strncpy(op->event_id, event_id, sizeof(op->event_id) - 1);
|
||||
op->event_id[sizeof(op->event_id) - 1] = '\0';
|
||||
|
||||
// Set callback and user data
|
||||
op->callback = callback;
|
||||
op->user_data = user_data;
|
||||
op->publish_time = time(NULL);
|
||||
op->total_relay_count = relay_count;
|
||||
op->pending_relay_count = relay_count;
|
||||
|
||||
// Copy relay URLs
|
||||
op->pending_relay_urls = malloc(relay_count * sizeof(char*));
|
||||
if (!op->pending_relay_urls) {
|
||||
free(op);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < relay_count; i++) {
|
||||
op->pending_relay_urls[i] = strdup(relay_urls[i]);
|
||||
if (!op->pending_relay_urls[i]) {
|
||||
// Cleanup on failure
|
||||
for (int j = 0; j < i; j++) {
|
||||
free(op->pending_relay_urls[j]);
|
||||
}
|
||||
free(op->pending_relay_urls);
|
||||
free(op);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Add to pool
|
||||
pool->publish_operations[pool->publish_operation_count++] = op;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static publish_operation_t* find_publish_operation(nostr_relay_pool_t* pool, const char* event_id) {
|
||||
if (!pool || !event_id) return NULL;
|
||||
|
||||
for (int i = 0; i < pool->publish_operation_count; i++) {
|
||||
if (pool->publish_operations[i] &&
|
||||
strcmp(pool->publish_operations[i]->event_id, event_id) == 0) {
|
||||
return pool->publish_operations[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void remove_publish_operation(nostr_relay_pool_t* pool, const char* event_id) {
|
||||
if (!pool || !event_id) return;
|
||||
|
||||
for (int i = 0; i < pool->publish_operation_count; i++) {
|
||||
if (pool->publish_operations[i] &&
|
||||
strcmp(pool->publish_operations[i]->event_id, event_id) == 0) {
|
||||
|
||||
publish_operation_t* op = pool->publish_operations[i];
|
||||
|
||||
// Free relay URLs (only non-NULL ones)
|
||||
if (op->pending_relay_urls) {
|
||||
for (int j = 0; j < op->total_relay_count; j++) {
|
||||
if (op->pending_relay_urls[j]) {
|
||||
free(op->pending_relay_urls[j]);
|
||||
op->pending_relay_urls[j] = NULL;
|
||||
}
|
||||
}
|
||||
free(op->pending_relay_urls);
|
||||
op->pending_relay_urls = NULL;
|
||||
}
|
||||
free(op);
|
||||
|
||||
// Shift remaining operations
|
||||
for (int j = i; j < pool->publish_operation_count - 1; j++) {
|
||||
pool->publish_operations[j] = pool->publish_operations[j + 1];
|
||||
}
|
||||
pool->publish_operations[--pool->publish_operation_count] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int remove_relay_from_publish_operation(publish_operation_t* op, const char* relay_url) {
|
||||
if (!op || !relay_url) return -1;
|
||||
|
||||
for (int i = 0; i < op->pending_relay_count; i++) {
|
||||
if (op->pending_relay_urls[i] && strcmp(op->pending_relay_urls[i], relay_url) == 0) {
|
||||
// Free this relay URL
|
||||
free(op->pending_relay_urls[i]);
|
||||
op->pending_relay_urls[i] = NULL; // Mark as freed
|
||||
|
||||
// Shift remaining URLs
|
||||
for (int j = i; j < op->pending_relay_count - 1; j++) {
|
||||
op->pending_relay_urls[j] = op->pending_relay_urls[j + 1];
|
||||
}
|
||||
op->pending_relay_urls[op->pending_relay_count - 1] = NULL; // Clear the last slot
|
||||
op->pending_relay_count--;
|
||||
return op->pending_relay_count; // Return remaining count
|
||||
}
|
||||
}
|
||||
return -1; // Relay not found
|
||||
}
|
||||
|
||||
// Helper function to ensure relay connection
|
||||
static int ensure_relay_connection(relay_connection_t* relay) {
|
||||
if (!relay) {
|
||||
@@ -559,6 +691,20 @@ void nostr_relay_pool_destroy(nostr_relay_pool_t* pool) {
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up all pending publish operations
|
||||
for (int i = 0; i < pool->publish_operation_count; i++) {
|
||||
if (pool->publish_operations[i]) {
|
||||
publish_operation_t* op = pool->publish_operations[i];
|
||||
|
||||
// Free relay URLs
|
||||
for (int j = 0; j < op->total_relay_count; j++) {
|
||||
free(op->pending_relay_urls[j]);
|
||||
}
|
||||
free(op->pending_relay_urls);
|
||||
free(op);
|
||||
}
|
||||
}
|
||||
|
||||
// Close all relay connections
|
||||
for (int i = 0; i < pool->relay_count; i++) {
|
||||
if (pool->relays[i]) {
|
||||
@@ -902,25 +1048,48 @@ static void process_relay_message(nostr_relay_pool_t* pool, relay_connection_t*
|
||||
} else if (strcmp(msg_type, "OK") == 0) {
|
||||
// Handle OK response: ["OK", event_id, true/false, message]
|
||||
if (cJSON_IsArray(parsed) && cJSON_GetArraySize(parsed) >= 3) {
|
||||
cJSON* event_id_json = cJSON_GetArrayItem(parsed, 1);
|
||||
cJSON* success_flag = cJSON_GetArrayItem(parsed, 2);
|
||||
|
||||
if (cJSON_IsBool(success_flag)) {
|
||||
if (cJSON_IsTrue(success_flag)) {
|
||||
if (cJSON_IsString(event_id_json) && cJSON_IsBool(success_flag)) {
|
||||
const char* event_id = cJSON_GetStringValue(event_id_json);
|
||||
int success = cJSON_IsTrue(success_flag);
|
||||
const char* error_message = NULL;
|
||||
|
||||
// Extract error message if available
|
||||
if (!success && cJSON_GetArraySize(parsed) >= 4) {
|
||||
cJSON* error_msg = cJSON_GetArrayItem(parsed, 3);
|
||||
if (cJSON_IsString(error_msg)) {
|
||||
error_message = cJSON_GetStringValue(error_msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Update relay statistics
|
||||
if (success) {
|
||||
relay->stats.events_published_ok++;
|
||||
} else {
|
||||
relay->stats.events_published_failed++;
|
||||
// Store error message if available
|
||||
if (cJSON_GetArraySize(parsed) >= 4) {
|
||||
cJSON* error_msg = cJSON_GetArrayItem(parsed, 3);
|
||||
if (cJSON_IsString(error_msg)) {
|
||||
const char* msg = cJSON_GetStringValue(error_msg);
|
||||
if (msg) {
|
||||
strncpy(relay->last_publish_error, msg,
|
||||
sizeof(relay->last_publish_error) - 1);
|
||||
relay->last_publish_error[sizeof(relay->last_publish_error) - 1] = '\0';
|
||||
relay->last_publish_error_time = time(NULL);
|
||||
}
|
||||
}
|
||||
// Store error message for legacy API
|
||||
if (error_message) {
|
||||
strncpy(relay->last_publish_error, error_message,
|
||||
sizeof(relay->last_publish_error) - 1);
|
||||
relay->last_publish_error[sizeof(relay->last_publish_error) - 1] = '\0';
|
||||
relay->last_publish_error_time = time(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for async publish operation callback
|
||||
publish_operation_t* op = find_publish_operation(pool, event_id);
|
||||
if (op && op->callback) {
|
||||
// Call the user's callback
|
||||
op->callback(relay->url, event_id, success, error_message, op->user_data);
|
||||
|
||||
// Remove this relay from the pending list
|
||||
int remaining = remove_relay_from_publish_operation(op, relay->url);
|
||||
|
||||
// If no more relays pending, remove the operation
|
||||
if (remaining == 0) {
|
||||
remove_publish_operation(pool, event_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1113,16 +1282,35 @@ cJSON* nostr_relay_pool_get_event(
|
||||
return result;
|
||||
}
|
||||
|
||||
int nostr_relay_pool_publish(
|
||||
|
||||
int nostr_relay_pool_publish_async(
|
||||
nostr_relay_pool_t* pool,
|
||||
const char** relay_urls,
|
||||
int relay_count,
|
||||
cJSON* event) {
|
||||
cJSON* event,
|
||||
publish_response_callback_t callback,
|
||||
void* user_data) {
|
||||
|
||||
if (!pool || !relay_urls || relay_count <= 0 || !event) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Extract event ID for tracking
|
||||
cJSON* event_id_json = cJSON_GetObjectItem(event, "id");
|
||||
if (!event_id_json || !cJSON_IsString(event_id_json)) {
|
||||
return -1; // Event must have an ID
|
||||
}
|
||||
const char* event_id = cJSON_GetStringValue(event_id_json);
|
||||
|
||||
// Add publish operation for tracking (only if callback provided)
|
||||
publish_operation_t* op = NULL;
|
||||
if (callback) {
|
||||
if (add_publish_operation(pool, event_id, relay_urls, relay_count, callback, user_data) != 0) {
|
||||
return -1; // Failed to add operation
|
||||
}
|
||||
op = find_publish_operation(pool, event_id);
|
||||
}
|
||||
|
||||
int success_count = 0;
|
||||
|
||||
for (int i = 0; i < relay_count; i++) {
|
||||
@@ -1135,55 +1323,35 @@ int nostr_relay_pool_publish(
|
||||
}
|
||||
|
||||
if (relay && ensure_relay_connection(relay) == 0) {
|
||||
double start_time_ms = get_current_time_ms();
|
||||
|
||||
// Send EVENT message
|
||||
if (nostr_relay_send_event(relay->ws_client, event) >= 0) {
|
||||
relay->stats.events_published++;
|
||||
|
||||
// Wait for OK response
|
||||
char buffer[1024];
|
||||
time_t wait_start = time(NULL);
|
||||
int got_response = 0;
|
||||
|
||||
while (time(NULL) - wait_start < 5 && !got_response) { // 5 second timeout
|
||||
int len = nostr_ws_receive(relay->ws_client, buffer, sizeof(buffer) - 1, 1000);
|
||||
if (len > 0) {
|
||||
buffer[len] = '\0';
|
||||
|
||||
char* msg_type = NULL;
|
||||
cJSON* parsed = NULL;
|
||||
if (nostr_parse_relay_message(buffer, &msg_type, &parsed) == 0) {
|
||||
if (msg_type && strcmp(msg_type, "OK") == 0) {
|
||||
// Handle OK response
|
||||
if (cJSON_IsArray(parsed) && cJSON_GetArraySize(parsed) >= 3) {
|
||||
cJSON* success_flag = cJSON_GetArrayItem(parsed, 2);
|
||||
if (cJSON_IsBool(success_flag) && cJSON_IsTrue(success_flag)) {
|
||||
success_count++;
|
||||
relay->stats.events_published_ok++;
|
||||
|
||||
// Update publish latency statistics
|
||||
double latency_ms = get_current_time_ms() - start_time_ms;
|
||||
if (relay->stats.publish_samples == 0) {
|
||||
relay->stats.publish_latency_avg = latency_ms;
|
||||
} else {
|
||||
relay->stats.publish_latency_avg =
|
||||
(relay->stats.publish_latency_avg * relay->stats.publish_samples + latency_ms) /
|
||||
(relay->stats.publish_samples + 1);
|
||||
}
|
||||
relay->stats.publish_samples++;
|
||||
} else {
|
||||
relay->stats.events_published_failed++;
|
||||
}
|
||||
}
|
||||
got_response = 1;
|
||||
}
|
||||
if (msg_type) free(msg_type);
|
||||
if (parsed) cJSON_Delete(parsed);
|
||||
}
|
||||
success_count++;
|
||||
} else {
|
||||
// If send failed and we have a callback, notify immediately
|
||||
if (callback && op) {
|
||||
callback(relay_urls[i], event_id, 0, "Failed to send event to relay", user_data);
|
||||
|
||||
// Remove this relay from the pending operation
|
||||
int remaining = remove_relay_from_publish_operation(op, relay_urls[i]);
|
||||
if (remaining == 0) {
|
||||
remove_publish_operation(pool, event_id);
|
||||
op = NULL; // Mark as removed to prevent double-free
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Connection failed - notify callback immediately if provided
|
||||
if (callback && op) {
|
||||
callback(relay_urls[i], event_id, 0, "Failed to connect to relay", user_data);
|
||||
|
||||
// Remove this relay from the pending operation
|
||||
int remaining = remove_relay_from_publish_operation(op, relay_urls[i]);
|
||||
if (remaining == 0) {
|
||||
remove_publish_operation(pool, event_id);
|
||||
op = NULL; // Mark as removed to prevent double-free
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -288,11 +288,23 @@ cJSON* nostr_relay_pool_get_event(
|
||||
int relay_count,
|
||||
cJSON* filter,
|
||||
int timeout_ms);
|
||||
int nostr_relay_pool_publish(
|
||||
// Async publish callback typedef
|
||||
typedef void (*publish_response_callback_t)(
|
||||
const char* relay_url,
|
||||
const char* event_id,
|
||||
int success, // 1 for OK, 0 for rejection
|
||||
const char* message, // Error message if rejected, NULL if success
|
||||
void* user_data
|
||||
);
|
||||
|
||||
// Async publish function (only async version available)
|
||||
int nostr_relay_pool_publish_async(
|
||||
nostr_relay_pool_t* pool,
|
||||
const char** relay_urls,
|
||||
int relay_count,
|
||||
cJSON* event);
|
||||
cJSON* event,
|
||||
publish_response_callback_t callback,
|
||||
void* user_data);
|
||||
|
||||
// Status and statistics functions
|
||||
nostr_pool_relay_status_t nostr_relay_pool_get_relay_status(
|
||||
|
||||
BIN
tests/async_publish_test
Executable file
BIN
tests/async_publish_test
Executable file
Binary file not shown.
93
tests/async_publish_test.c
Normal file
93
tests/async_publish_test.c
Normal file
@@ -0,0 +1,93 @@
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "../nostr_core/nostr_core.h"
|
||||
#include "../cjson/cJSON.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// Test callback function
|
||||
static int callback_count = 0;
|
||||
static int success_count = 0;
|
||||
|
||||
void test_callback(const char* relay_url, const char* event_id,
|
||||
int success, const char* message, void* user_data) {
|
||||
callback_count++;
|
||||
if (success) {
|
||||
success_count++;
|
||||
}
|
||||
|
||||
printf("📡 Callback %d: Relay %s, Event %s, Success: %s\n",
|
||||
callback_count, relay_url, event_id, success ? "YES" : "NO");
|
||||
if (message) {
|
||||
printf(" Message: %s\n", message);
|
||||
}
|
||||
|
||||
// Mark test as complete when we get the expected number of callbacks
|
||||
int* expected_callbacks = (int*)user_data;
|
||||
if (callback_count >= *expected_callbacks) {
|
||||
printf("✅ All callbacks received!\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("🧪 Testing Async Publish Functionality\n");
|
||||
printf("=====================================\n");
|
||||
|
||||
// Create pool
|
||||
nostr_relay_pool_t* pool = nostr_relay_pool_create(NULL);
|
||||
if (!pool) {
|
||||
printf("❌ Failed to create pool\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a test event
|
||||
cJSON* event = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(event, "id", "test_event_12345");
|
||||
cJSON_AddNumberToObject(event, "kind", 1);
|
||||
cJSON_AddStringToObject(event, "content", "Test async publish");
|
||||
cJSON_AddNumberToObject(event, "created_at", time(NULL));
|
||||
cJSON_AddStringToObject(event, "pubkey", "test_pubkey");
|
||||
cJSON_AddStringToObject(event, "sig", "test_signature");
|
||||
|
||||
// Test with non-existent relays (should trigger connection failure callbacks)
|
||||
const char* test_relays[] = {
|
||||
"ws://nonexistent1.example.com",
|
||||
"ws://nonexistent2.example.com"
|
||||
};
|
||||
int expected_callbacks = 2;
|
||||
|
||||
printf("🚀 Testing async publish with connection failure callbacks...\n");
|
||||
|
||||
// Call async publish
|
||||
int sent_count = nostr_relay_pool_publish_async(
|
||||
pool, test_relays, 2, event, test_callback, &expected_callbacks);
|
||||
|
||||
printf("📊 Sent to %d relays\n", sent_count);
|
||||
|
||||
// Wait a bit for callbacks (connection failures should be immediate)
|
||||
printf("⏳ Waiting for callbacks...\n");
|
||||
for (int i = 0; i < 10 && callback_count < expected_callbacks; i++) {
|
||||
nostr_relay_pool_poll(pool, 100);
|
||||
usleep(100000); // 100ms
|
||||
}
|
||||
|
||||
printf("\n📈 Results:\n");
|
||||
printf(" Callbacks received: %d/%d\n", callback_count, expected_callbacks);
|
||||
printf(" Successful publishes: %d\n", success_count);
|
||||
|
||||
// Test backward compatibility with synchronous version
|
||||
printf("\n🔄 Testing backward compatibility (sync version)...\n");
|
||||
int sync_result = nostr_relay_pool_publish_async(pool, test_relays, 2, event, NULL, NULL);
|
||||
printf(" Sync publish result: %d successful publishes\n", sync_result);
|
||||
|
||||
// Cleanup
|
||||
cJSON_Delete(event);
|
||||
nostr_relay_pool_destroy(pool);
|
||||
|
||||
printf("\n✅ Async publish test completed!\n");
|
||||
printf(" - Async callbacks: %s\n", callback_count >= expected_callbacks ? "PASS" : "FAIL");
|
||||
printf(" - Backward compatibility: %s\n", sync_result >= 0 ? "PASS" : "FAIL");
|
||||
|
||||
return (callback_count >= expected_callbacks && sync_result >= 0) ? 0 : 1;
|
||||
}
|
||||
49
tests/backward_compat_test.c
Normal file
49
tests/backward_compat_test.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "../nostr_core/nostr_core.h"
|
||||
#include "../cjson/cJSON.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
printf("🧪 Backward Compatibility Test\n");
|
||||
printf("===============================\n");
|
||||
|
||||
// Create pool
|
||||
nostr_relay_pool_t* pool = nostr_relay_pool_create(NULL);
|
||||
if (!pool) {
|
||||
printf("❌ Failed to create pool\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a test event
|
||||
cJSON* event = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(event, "id", "test_event_sync");
|
||||
cJSON_AddNumberToObject(event, "kind", 1);
|
||||
cJSON_AddStringToObject(event, "content", "Test sync publish");
|
||||
cJSON_AddNumberToObject(event, "created_at", time(NULL));
|
||||
cJSON_AddStringToObject(event, "pubkey", "test_pubkey");
|
||||
cJSON_AddStringToObject(event, "sig", "test_signature");
|
||||
|
||||
// Test with non-existent relay (should return 0 successful publishes)
|
||||
const char* test_relays[] = {"ws://nonexistent.example.com"};
|
||||
|
||||
printf("🚀 Testing synchronous publish (backward compatibility)...\n");
|
||||
|
||||
// Call synchronous publish (old API)
|
||||
int result = nostr_relay_pool_publish_async(pool, test_relays, 1, event, NULL, NULL);
|
||||
|
||||
printf("📊 Synchronous publish result: %d successful publishes\n", result);
|
||||
|
||||
// Cleanup
|
||||
cJSON_Delete(event);
|
||||
nostr_relay_pool_destroy(pool);
|
||||
|
||||
printf("\n✅ Backward compatibility test completed!\n");
|
||||
printf(" Expected: 0 successful publishes (connection failure)\n");
|
||||
printf(" Actual: %d successful publishes\n", result);
|
||||
printf(" Result: %s\n", result == 0 ? "PASS" : "FAIL");
|
||||
|
||||
return result == 0 ? 0 : 1;
|
||||
}
|
||||
BIN
tests/simple_async_test
Executable file
BIN
tests/simple_async_test
Executable file
Binary file not shown.
70
tests/simple_async_test.c
Normal file
70
tests/simple_async_test.c
Normal file
@@ -0,0 +1,70 @@
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "../nostr_core/nostr_core.h"
|
||||
#include "../cjson/cJSON.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// Test callback function
|
||||
static int callback_count = 0;
|
||||
|
||||
void test_callback(const char* relay_url, const char* event_id,
|
||||
int success, const char* message, void* user_data) {
|
||||
callback_count++;
|
||||
printf("📡 Callback %d: Relay %s, Success: %s\n",
|
||||
callback_count, relay_url, success ? "YES" : "NO");
|
||||
if (message) {
|
||||
printf(" Message: %s\n", message);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("🧪 Simple Async Publish Test\n");
|
||||
printf("============================\n");
|
||||
|
||||
// Create pool
|
||||
nostr_relay_pool_t* pool = nostr_relay_pool_create(NULL);
|
||||
if (!pool) {
|
||||
printf("❌ Failed to create pool\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a test event
|
||||
cJSON* event = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(event, "id", "test_event_simple");
|
||||
cJSON_AddNumberToObject(event, "kind", 1);
|
||||
cJSON_AddStringToObject(event, "content", "Test async publish");
|
||||
cJSON_AddNumberToObject(event, "created_at", time(NULL));
|
||||
cJSON_AddStringToObject(event, "pubkey", "test_pubkey");
|
||||
cJSON_AddStringToObject(event, "sig", "test_signature");
|
||||
|
||||
// Test with non-existent relay (should trigger connection failure callback)
|
||||
const char* test_relays[] = {"ws://nonexistent.example.com"};
|
||||
|
||||
printf("🚀 Testing async publish...\n");
|
||||
|
||||
// Call async publish
|
||||
int sent_count = nostr_relay_pool_publish_async(
|
||||
pool, test_relays, 1, event, test_callback, NULL);
|
||||
|
||||
printf("📊 Sent to %d relays\n", sent_count);
|
||||
|
||||
// Wait a bit for callback
|
||||
printf("⏳ Waiting for callback...\n");
|
||||
for (int i = 0; i < 5 && callback_count == 0; i++) {
|
||||
nostr_relay_pool_poll(pool, 100);
|
||||
usleep(100000); // 100ms
|
||||
}
|
||||
|
||||
printf("\n📈 Results:\n");
|
||||
printf(" Callbacks received: %d\n", callback_count);
|
||||
|
||||
// Cleanup
|
||||
cJSON_Delete(event);
|
||||
nostr_relay_pool_destroy(pool);
|
||||
|
||||
printf("\n✅ Simple async test completed!\n");
|
||||
|
||||
return callback_count > 0 ? 0 : 1;
|
||||
}
|
||||
Reference in New Issue
Block a user