Skip to content

Persistent nodedb #780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft

Persistent nodedb #780

wants to merge 17 commits into from

Conversation

philon-
Copy link
Contributor

@philon- philon- commented Aug 12, 2025

Description

This is a draft PR that adds persistence of node database. This is the first step towards safe persistence of messages, telemetry and so on.

This is very much a rough draft, I just wanted it here so that we can keep track on the progress, what remains and what should (and should not) be part of this PR.

Still remaining before this can be merged:

  • Wipe persisted database when the nodedb reset option is called
  • Update PKI regen dialog to allow reuse when nodes have mismatching keys
  • (?) CommandPalette option to disconnect & wipe storage
  • Tests

Related Issues

Changes Made

Major:

  • Refactored deviceStore by breaking the monolith apart and bringing all nodeDB methods into its own nodeDBStore
  • Adjusted the DeviceContext so that instead of passing the Device object along, we only pass the nodenum and get the correct Device and NodeDB objects from their respective hooks useDevice and useNodeDB
  • Rewrote the JSON serializer previously used for the messageStore to allow more special handlers, since more datatypes need specific (de)serialization.
  • Defined NODEDB_RETENTION_NUM (currently 10) which defined how many separate devices' nodeDBs should be saved before cycling them out.
  • Tests for nodeDB store, indexDB handler

Minor:

  • Updated useFavoriteNode and useIgnoreNode to use the separate device and nodedb stores.
  • Updated existing tests

Testing Done

Screenshots (if applicable)

Checklist

  • Code follows project style guidelines
  • Documentation has been updated or added
  • Tests have been added or updated
  • All i18n translation labels have been added (read
    CONTRIBUTING_I18N_DEVELOPER_GUIDE.md for more details)

@Copilot Copilot AI review requested due to automatic review settings August 12, 2025 21:01
Copy link

vercel bot commented Aug 12, 2025

@philon- is attempting to deploy a commit to the Meshtastic Team on Vercel.

A member of the Team first needs to authorize it.

@philon- philon- marked this pull request as draft August 12, 2025 21:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements persistence for the node database by separating node-related functionality from the monolithic device store into a dedicated nodeDB store. The refactoring improves data organization and enables persistent storage of node information.

Key Changes

  • Extracted node-related methods from the device store into a separate nodeDB store with persistence
  • Refactored device context to use device IDs instead of device objects
  • Rewrote the JSON serializer to support additional data types like Map and Uint8Array

Reviewed Changes

Copilot reviewed 84 out of 85 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/web/src/core/stores/nodeDBStore/index.ts New persistent nodeDB store with Map storage and Uint8Array support
packages/web/src/core/stores/utils/indexDB.ts Generic JSON serializer with custom type handlers for persistence
packages/web/src/core/stores/deviceStore/index.ts Removed node-related methods, now focuses on device-specific functionality
packages/web/src/core/stores/index.ts Central export file with new useNodeDB and useDevice hooks
packages/web/src/core/subscriptions.ts Updated to use separate device and nodeDB stores

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants