diff --git a/bin/nostr_console.dart b/bin/nostr_console.dart index e3a149d..5c42725 100644 --- a/bin/nostr_console.dart +++ b/bin/nostr_console.dart @@ -270,19 +270,27 @@ Future main(List arguments) async { // then get the events of user-id's mentioned in p-tags of received events and the contact list // then display them all - int daysToGetEventsFor = gDaysToGetEventsFor; + int limitFollowPosts = gLimitFollowPosts; + int limitMetaInfoEvents = 300; + int limitSelfEvents = 300; + + int limitPerSubscription = gLimitPerSubscription; // if more than 1000 posts have already been read from the file, then don't get too many day's events. Only for last 3 days. if(numFilePosts > 1000) { - daysToGetEventsFor = 3; - gDefaultNumWaitSeconds = gDefaultNumWaitSeconds ~/3; + limitPerSubscription = 5000; + limitSelfEvents = 5; + limitMetaInfoEvents = 3; + limitFollowPosts = 3; + gDefaultNumWaitSeconds = gDefaultNumWaitSeconds ~/4; } - getUserEvents(gListRelayUrls1, userPublicKey, gLimitPerSubscription, getSecondsDaysAgo(daysToGetEventsFor * 100)); - getMentionEvents(gListRelayUrls2, userPublicKey, gLimitPerSubscription, getSecondsDaysAgo(daysToGetEventsFor * 20)); // from relay group 2 - getMultiUserEvents(gListRelayUrls1, gDefaultFollows, 1000, getSecondsDaysAgo(daysToGetEventsFor)); - getKindEvents([0, 3, 40, 41, 140, 141], gListRelayUrls1, 3 * gLimitPerSubscription, getSecondsDaysAgo(daysToGetEventsFor* 100)); // get all type 3 etc - getKindEvents([42, 142], gListRelayUrls1, gLimitPerSubscription * 3, getSecondsDaysAgo( daysToGetEventsFor)); // get all type 3 etc + getUserEvents(gListRelayUrls1, userPublicKey, limitPerSubscription, getSecondsDaysAgo(limitSelfEvents)); + getMentionEvents(gListRelayUrls2, userPublicKey, limitPerSubscription, getSecondsDaysAgo(limitSelfEvents)); // from relay group 2 + + getMultiUserEvents(gListRelayUrls1, gDefaultFollows, limitPerSubscription, getSecondsDaysAgo(limitFollowPosts)); + getKindEvents([0, 3, 40, 41, 140, 141], gListRelayUrls1, 3 * limitPerSubscription, getSecondsDaysAgo(limitMetaInfoEvents)); // get all type 3 etc + getKindEvents([42, 142], gListRelayUrls1, limitPerSubscription * 3, getSecondsDaysAgo( limitFollowPosts)); // get all type 3 etc // TODO get all 40 events, and then get all #e for them ( responses to them) @@ -310,13 +318,13 @@ Future main(List arguments) async { contacts.add(contact.id); }); } - getContactFeed(gListRelayUrls1, contacts, gLimitPerSubscription, getSecondsDaysAgo(2 * daysToGetEventsFor)); + getContactFeed(gListRelayUrls1, contacts, gLimitPerSubscription, getSecondsDaysAgo(2 * limitFollowPosts)); // calculate top mentioned ptags, and then get the events for those users //log.info('calling getpTags'); List pTags = getpTags(initialEvents, gMaxPtagsToGet); //log.info('after getpTags\n'); - getMultiUserEvents(gListRelayUrls1, pTags, gLimitPerSubscription, getSecondsDaysAgo(daysToGetEventsFor)); + getMultiUserEvents(gListRelayUrls1, pTags, gLimitPerSubscription, getSecondsDaysAgo(limitFollowPosts)); stdout.write('Waiting for feed to come in..............'); diff --git a/lib/console_ui.dart b/lib/console_ui.dart index 3b3c420..a0409cd 100644 --- a/lib/console_ui.dart +++ b/lib/console_ui.dart @@ -140,7 +140,7 @@ Future sendDirectMessage(Store node, String otherPubkey, String messageToS String id = getShaId(userPublicKey, createdAt.toString(), replyKind, strTags, encryptedMessageToSend); String sig = mySign(userPrivateKey, id); String eventStrToSend = '["EVENT",{"id":"$id","pubkey":"$userPublicKey","created_at":$createdAt,"kind":$replyKind,"tags":[$strTags],"content":"$encryptedMessageToSend","sig":"$sig"}]'; - + //print("calling send for str : $eventStrToSend"); sendRequest( gListRelayUrls1, eventStrToSend); Future foo() async { @@ -562,11 +562,11 @@ Future otherOptionsMenuUi(Store node) async { print('Sending new contact event'); Contact newContact = Contact(pk, defaultServerUrl); newContactEvent.eventData.contactList.add(newContact); - getUserEvents(gListRelayUrls1, pk, gLimitPerSubscription, getSecondsDaysAgo(gDaysToGetEventsFor)); + getUserEvents(gListRelayUrls1, pk, gLimitPerSubscription, getSecondsDaysAgo(gLimitFollowPosts)); sendEvent(node, newContactEvent); } else { print("The contact already exists in the contact list. Republishing the old contact list."); - getUserEvents(gListRelayUrls1, pk, gLimitPerSubscription, getSecondsDaysAgo(gDaysToGetEventsFor)); + getUserEvents(gListRelayUrls1, pk, gLimitPerSubscription, getSecondsDaysAgo(gLimitFollowPosts)); sendEvent(node, contactEvent); } } else { @@ -584,7 +584,7 @@ Future otherOptionsMenuUi(Store node) async { EventData newEventData = EventData(newId, newPubkey, newCreatedAt, newKind, newContent, newEtags, newPtags, newContactList, newTags, newNewLikes,); Event newEvent = Event( "EVENT", newId, newEventData, [], ""); - getUserEvents(gListRelayUrls1, pk, gLimitPerSubscription, getSecondsDaysAgo(gDaysToGetEventsFor)); + getUserEvents(gListRelayUrls1, pk, gLimitPerSubscription, getSecondsDaysAgo(gLimitFollowPosts)); sendEvent(node, newEvent); } } diff --git a/lib/event_ds.dart b/lib/event_ds.dart index e2a37e6..bc938cc 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -1529,8 +1529,10 @@ String myEncrypt( String privateString, String publicString, String plainText) { //print("private = ${privateString.length} public = ${publicString.length}"); + //print("private = ${privateString} public = ${publicString}"); Uint8List uintInputText = convert.Utf8Encoder().convert(plainText); final encryptedString = myEncryptRaw(privateString, publicString, uintInputText); + //print("encryptedString = $encryptedString"); return encryptedString; } diff --git a/lib/settings.dart b/lib/settings.dart index c514dbb..07d4192 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -13,7 +13,7 @@ final log = Logger('ExampleLogger'); // for debugging String gCheckEventId = "fg ee810ea73072af056cceaa6d051b4fcce60739247f7bcc752e72fa5defb64f09"; -int gDefaultNumWaitSeconds = 3000; // is used in main() +int gDefaultNumWaitSeconds = 6000; // is used in main() //////////////////////////////////////////////////////////////////////////////////////////////////////////////// file related settings const String gDefaultEventsFilename = "all_nostr_events.txt"; @@ -25,8 +25,8 @@ bool gOverWriteFile = false; // overwrite the file, and don't ju const int gDontAddToStoreBeforeDays = 60; // events older than this are not added to the Store of all events -const int gDaysToGetEventsFor = 10; // when getting events, this is the since field (unless a fully formed request is given in command line) -const int gLimitPerSubscription = 6000; +const int gLimitFollowPosts = 20; // when getting events, this is the since field (unless a fully formed request is given in command line) +const int gLimitPerSubscription = 10000; // don't show notifications for events that are older than 5 days and come when program is running // applicable only for notifications and not for search results. Search results set a flag in EventData and don't use this variable @@ -45,8 +45,7 @@ String defaultServerUrl = "wss://relay.damus.io"; List gListRelayUrls1 = [ defaultServerUrl, relayNostrInfo, - "wss://nostr.oxtr.dev", - "wss://nostr-verified.wellorder.net" + "wss://nostr.oxtr.dev" ]; List gListRelayUrls2 = [ diff --git a/lib/tree_ds.dart b/lib/tree_ds.dart index ed0712c..3b08453 100644 --- a/lib/tree_ds.dart +++ b/lib/tree_ds.dart @@ -1630,7 +1630,8 @@ class Store { if( tree.event.eventData.pubkey != userPublicKey ) { if( !(tree.event.eventData.kind == 4 && isValidDirectMessage(tree.event.eventData))) if( !tree.event.eventData.pTags.contains(userPublicKey)) - continue; + if( ![0, 3, 40, 41, 140, 141].contains(tree.event.eventData.kind)) + continue; } }