mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-06-01 10:39:17 +02:00
minor comment etc changes
This commit is contained in:
parent
a4e687d806
commit
e3aae09f9d
@ -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 {
|
||||
|
@ -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<String> 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<String> 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 <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.
|
||||
-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.
|
||||
-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.
|
||||
|
@ -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<Tree> latestTrees = [];
|
||||
List<Tree> latestTrees = []; // TODO
|
||||
|
||||
if( whetherTopMost) {
|
||||
depth = depth - 1;
|
||||
@ -388,6 +370,7 @@ class Tree {
|
||||
} else {
|
||||
e.printEvent(depth);
|
||||
numPrinted++;
|
||||
//latestTrees = children;
|
||||
}
|
||||
|
||||
bool leftShifted = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user