chore: rewrite all error messages for consistency (#5176)

Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
DaniPopes
2023-10-25 22:12:03 +02:00
committed by GitHub
parent 1c0373b322
commit e05dba69ce
73 changed files with 649 additions and 599 deletions

View File

@ -187,29 +187,22 @@ tables!([
(PruneCheckpoints, TableType::Table)
]);
#[macro_export]
/// Macro to declare key value table.
#[macro_export]
macro_rules! table {
($(#[$docs:meta])+ ( $table_name:ident ) $key:ty | $value:ty) => {
$(#[$docs])+
///
#[doc = concat!("Takes [`", stringify!($key), "`] as a key and returns [`", stringify!($value), "`]")]
#[doc = concat!("Takes [`", stringify!($key), "`] as a key and returns [`", stringify!($value), "`].")]
#[derive(Clone, Copy, Debug, Default)]
pub struct $table_name;
impl $crate::table::Table for $table_name {
const NAME: &'static str = $table_name::const_name();
const NAME: &'static str = stringify!($table_name);
type Key = $key;
type Value = $value;
}
impl $table_name {
#[doc=concat!("Return ", stringify!($table_name), " as it is present inside the database.")]
pub const fn const_name() -> &'static str {
stringify!($table_name)
}
}
impl std::fmt::Display for $table_name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", stringify!($table_name))
@ -225,7 +218,7 @@ macro_rules! dupsort {
table!(
$(#[$docs])+
///
#[doc = concat!("`DUPSORT` table with subkey being: [`", stringify!($subkey), "`].")]
#[doc = concat!("`DUPSORT` table with subkey being: [`", stringify!($subkey), "`]")]
( $table_name ) $key | $value
);
impl DupSort for $table_name {
@ -430,37 +423,36 @@ pub type StageId = String;
#[cfg(test)]
mod tests {
use super::*;
use std::str::FromStr;
use crate::*;
const TABLES: [(TableType, &str); NUM_TABLES] = [
(TableType::Table, CanonicalHeaders::const_name()),
(TableType::Table, HeaderTD::const_name()),
(TableType::Table, HeaderNumbers::const_name()),
(TableType::Table, Headers::const_name()),
(TableType::Table, BlockBodyIndices::const_name()),
(TableType::Table, BlockOmmers::const_name()),
(TableType::Table, BlockWithdrawals::const_name()),
(TableType::Table, TransactionBlock::const_name()),
(TableType::Table, Transactions::const_name()),
(TableType::Table, TxHashNumber::const_name()),
(TableType::Table, Receipts::const_name()),
(TableType::Table, PlainAccountState::const_name()),
(TableType::DupSort, PlainStorageState::const_name()),
(TableType::Table, Bytecodes::const_name()),
(TableType::Table, AccountHistory::const_name()),
(TableType::Table, StorageHistory::const_name()),
(TableType::DupSort, AccountChangeSet::const_name()),
(TableType::DupSort, StorageChangeSet::const_name()),
(TableType::Table, HashedAccount::const_name()),
(TableType::DupSort, HashedStorage::const_name()),
(TableType::Table, AccountsTrie::const_name()),
(TableType::DupSort, StoragesTrie::const_name()),
(TableType::Table, TxSenders::const_name()),
(TableType::Table, SyncStage::const_name()),
(TableType::Table, SyncStageProgress::const_name()),
(TableType::Table, PruneCheckpoints::const_name()),
(TableType::Table, CanonicalHeaders::NAME),
(TableType::Table, HeaderTD::NAME),
(TableType::Table, HeaderNumbers::NAME),
(TableType::Table, Headers::NAME),
(TableType::Table, BlockBodyIndices::NAME),
(TableType::Table, BlockOmmers::NAME),
(TableType::Table, BlockWithdrawals::NAME),
(TableType::Table, TransactionBlock::NAME),
(TableType::Table, Transactions::NAME),
(TableType::Table, TxHashNumber::NAME),
(TableType::Table, Receipts::NAME),
(TableType::Table, PlainAccountState::NAME),
(TableType::DupSort, PlainStorageState::NAME),
(TableType::Table, Bytecodes::NAME),
(TableType::Table, AccountHistory::NAME),
(TableType::Table, StorageHistory::NAME),
(TableType::DupSort, AccountChangeSet::NAME),
(TableType::DupSort, StorageChangeSet::NAME),
(TableType::Table, HashedAccount::NAME),
(TableType::DupSort, HashedStorage::NAME),
(TableType::Table, AccountsTrie::NAME),
(TableType::DupSort, StoragesTrie::NAME),
(TableType::Table, TxSenders::NAME),
(TableType::Table, SyncStage::NAME),
(TableType::Table, SyncStageProgress::NAME),
(TableType::Table, PruneCheckpoints::NAME),
];
#[test]