+
Skip to content

Fix all typos #313

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

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/floresta-chain/src/pruned_utreexo/chainparams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct ChainParams {
}

/// A dns seed is a authoritative DNS server that returns the IP addresses of nodes that are
/// likely to be accepting incoming connections. This is our prefered way of finding new peers
/// likely to be accepting incoming connections. This is our preferred way of finding new peers
/// on the first startup, as peers returned by seeds are likely to be online and accepting
/// connections. We may use this as a fallback if we don't have any peers to connect in
/// subsequent startups.
Expand Down
6 changes: 3 additions & 3 deletions crates/floresta-chain/src/pruned_utreexo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait BlockchainInterface {
/// Register for receiving notifications for some event. Right now it only works for
/// new blocks, but may work with transactions in the future too.
/// if a module performs some heavy-lifting on the block's data, it should pass in a
/// vector or a channel where data can be transfered to the atual worker, otherwise
/// vector or a channel where data can be transferred to the atual worker, otherwise
/// chainstate will be stuck for as long as you have work to do.
fn subscribe(&self, tx: Arc<dyn BlockConsumer>);
/// Tells whether or not we are on ibd
Expand Down Expand Up @@ -136,7 +136,7 @@ pub trait UpdatableChainstate {
/// Returns a partial chainstate from a range of blocks.
///
/// [PartialChainState] is a simplified version of `ChainState` that is used during IBD.
/// It doesn't suport reorgs, only hold headers for a subset of blocks and isn't [Sync].
/// It doesn't support reorgs, only hold headers for a subset of blocks and isn't [Sync].
/// The idea here is that you take a OS thread or some async task that will drive one
/// [PartialChainState] to completion by downloading blocks inside that chainstate's range.
/// If all goes right, it'll end without error, and you should mark blocks in this range as
Expand All @@ -152,7 +152,7 @@ pub trait UpdatableChainstate {
) -> Result<PartialChainState, BlockchainError>;
/// Marks a chain as fully-valid
///
/// This mimics the behavour of checking every block before this block, and continues
/// This mimics the behaviour of checking every block before this block, and continues
/// from this point
fn mark_chain_as_assumed(&self, acc: Stump, tip: BlockHash) -> Result<bool, BlockchainError>;
}
Expand Down
22 changes: 11 additions & 11 deletions crates/floresta-chain/src/pruned_utreexo/partial_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//! and then merge them together to get the full chain. This allows us to make
//! Initial Block Download in parallel.
//!
//! We use a [PartialChainState] insted of the useal ChainState, mainly for
//! We use a [PartialChainState] instead of the useal ChainState, mainly for
//! performance. Because we assume that only one worker will hold a [PartialChainState]
//! at a given time, we can drop all syncronization primitives and make a really performatic
//! at a given time, we can drop all synchronization primitives and make a really performatic
//! ChainState that will consume and validate blocks as fast as we possibly can.
//!
//! This choice removes the use of costly atomic operations, but opens space for design flaws
Expand All @@ -15,7 +15,7 @@
//! - Shared ownership is forbidden: if you have two threads or tasks owning this, you'll have
//! data race. If you want to hold shared ownership for this module, you need to place a
//! [PartialChainState] inside an `Arc<Mutex>` yourself. Don't just Arc this and expect it to
//! work, as you are garanteed to have data races.
//! work, as you are guaranteed to have data races.
//! - The interior is toxic, so no peeking: no references, mutable or not, to any field should
//! leak through the API, as we are not enforcing lifetime or borrowing rules at compile time.
//! - Sending is fine: There's nothing in this module that makes it not sendable to between
Expand Down Expand Up @@ -62,7 +62,7 @@ pub(crate) struct PartialChainStateInner {
/// result in an error.
pub(crate) final_height: u32,
/// The error that occurred during validation, if any. It is here so we can
/// pull that afterwords.
/// pull that afterwards.
pub(crate) error: Option<BlockValidationErrors>,
/// The consensus parameters, we need this to validate the blocks.
pub(crate) consensus: Consensus,
Expand All @@ -83,14 +83,14 @@ pub(crate) struct PartialChainStateInner {
/// We could just use a mutex, but this is not required and very wateful. Partial chains
/// differ from the normal chain because they only have one owner, the worker responsible
/// for driving this chain to it's completion. Because of that, we can simply use a UnsafeCell
/// and forbit shared access between threads by not implementing [Clone].
/// and forbid shared access between threads by not implementing [Clone].
pub struct PartialChainState(pub(crate) UnsafeCell<PartialChainStateInner>);

/// We need to send [PartialChainState] between threads/tasks, because the worker thread, once it
/// finishes, needs to notify the main task and pass the final partial chain.
/// # Safety
///
/// All itens inside the [UnsafeCell] are [Send], most importantly, there are no references or
/// All items inside the [UnsafeCell] are [Send], most importantly, there are no references or
/// smart pointers inside it, so sending shouldn't be a problem.
unsafe impl Send for PartialChainState {}
unsafe impl Sync for PartialChainState {}
Expand Down Expand Up @@ -255,29 +255,29 @@ impl PartialChainStateInner {
}

impl PartialChainState {
/// Borrows the inner content as immutable referece.
/// Borrows the inner content as immutable reference.
///
/// # Safety
/// We can assume this [UnsafeCell] is initialized because the only way to get a
/// [PartialChainState] is through our APIs, and we make sure this [UnsafeCell] is
/// always valid.
/// The reference returned here **should not** leak through the API, as there's no
/// syncronization mechanims for it.
/// synchronization mechanims for it.
#[inline(always)]
#[must_use]
#[doc(hidden)]
fn inner(&self) -> &PartialChainStateInner {
unsafe { self.0.get().as_ref().expect("this pointer is valid") }
}

/// Borrows the inner content as a mutable referece.
/// Borrows the inner content as a mutable reference.
///
/// # Safety
/// We can assume this [UnsafeCell] is initialized because the only way to get a
/// [PartialChainState] is through our APIs, and we make sure this [UnsafeCell] is
/// always valid.
/// The reference returned here **should not** leak through the API, as there's no
/// syncronization mechanims for it.
/// synchronization mechanims for it.
#[inline(always)]
#[allow(clippy::mut_from_ref)]
#[must_use]
Expand Down Expand Up @@ -471,7 +471,7 @@ impl BlockchainInterface for PartialChainState {
}

fn subscribe(&self, _tx: sync::Arc<dyn crate::BlockConsumer>) {
unimplemented!("partialChainState::subscibe")
unimplemented!("partialChainState::subscribe")
}

fn estimate_fee(&self, _target: usize) -> Result<f64, Self::Error> {
Expand Down
6 changes: 3 additions & 3 deletions crates/floresta-cli/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub trait FlorestaRPC {
/// designed for efficient light client synchronization. This method returns the filter
/// for a given block height, encoded as a hexadecimal string.
/// You need to have enabled block filters by setting the `blockfilters=1` option
fn get_block_filter(&self, heigth: u32) -> Result<String>;
fn get_block_filter(&self, height: u32) -> Result<String>;
/// Returns general information about the chain we are on
///
/// This method returns a bunch of information about the chain we are on, including
Expand Down Expand Up @@ -214,8 +214,8 @@ impl<T: JsonRPCClient> FlorestaRPC for T {
self.call("loaddescriptor", &[Value::String(descriptor)])
}

fn get_block_filter(&self, heigth: u32) -> Result<String> {
self.call("getblockfilter", &[Value::Number(Number::from(heigth))])
fn get_block_filter(&self, height: u32) -> Result<String> {
self.call("getblockfilter", &[Value::Number(Number::from(height))])
}

fn get_block_header(&self, hash: BlockHash) -> Result<BlockHeader> {
Expand Down
26 changes: 13 additions & 13 deletions crates/floresta-cli/src/rpc_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct RawTx {
pub size: u32,
/// The virtual size of this transaction, as define by the segwit soft-fork
pub vsize: u32,
/// The weight of this transacion, as defined by the segwit soft-fork
/// The weight of this transaction, as defined by the segwit soft-fork
pub weight: u32,
/// This transaction's version. The current bigger version is 2
pub version: u32,
Expand Down Expand Up @@ -93,7 +93,7 @@ pub struct TxOut {
pub value: u64,
/// This utxo's index inside the transaction
pub n: u32,
/// The loking script of this utxo
/// The locking script of this utxo
pub script_pub_key: ScriptPubKey,
}

Expand Down Expand Up @@ -159,7 +159,7 @@ pub struct PeerInfo {
/// User agent is a string that represents the client being used by our peer. E.g.
/// /Satoshi-26.0/ for bitcoin core version 26
pub user_agent: String,
/// This peer's height at the time we've openned a connection with them
/// This peer's height at the time we've opened a connection with them
pub initial_height: u32,
/// The connection type of this peer
///
Expand Down Expand Up @@ -197,7 +197,7 @@ pub struct GetBlockRes {
///
/// Currently, blocks have version 2 (see BIP34), but it may also flip some of the LSB for
/// either consensus reason (see BIPs 8 and 9) or for version rolling mining, usually bits
/// after the 24th are not touched. Therefore, the actual version is likelly the result of
/// after the 24th are not touched. Therefore, the actual version is likely the result of
/// version & ~(1 << 24).
/// This is encoded as a number, see `version_hex` for a hex-encoded version
pub version: i32,
Expand All @@ -213,13 +213,13 @@ pub struct GetBlockRes {
pub merkleroot: String,
/// A list of hex-encoded transaction id for the tx's in this block
pub tx: Vec<String>,
/// The timestamp commited to in this block's header
/// The timestamp committed to in this block's header
///
/// Since there's no central clock that can tell time precisely in Bitcoin, this value is
/// reported by miners and only constrained by a couple of consensus rules. More sensibly, it
/// is **not** garanteed to be monotonical. So a block n might have a lower timestamp than
/// is **not** guaranteed to be monotonical. So a block n might have a lower timestamp than
/// block `n - 1`.
/// If you need it to be monotonical, see `mediantime` insted
/// If you need it to be monotonical, see `mediantime` instead
pub time: u32,
/// The meadian of the last 11 blocktimes.
///
Expand All @@ -234,13 +234,13 @@ pub struct GetBlockRes {
pub nonce: u32,
/// Bits is a compact representation for the target.
///
/// This is a exponential format (with well-define rouding) used by openssl that Satoshi
/// This is a exponential format (with well-define rounding) used by openssl that Satoshi
/// decided to make consensus critical :/
pub bits: String,
/// The difficulty is derived from the current target and is defined as how many hashes, on
/// average, one has to make before finding a valid block
///
/// This is computed as 1 / (target / 2 ^ 256). In most softwares (this one inclued) the
/// This is computed as 1 / (target / 2 ^ 256). In most software (this one included) the
/// difficulty is a multiple of the smallest possible difficulty. So to find the actual
/// difficulty you have to multiply this by the min_diff.
/// For mainnet, mindiff is 2 ^ 32
Expand All @@ -251,10 +251,10 @@ pub struct GetBlockRes {
pub chainwork: String,
/// How many transactions in this block
pub n_tx: usize,
/// The hash of the block comming before this one
/// The hash of the block coming before this one
pub previousblockhash: String,
#[serde(skip_serializing_if = "Option::is_none")]
/// The hash of the block comming after this one, if any
/// The hash of the block coming after this one, if any
pub nextblockhash: Option<String>,
}

Expand All @@ -269,7 +269,7 @@ pub enum Error {
/// An error internal to our jsonrpc server
Api(serde_json::Value),
/// The server sent an empty response
EmtpyResponse,
EmptyResponse,
}

impl From<serde_json::Error> for Error {
Expand All @@ -292,7 +292,7 @@ impl Display for Error {
Error::JsonRpc(e) => write!(f, "JsonRpc returned an error {e}"),
Error::Api(e) => write!(f, "general jsonrpc error: {e}"),
Error::Serde(e) => write!(f, "error while deserializing the response: {e}"),
Error::EmtpyResponse => write!(f, "got an empty response from server"),
Error::EmptyResponse => write!(f, "got an empty response from server"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/floresta-common/src/spsc.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! A no-std Single Producer, Single Consumer channel for unidirectional message exchange between
//! modules. This module don't use anything from the standard lib and can be easily used in no-std
//! enviroments. We only use mem::take from [core].
//! environments. We only use mem::take from [core].

use core::mem::take;

use crate::prelude::Vec;

/// A (Send + Sync) single producer, single consumer channel to notify modules about things.
/// The api is super minimalistic to reduce external dependecies, including from the std-lib
/// The api is super minimalistic to reduce external dependencies, including from the std-lib
///
/// One notable difference from the standard mspc channel is that this channel's ends are't
/// two different types, while this is possible, there's no reason to do that. Specially
Expand Down Expand Up @@ -72,7 +72,7 @@ impl<T> Channel<T> {

/// An iterator issued every time someone calls `recv`.
///
/// This iterator takes all itens available for reading in a channel
/// This iterator takes all items available for reading in a channel
/// and lets the consumer iterate over them, without acquiring the lock
/// every time (the mutex is only locked when `recv` is called).
///
Expand Down
24 changes: 12 additions & 12 deletions crates/floresta-compact-filters/src/flat_filters_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use std::sync::Mutex;
use std::sync::MutexGuard;
use std::sync::PoisonError;

use crate::IteratableFilterStore;
use crate::IteratableFilterStoreError;
use crate::IterableFilterStore;
use crate::IterableFilterStoreError;

pub struct FiltersIterator {
reader: BufReader<File>,
Expand Down Expand Up @@ -50,9 +50,9 @@ struct FlatFiltersStoreInner {
path: PathBuf,
}

impl From<PoisonError<MutexGuard<'_, FlatFiltersStoreInner>>> for IteratableFilterStoreError {
impl From<PoisonError<MutexGuard<'_, FlatFiltersStoreInner>>> for IterableFilterStoreError {
fn from(_: PoisonError<MutexGuard<'_, FlatFiltersStoreInner>>) -> Self {
IteratableFilterStoreError::Poisoned
IterableFilterStoreError::Poisoned
}
}

Expand Down Expand Up @@ -126,17 +126,17 @@ impl IntoIterator for FlatFiltersStore {
}
}

impl IteratableFilterStore for FlatFiltersStore {
impl IterableFilterStore for FlatFiltersStore {
type I = FiltersIterator;
fn set_height(&self, height: u32) -> Result<(), IteratableFilterStoreError> {
fn set_height(&self, height: u32) -> Result<(), IterableFilterStoreError> {
let mut inner = self.0.lock()?;
inner.file.seek(SeekFrom::Start(0))?;
inner.file.write_all(&height.to_le_bytes())?;

Ok(())
}

fn get_height(&self) -> Result<u32, IteratableFilterStoreError> {
fn get_height(&self) -> Result<u32, IterableFilterStoreError> {
let mut inner = self.0.lock()?;

let mut buf = [0; 4];
Expand All @@ -146,7 +146,7 @@ impl IteratableFilterStore for FlatFiltersStore {
Ok(u32::from_le_bytes(buf))
}

fn iter(&self, start_height: Option<usize>) -> Result<Self::I, IteratableFilterStoreError> {
fn iter(&self, start_height: Option<usize>) -> Result<Self::I, IterableFilterStoreError> {
let mut inner = self.0.lock()?;
let new_file = File::open(inner.path.clone())?;
let mut reader = BufReader::new(new_file);
Expand Down Expand Up @@ -176,11 +176,11 @@ impl IteratableFilterStore for FlatFiltersStore {
&self,
block_filter: crate::bip158::BlockFilter,
height: u32,
) -> Result<(), IteratableFilterStoreError> {
) -> Result<(), IterableFilterStoreError> {
let length = block_filter.content.len() as u32;

if length > 1_000_000 {
return Err(IteratableFilterStoreError::FilterTooLarge);
return Err(IterableFilterStoreError::FilterTooLarge);
}

let mut inner = self.0.lock()?;
Expand Down Expand Up @@ -210,15 +210,15 @@ mod tests {

use super::FlatFiltersStore;
use crate::bip158::BlockFilter;
use crate::IteratableFilterStore;
use crate::IterableFilterStore;

#[test]
fn test_filter_store() {
let path = "test_filter_store";
let store = FlatFiltersStore::new(path.into());

let res = store.get_height().unwrap_err();
assert!(matches!(res, crate::IteratableFilterStoreError::Io(_)));
assert!(matches!(res, crate::IterableFilterStoreError::Io(_)));
store.set_height(1).expect("could not set height");
assert_eq!(store.get_height().unwrap(), 1);

Expand Down
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载