Skip to content

Commit db4e215

Browse files
committed
Merge branch 'main' of github.com:sandwichfarm/nostr-trawl into main
2 parents cf996f6 + a13b278 commit db4e215

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
`nostrawl` is a simple tool for persistently fetching and processing filtered events from a set of [nostr](https://github.com/nostr-protocol/) relays.
88

9-
`nostrawl` wraps `nostr-fetch` (with the `nostr-tools` simple-pool adapter) and implements adapters for queuing fetch jobs.
9+
`nostrawl` wraps `nostr-fetch` (with the `nostr-tools` simple-pool adapter) and implements adapters for queuing fetch jobs. Implements an LMDB cache that can be accessed via provided `parser` and `validator` functions.
1010

1111
## Install
1212
```
@@ -18,7 +18,7 @@ _npm package soon_
1818

1919
With docker
2020
```
21-
pnp run example
21+
pnpm run example
2222
```
2323
With a local redis instance. Use defaults, or set with envvars (REDIS_HOST, REDIS_PORT, etc)
2424
```
@@ -45,8 +45,6 @@ dotenv.config()
4545

4646
const relays = ["wss://relay.damus.io","wss://nostr-pub.wellorder.net","wss://nostr.mom","wss://nostr.slothy.win","wss://global.relay.red"]
4747

48-
const event_ids = new Set()
49-
5048
const options = {
5149
filters: { kinds: [3] },
5250
adapter: 'bullmq',
@@ -70,12 +68,15 @@ const options = {
7068
removeOnComplete: true,
7169
removeOnFail: true
7270
},
73-
parser: async (event) => {
74-
event_ids.add(event.id)
75-
// console.log(event.created_at)
71+
//the cache is used internal to remember the last time
72+
//a relay was filtered against, so it can resume from
73+
//there later. It uses to the key `lastUpdate:${timestamp}`
74+
//so be weary of that.
75+
parser: async ($trawler, event) => {
76+
$trawler.cache.put(`found:${event.id}`)
7677
},
77-
validator: (event) => {
78-
if(event_ids.has(event.id))
78+
validator: ($trawler, event) => {
79+
if($trawler.cache.get(`found:${event.id`))
7980
return false
8081
return true
8182
}

0 commit comments

Comments
 (0)