Skip to content

Conversation

DracoLi
Copy link
Contributor

@DracoLi DracoLi commented Aug 26, 2025

Why this should be merged

Adds an in memory implementation of database.HeightIndex. The main use of this will be in tests where we don't need a on-disk height-indexed database.

How this works

The package is in database/heightindexdb/memdb. It uses a map to store data by height.

How this was tested

Unit tests

Need to be documented in RELEASES.md?

No

@DracoLi DracoLi marked this pull request as ready for review August 28, 2025 17:51
@Copilot Copilot AI review requested due to automatic review settings August 28, 2025 17:51
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 introduces an in-memory implementation of the BlockDatabase interface for testing purposes, allowing tests to avoid using on-disk storage when not necessary.

  • Adds a new MemoryDatabase struct that implements the BlockDatabase interface
  • Provides thread-safe operations using read-write mutexes
  • Includes proper error handling for closed database states and empty blocks

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

@DracoLi DracoLi requested review from a team and joshua-kim and removed request for a team August 28, 2025 19:58
@DracoLi DracoLi requested a review from joshua-kim September 2, 2025 18:37
@joshua-kim joshua-kim moved this to Backlog 🧊 in avalanchego Sep 8, 2025
@joshua-kim joshua-kim moved this from Backlog 🧊 to In Progress 🏗️ in avalanchego Sep 9, 2025
@joshua-kim joshua-kim moved this from In Progress 🏗️ to In Review 🔎 in avalanchego Sep 9, 2025
@DracoLi DracoLi requested a review from joshua-kim September 9, 2025 21:37
@DracoLi DracoLi requested a review from joshua-kim September 15, 2025 15:43
@DracoLi DracoLi force-pushed the dl/blockdb-memory-mock branch from 6501406 to 01d9423 Compare September 23, 2025 14:43
@DracoLi DracoLi changed the title feat: added in memory implementation of blockdb feat: added in memory implementation of HeightIndex Database Sep 23, 2025
@DracoLi DracoLi changed the title feat: added in memory implementation of HeightIndex Database feat: add in memory implementation of HeightIndex Database Sep 23, 2025
@DracoLi DracoLi force-pushed the dl/blockdb-memory-mock branch from 3e996ff to 88f2394 Compare September 23, 2025 22:19
// Has checks if an entry exists at the given height.
// Has checks if a value exists at the given height.
//
// Return true even if the stored value is nil, or empty.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also confused here, I thought Get returned nil if you inserted empty - why does Has return nil or empty?

Copy link
Contributor Author

@DracoLi DracoLi Sep 29, 2025

Choose a reason for hiding this comment

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

this is to clarify Has returns true if the value at the key is nil or empty.

@DracoLi DracoLi requested a review from joshua-kim September 29, 2025 20:35
Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

comment nits then lgtm

@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 30, 2025
Merged via the queue into master with commit 188f7e3 Sep 30, 2025
35 checks passed
@StephenButtolph StephenButtolph deleted the dl/blockdb-memory-mock branch September 30, 2025 17:44
@github-project-automation github-project-automation bot moved this from In Review 🔎 to Done 🎉 in avalanchego Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants