mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: add and fix more lints, improve docs (#4765)
This commit is contained in:
@ -21,6 +21,7 @@ use crate::{abstraction::table::*, DatabaseError};
|
||||
// Sealed trait helper to prevent misuse of the API.
|
||||
mod sealed {
|
||||
pub trait Sealed: Sized {}
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Bounds<T>(T);
|
||||
impl<T> Sealed for Bounds<T> {}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use std::{
|
||||
fmt,
|
||||
marker::PhantomData,
|
||||
ops::{Bound, RangeBounds},
|
||||
};
|
||||
@ -148,6 +149,16 @@ pub struct Walker<'cursor, 'tx, T: Table, CURSOR: DbCursorRO<'tx, T>> {
|
||||
_tx_phantom: PhantomData<&'tx T>,
|
||||
}
|
||||
|
||||
impl<'tx, T, CURSOR> fmt::Debug for Walker<'_, 'tx, T, CURSOR>
|
||||
where
|
||||
T: Table,
|
||||
CURSOR: DbCursorRO<'tx, T> + fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Walker").field("cursor", &self.cursor).field("start", &self.start).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cursor, 'tx, T: Table, CURSOR: DbCursorRO<'tx, T>> std::iter::Iterator
|
||||
for Walker<'cursor, 'tx, T, CURSOR>
|
||||
{
|
||||
@ -195,6 +206,19 @@ pub struct ReverseWalker<'cursor, 'tx, T: Table, CURSOR: DbCursorRO<'tx, T>> {
|
||||
_tx_phantom: PhantomData<&'tx T>,
|
||||
}
|
||||
|
||||
impl<'tx, T, CURSOR> fmt::Debug for ReverseWalker<'_, 'tx, T, CURSOR>
|
||||
where
|
||||
T: Table,
|
||||
CURSOR: DbCursorRO<'tx, T> + fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("ReverseWalker")
|
||||
.field("cursor", &self.cursor)
|
||||
.field("start", &self.start)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cursor, 'tx, T: Table, CURSOR: DbCursorRO<'tx, T>> ReverseWalker<'cursor, 'tx, T, CURSOR> {
|
||||
/// construct ReverseWalker
|
||||
pub fn new(cursor: &'cursor mut CURSOR, start: IterPairResult<T>) -> Self {
|
||||
@ -247,6 +271,21 @@ pub struct RangeWalker<'cursor, 'tx, T: Table, CURSOR: DbCursorRO<'tx, T>> {
|
||||
_tx_phantom: PhantomData<&'tx T>,
|
||||
}
|
||||
|
||||
impl<'tx, T, CURSOR> fmt::Debug for RangeWalker<'_, 'tx, T, CURSOR>
|
||||
where
|
||||
T: Table,
|
||||
CURSOR: DbCursorRO<'tx, T> + fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("RangeWalker")
|
||||
.field("cursor", &self.cursor)
|
||||
.field("start", &self.start)
|
||||
.field("end_key", &self.end_key)
|
||||
.field("is_done", &self.is_done)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cursor, 'tx, T: Table, CURSOR: DbCursorRO<'tx, T>> std::iter::Iterator
|
||||
for RangeWalker<'cursor, 'tx, T, CURSOR>
|
||||
{
|
||||
@ -322,6 +361,19 @@ pub struct DupWalker<'cursor, 'tx, T: DupSort, CURSOR: DbDupCursorRO<'tx, T>> {
|
||||
pub _tx_phantom: PhantomData<&'tx T>,
|
||||
}
|
||||
|
||||
impl<'tx, T, CURSOR> fmt::Debug for DupWalker<'_, 'tx, T, CURSOR>
|
||||
where
|
||||
T: DupSort,
|
||||
CURSOR: DbDupCursorRO<'tx, T> + fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("DupWalker")
|
||||
.field("cursor", &self.cursor)
|
||||
.field("start", &self.start)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cursor, 'tx, T: DupSort, CURSOR: DbCursorRW<'tx, T> + DbDupCursorRO<'tx, T>>
|
||||
DupWalker<'cursor, 'tx, T, CURSOR>
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ use crate::{
|
||||
|
||||
/// Mock database used for testing with inner BTreeMap structure
|
||||
/// TODO
|
||||
#[derive(Clone, Default)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct DatabaseMock {
|
||||
/// Main data. TODO (Make it table aware)
|
||||
pub data: BTreeMap<Vec<u8>, Vec<u8>>,
|
||||
@ -115,6 +115,7 @@ impl<'a> DbTxMut<'a> for TxMock {
|
||||
impl<'a> TableImporter<'a> for TxMock {}
|
||||
|
||||
/// Cursor that iterates over table
|
||||
#[derive(Debug)]
|
||||
pub struct CursorMock {
|
||||
_cursor: u32,
|
||||
}
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||
issue_tracker_base_url = "https://github.com/paradigmxzy/reth/issues/"
|
||||
)]
|
||||
//! reth's database abstraction layer with concrete implementations.
|
||||
//!
|
||||
//! The database abstraction assumes that the underlying store is a KV store subdivided into tables.
|
||||
@ -61,12 +55,14 @@
|
||||
//! [`Decompress`]: crate::abstraction::table::Decompress
|
||||
//! [`Table`]: crate::abstraction::table::Table
|
||||
|
||||
#![warn(missing_docs, unreachable_pub)]
|
||||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||
issue_tracker_base_url = "https://github.com/paradigmxzy/reth/issues/"
|
||||
)]
|
||||
#![warn(missing_debug_implementations, missing_docs, unreachable_pub, rustdoc::all)]
|
||||
#![deny(unused_must_use, rust_2018_idioms)]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
))]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
/// Traits defining the database abstractions, such as cursors and transactions.
|
||||
pub mod abstraction;
|
||||
|
||||
@ -7,10 +7,10 @@ use std::ops::Range;
|
||||
/// Total number of transactions.
|
||||
pub type NumTransactions = u64;
|
||||
|
||||
/// The storage of the block body indices
|
||||
/// The storage of the block body indices.
|
||||
///
|
||||
/// It has the pointer to the transaction Number of the first
|
||||
/// transaction in the block and the total number of transactions
|
||||
/// transaction in the block and the total number of transactions.
|
||||
#[derive(Debug, Default, Eq, PartialEq, Clone)]
|
||||
#[main_codec]
|
||||
pub struct StoredBlockBodyIndices {
|
||||
@ -65,10 +65,9 @@ impl StoredBlockBodyIndices {
|
||||
}
|
||||
}
|
||||
|
||||
/// The storage representation of a block ommers.
|
||||
/// The storage representation of a block's ommers.
|
||||
///
|
||||
/// It is stored as the headers of the block's uncles.
|
||||
/// tx_amount)`.
|
||||
#[main_codec]
|
||||
#[derive(Debug, Default, Eq, PartialEq, Clone)]
|
||||
pub struct StoredBlockOmmers {
|
||||
|
||||
Reference in New Issue
Block a user