-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.. to about 30k for my own username. This reduces connection which seems to improve relay response. added file user.dart with mostly old code.
- Loading branch information
Showing
7 changed files
with
81 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
import 'dart:io'; | ||
import 'package:nostr_console/event_ds.dart'; | ||
import 'package:nostr_console/utils.dart'; | ||
|
||
// From the list of events provided, lookup the lastst contact information for the given user/pubkey | ||
Event? getContactEvent(String pubkey) { | ||
|
||
// get the latest kind 3 event for the user, which lists his 'follows' list | ||
if( gKindONames.containsKey(pubkey)) { | ||
Event? e = (gKindONames[pubkey]?.latestContactEvent)??null; | ||
return e; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
Set<String> getUserChannels(Set<Event> userEvents, String userPublicKey) { | ||
Set<String> userChannels = {}; | ||
|
||
return userChannels; | ||
} | ||
|
||
void addToHistogram(Map<String, int> histogram, List<String> pTags) { | ||
Set tempPtags = {}; | ||
pTags.retainWhere((x) => tempPtags.add(x)); | ||
|
||
for(int i = 0; i < pTags.length; i++ ) { | ||
String pTag = pTags[i]; | ||
if( histogram.containsKey(pTag)) { | ||
int? val = histogram[pTag]; | ||
if( val != null) { | ||
histogram[pTag] = ++val; | ||
} else { | ||
} | ||
} else { | ||
histogram[pTag] = 1; | ||
} | ||
} | ||
//return histogram; | ||
} | ||
|
||
// return the numMostFrequent number of most frequent p tags ( user pubkeys) in the given events | ||
Set<String> getpTags(Set<Event> events, int numMostFrequent) { | ||
List<HistogramEntry> listHistogram = []; | ||
Map<String, int> histogramMap = {}; | ||
for(var event in events) { | ||
addToHistogram(histogramMap, event.eventData.pTags); | ||
} | ||
|
||
histogramMap.forEach((key, value) {listHistogram.add(HistogramEntry(key, value));/* print("added to list of histogramEntry $key $value"); */}); | ||
listHistogram.sort(HistogramEntry.histogramSorter); | ||
List<String> ptags = []; | ||
for( int i = 0; i < listHistogram.length && i < numMostFrequent; i++ ) { | ||
ptags.add(listHistogram[i].str); | ||
} | ||
|
||
return ptags.toSet(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters