Why Nostr? What is Njump?
2024-06-10 12:42:46

NDK 2.8: "Fast and steady"

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 <span itemprop="mentions" itemscope itemtype="https://schema.org/Person"><a itemprop="url" href="/npub1dergggklka99wwrs92yz8wdjs952h2ux2ha2ed598ngwu9w7a6fsh9xzpc" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1"><span>derGigi ⚡🧡</span> (<span class="italic">npub1der…xzpc</span>)</a></span>
- 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

<span itemprop="mentions" itemscope itemtype="https://schema.org/Person"><a itemprop="url" href="/npub1dergggklka99wwrs92yz8wdjs952h2ux2ha2ed598ngwu9w7a6fsh9xzpc" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1"><span>derGigi ⚡🧡</span> (<span class="italic">npub1der…xzpc</span>)</a></span> 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.

Author Public Key
npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft