NDK 2.8: "Fast and steady"

NDK 2.8 has been released, coming with a plethora of performance improvements, threading capabilities and many many other things. TL;DR: Optimistic signature-verification Threaded signature-verification Threads, threads, threads! s/o Dexie cache adapter becomes massively more efficient Onwards 🫡

PABLOF7z

23. April 2024April 23, 2024 · 2 Min. Lesezeit2 min read · Aktualisiert am 10. Juni 2024Updated June 10, 2024

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:

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#

⁠Gigi 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.

#development#ndk#nostr

Written by

Comments

No comments yet. Start the conversation.

Contents

2 sections

  1. Performance boost
  2. Threading