minor comment etc changes

This commit is contained in:
Vishal 2022-08-29 20:38:48 +05:30
parent a4e687d806
commit e3aae09f9d
3 changed files with 8 additions and 33 deletions

View File

@ -165,11 +165,9 @@ String addEscapeChars(String str) {
String getShaId(String pubkey, int createdAt, String kind, String strTags, String content) { String getShaId(String pubkey, int createdAt, String kind, String strTags, String content) {
String buf = '[0,"$pubkey",$createdAt,$kind,[$strTags],"$content"]'; String buf = '[0,"$pubkey",$createdAt,$kind,[$strTags],"$content"]';
if( gDebug > 0) print("In getShaId: for buf = $buf");
var bufInBytes = utf8.encode(buf); var bufInBytes = utf8.encode(buf);
var value = sha256.convert(bufInBytes); var value = sha256.convert(bufInBytes);
String id = value.toString(); return value.toString();
return id;
} }
class EventData { class EventData {

View File

@ -5,7 +5,7 @@ final log = Logger('ExampleLogger');
// for debugging // for debugging
String gCheckEventId = "a4479de655094679cdfb10f347521aa58f24717cdc5ddba89fb346453a8a99ed"; String gCheckEventId = "a4479de655094679cdfb10f347521aa58f24717cdc5ddba89fb346453a8a99ed";
const int numWaitSeconds = 3000; const int numWaitSeconds = 3000; // is used in main()
const String gDefaultEventsFilename = "all_nostr_events.txt"; const String gDefaultEventsFilename = "all_nostr_events.txt";
String gEventsFilename = ""; // is set in arguments, and if set, then file is read from and written to 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; int numFileEvents = 0, numUserEvents = 0, numFeedEvents = 0, numOtherEvents = 0;
//String defaultServerUrl = 'wss://relay.damus.io'; //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'; const String relayNostrInfo = 'wss://relay.nostr.info';
String defaultServerUrl = "wss://relay.damus.io"; String defaultServerUrl = "wss://relay.damus.io";
List<String> gListRelayUrls = [ defaultServerUrl, List<String> gListRelayUrls = [ defaultServerUrl,
relayNostrInfo,
"wss://nostr-verified.wellorder.net", "wss://nostr-verified.wellorder.net",
"wss://nostr-relay.wlvs.space", "wss://nostr-relay.wlvs.space",
"wss://nostr-pub.wellorder.net" "wss://nostr-pub.wellorder.net"
//"wss://relay.damus.io"
]; ];
// name of executable // name of executable
@ -62,7 +62,6 @@ const int gDefaultMaxDepth = 4;
int maxDepthAllowed = gDefaultMaxDepth; int maxDepthAllowed = gDefaultMaxDepth;
const int leftShiftThreadsBy = 2; const int leftShiftThreadsBy = 2;
// text color // text color
const String defaultTextColor = "green"; const String defaultTextColor = "green";
@ -86,7 +85,6 @@ String gNotificationColor = cyanColor; // cyan
String gWarningColor = redColor; // red String gWarningColor = redColor; // red
const String colorEndMarker = "\x1B[0m"; const String colorEndMarker = "\x1B[0m";
// dummy account pubkey // dummy account pubkey
const String gDummyAccountPubkey = "Non"; const String gDummyAccountPubkey = "Non";
@ -95,10 +93,6 @@ const String gDummyAccountPubkey = "Non";
const int gDefaultNumLastDays = 1; const int gDefaultNumLastDays = 1;
int gNumLastDays = gDefaultNumLastDays; int gNumLastDays = gDefaultNumLastDays;
// UNUSED
String gRemoteAdminPubkey = "";
// bots ignored to reduce spam // bots ignored to reduce spam
List<String> gBots = [ "3b57518d02e6acfd5eb7198530b2e351e5a52278fb2499d14b66db2b5791c512", // robosats orderbook List<String> gBots = [ "3b57518d02e6acfd5eb7198530b2e351e5a52278fb2499d14b66db2b5791c512", // robosats orderbook
"887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072", // bestofhn "887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072", // bestofhn
@ -119,7 +113,7 @@ usage: $exename [OPTIONS]
well known private key. When given, posts/replies can't be sent. well known private key. When given, posts/replies can't be sent.
-k, --prikey <private key> The hex private key of user whose events and feed are shown. Also used to sign events -k, --prikey <private key> 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. sent. Default is a hard-coded well known private key.
-r, --relay <relay wss url> The relay url that is used as main relay. Default is $nostrRelayUnther. -r, --relay <relay wss url> The relay url that is used as main relay. Default is wss://relay.damus.io.
-d, --days <N as num> The latest number of days for which events are shown. Default is $gDefaultNumLastDays. -d, --days <N as num> The latest number of days for which events are shown. Default is $gDefaultNumLastDays.
-q, --request <REQ string> This request is sent verbatim to the default relay. It can be used to recieve all events -q, --request <REQ string> 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. from a relay. If not provided, then events for default or given user are shown.

View File

@ -138,7 +138,6 @@ class Tree {
} }
tempChildEventsMap[parentId]?.addChildNode(value); // in this if condition this will get called tempChildEventsMap[parentId]?.addChildNode(value); // in this if condition this will get called
} else { } else {
// in case where the parent of the new event is not in the pool of all events, // 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 // 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("","", 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 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 in map of kind 42 = ${numKind42Events}");
if(gDebug != 0) print("In Tree FromEvents: number of events without parent in fromEvents = ${tempWithoutParent.length}"); 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 // 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]"); Event dummy = Event("","", EventData("non","", 0, 1, "Dummy Top event. Should not be printed.", [], [], [], [[]], {}), [""], "[json]");
@ -208,15 +206,8 @@ class Tree {
return; return;
} }
// experimental // expand mentions ( and translate if flag is set) and then add event to main event map
if( newEvent.eventData.pubkey == gRemoteAdminPubkey) {
}
// expand mentions ( and translate if flag is set)
newEvent.eventData.translateAndExpandMentions(); newEvent.eventData.translateAndExpandMentions();
//if( gDebug > 0) print("In insertEvents: adding event to main children map");
allChildEventsMap[newEvent.eventData.id] = Tree(newEvent, [], {}, [], false, {}); 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) // 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 { } else {
// if it has a parent , then add the newTree as the parent's child // if it has a parent , then add the newTree as the parent's child
String parentId = newTree.e.eventData.getParent(); 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)) { if( allChildEventsMap.containsKey(parentId)) {
allChildEventsMap[parentId]?.addChildNode(newTree); allChildEventsMap[parentId]?.addChildNode(newTree);
} else { } else {
@ -256,7 +241,6 @@ class Tree {
dummyTopNode.addChildNode(newTree); dummyTopNode.addChildNode(newTree);
children.add(dummyTopNode); children.add(dummyTopNode);
} }
} }
break; break;
case 42: case 42:
@ -281,7 +265,6 @@ class Tree {
return newEventIdsSet; return newEventIdsSet;
} }
/* /*
* @printNotifications Add the given events to the Tree, and print the events as notifications * @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 * 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"); if(gDebug > 0) print("Info: In printNotifications: newEventsId = $newEventIdsSet count17 = $countNotificationEvents");
@ -380,7 +362,7 @@ class Tree {
int numPrinted = 0; int numPrinted = 0;
// for the top most tree, create a smaller list which only has recent trees // for the top most tree, create a smaller list which only has recent trees
List<Tree> latestTrees = []; List<Tree> latestTrees = []; // TODO
if( whetherTopMost) { if( whetherTopMost) {
depth = depth - 1; depth = depth - 1;
@ -388,6 +370,7 @@ class Tree {
} else { } else {
e.printEvent(depth); e.printEvent(depth);
numPrinted++; numPrinted++;
//latestTrees = children;
} }
bool leftShifted = false; bool leftShifted = false;