From e3aae09f9d669b281ef3cbae7f2e35c0f8aace20 Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Mon, 29 Aug 2022 20:38:48 +0530 Subject: [PATCH] minor comment etc changes --- lib/event_ds.dart | 4 +--- lib/settings.dart | 14 ++++---------- lib/tree_ds.dart | 23 +++-------------------- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/lib/event_ds.dart b/lib/event_ds.dart index 7fe15ef..f313024 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -165,11 +165,9 @@ String addEscapeChars(String str) { String getShaId(String pubkey, int createdAt, String kind, String strTags, String content) { String buf = '[0,"$pubkey",$createdAt,$kind,[$strTags],"$content"]'; - if( gDebug > 0) print("In getShaId: for buf = $buf"); var bufInBytes = utf8.encode(buf); var value = sha256.convert(bufInBytes); - String id = value.toString(); - return id; + return value.toString(); } class EventData { diff --git a/lib/settings.dart b/lib/settings.dart index 16541ba..6b6e1b3 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -5,7 +5,7 @@ final log = Logger('ExampleLogger'); // for debugging String gCheckEventId = "a4479de655094679cdfb10f347521aa58f24717cdc5ddba89fb346453a8a99ed"; -const int numWaitSeconds = 3000; +const int numWaitSeconds = 3000; // is used in main() const String gDefaultEventsFilename = "all_nostr_events.txt"; String gEventsFilename = ""; // is set in arguments, and if set, then file is read from and written to @@ -26,15 +26,15 @@ const int gMaxPtagsToGet = 100; // maximum number of p tags that are ta int numFileEvents = 0, numUserEvents = 0, numFeedEvents = 0, numOtherEvents = 0; //String defaultServerUrl = 'wss://relay.damus.io'; -const String nostrRelayUnther = 'wss://nostr-relay.untethr.me'; +//const String nostrRelayUnther = 'wss://nostr-relay.untethr.me'; not working const String relayNostrInfo = 'wss://relay.nostr.info'; String defaultServerUrl = "wss://relay.damus.io"; List gListRelayUrls = [ defaultServerUrl, + relayNostrInfo, "wss://nostr-verified.wellorder.net", "wss://nostr-relay.wlvs.space", "wss://nostr-pub.wellorder.net" - //"wss://relay.damus.io" ]; // name of executable @@ -62,7 +62,6 @@ const int gDefaultMaxDepth = 4; int maxDepthAllowed = gDefaultMaxDepth; const int leftShiftThreadsBy = 2; - // text color const String defaultTextColor = "green"; @@ -86,7 +85,6 @@ String gNotificationColor = cyanColor; // cyan String gWarningColor = redColor; // red const String colorEndMarker = "\x1B[0m"; - // dummy account pubkey const String gDummyAccountPubkey = "Non"; @@ -95,10 +93,6 @@ const String gDummyAccountPubkey = "Non"; const int gDefaultNumLastDays = 1; int gNumLastDays = gDefaultNumLastDays; - -// UNUSED -String gRemoteAdminPubkey = ""; - // bots ignored to reduce spam List gBots = [ "3b57518d02e6acfd5eb7198530b2e351e5a52278fb2499d14b66db2b5791c512", // robosats orderbook "887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072", // bestofhn @@ -119,7 +113,7 @@ usage: $exename [OPTIONS] well known private key. When given, posts/replies can't be sent. -k, --prikey The hex private key of user whose events and feed are shown. Also used to sign events sent. Default is a hard-coded well known private key. - -r, --relay The relay url that is used as main relay. Default is $nostrRelayUnther. + -r, --relay The relay url that is used as main relay. Default is wss://relay.damus.io. -d, --days The latest number of days for which events are shown. Default is $gDefaultNumLastDays. -q, --request This request is sent verbatim to the default relay. It can be used to recieve all events from a relay. If not provided, then events for default or given user are shown. diff --git a/lib/tree_ds.dart b/lib/tree_ds.dart index 82e2f2b..f71a5ea 100644 --- a/lib/tree_ds.dart +++ b/lib/tree_ds.dart @@ -138,7 +138,6 @@ class Tree { } tempChildEventsMap[parentId]?.addChildNode(value); // in this if condition this will get called } else { - // in case where the parent of the new event is not in the pool of all events, // then we create a dummy event and put it at top ( or make this a top event?) TODO handle so that this can be replied to, and is fetched Tree dummyTopNode = Tree(Event("","", @@ -167,7 +166,6 @@ class Tree { if(gDebug != 0) print("In Tree FromEvents: number of events in map of kind 40 = ${numKind40Events}"); if(gDebug != 0) print("In Tree FromEvents: number of events in map of kind 42 = ${numKind42Events}"); if(gDebug != 0) print("In Tree FromEvents: number of events without parent in fromEvents = ${tempWithoutParent.length}"); - // create a dummy top level tree and then create the main Tree object Event dummy = Event("","", EventData("non","", 0, 1, "Dummy Top event. Should not be printed.", [], [], [], [[]], {}), [""], "[json]"); @@ -208,15 +206,8 @@ class Tree { return; } - // experimental - if( newEvent.eventData.pubkey == gRemoteAdminPubkey) { - - } - - // expand mentions ( and translate if flag is set) + // expand mentions ( and translate if flag is set) and then add event to main event map newEvent.eventData.translateAndExpandMentions(); - //if( gDebug > 0) print("In insertEvents: adding event to main children map"); - allChildEventsMap[newEvent.eventData.id] = Tree(newEvent, [], {}, [], false, {}); // add to new-notification list only if tis a recent event ( because relays may send old events, and we dont want to highlight stale messages) @@ -239,12 +230,6 @@ class Tree { } else { // if it has a parent , then add the newTree as the parent's child String parentId = newTree.e.eventData.getParent(); - if( gDebug > 0 && newId == "e9c0c91d52a2cf000bb2460406139a99dd5b7823165be435e96433a600be8e41" || parentId == "f377a303a852c8821069714f43b4eef5e341c03892eacf49abb594660b2fbb00") { - print (newTree.e.eventData.tags); - print("In from json: newId = $newId parentid = $parentId for event id = ${newTree.e.eventData.id}"); - print(allChildEventsMap.containsKey(parentId)); - print("----------------------------------------------/insert events"); - } if( allChildEventsMap.containsKey(parentId)) { allChildEventsMap[parentId]?.addChildNode(newTree); } else { @@ -256,7 +241,6 @@ class Tree { dummyTopNode.addChildNode(newTree); children.add(dummyTopNode); } - } break; case 42: @@ -281,7 +265,6 @@ class Tree { return newEventIdsSet; } - /* * @printNotifications Add the given events to the Tree, and print the events as notifications * It should be ensured that these are only kind 1 events @@ -304,7 +287,6 @@ class Tree { } } - // TODO don't print notifications for events that are too old if(gDebug > 0) print("Info: In printNotifications: newEventsId = $newEventIdsSet count17 = $countNotificationEvents"); @@ -380,7 +362,7 @@ class Tree { int numPrinted = 0; // for the top most tree, create a smaller list which only has recent trees - List latestTrees = []; + List latestTrees = []; // TODO if( whetherTopMost) { depth = depth - 1; @@ -388,6 +370,7 @@ class Tree { } else { e.printEvent(depth); numPrinted++; + //latestTrees = children; } bool leftShifted = false;