-
![](https://m.primal.net/KwlG.jpg)
@ PABLOF7z
2024-06-10 10:42:46
I'm happy to announce the release of NDK 2.8 which comes with a plethora of new performance improvements, threading capabilities and many many other things.
TL;DR:
- Optimistic signature-verification
- Threaded signature-verification
- Threads, threads, threads! s/o nostr:npub1dergggklka99wwrs92yz8wdjs952h2ux2ha2ed598ngwu9w7a6fsh9xzpc
- Dexie cache adapter becomes massively more efficient
Onwards 🫡
## Performance boost
### Optimistic signature-verification
NDK can now be configured to perform signature verification of events asynchronously. This means that events are assumed to be valid and pushed to a queue.
When an invalid signature is received, a global event is emitted for the application to handle accordingly (i.e. alert the user, disconnect from the evil relay, etc)
### Web Worker Signature Verification
Signature verification can be offloaded to a web worker (meaning that it runs on it's own thread) with the `workers/sig-verification` that comes with NDK. Other web workers can be implemented and hooked to NDK.
### Dexie Cache Adapter Improvements
This cache adapter now works mostly as an LRU in-memory cache; while using IndexDB mostly just as a persistence storage.
## Threading
nostr:npub1dergggklka99wwrs92yz8wdjs952h2ux2ha2ed598ngwu9w7a6fsh9xzpc has paved the way to show how broken thread rendering is in nostr multiple-times. This release includes a bunch of helper functions that should make proper thread rendering incredibly obvious.
When fetching events, these functions can be used to make sense of what's the right ordering, what are replies, what is part of the main thread, etc.
The main entry point to these threading utility functions is `eventThreads`, which can be provided a set of fetched events and will return, in order, the events that belong to the thread. All other events can be rendered as replies.
There are many more very useful functions along with it that can be found on `src/threads`. Examples of how to use these can be found on the open sourced Highlighter codebase.