Skip to content
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

Fix typos, grammar, comment clarification and standardization. #85

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
22 changes: 11 additions & 11 deletions xelis_common/src/account/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use super::CiphertextCache;
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum BalanceType {
// Only incoming funds were added
// By default, a balance is considered as input
// Only incoming funds were added.
// By default, a balance is considered as input.
Input,
// Only a spending was made from this
Output,
Expand Down Expand Up @@ -42,17 +42,17 @@ impl Serializer for BalanceType {

#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, Debug)]
pub struct VersionedBalance {
// Output balance is used in case of multi TXs not in same block
// Output balance is used in case of multi TXs not in same block.
// If you build several TXs at same time but are not in the same block,
// and a incoming tx happen we need to keep track of the output balance
// and a incoming tx happen we need to keep track of the output balance.
output_balance: Option<CiphertextCache>,
// Final user balance that contains outputs and inputs balance
// This is the balance shown to a user and used to build TXs
// Final user balance that contains outputs and inputs balance.
// This is the balance shown to a user and used to build TXs.
final_balance: CiphertextCache,
// Determine if there was any output made in this version
balance_type: BalanceType,
// Topoheight of the previous versioned balance
// If its none, that means it's the first version available
// Topoheight of the previous versioned balance.
// If its none, that means it's the first version available.
previous_topoheight: Option<u64>,
}

Expand Down Expand Up @@ -211,11 +211,11 @@ impl Serializer for Balance {

#[derive(Debug)]
pub struct AccountSummary {
// last output balance stored on chain
// Last output balance stored on chain.
// It can be None if the account has no output balance
// or if the output balance is already in stable_version
// or if the output balance is already in stable_version.
pub output_version: Option<Balance>,
// last balance stored on chain below or equal to stable topoheight
// Last balance stored on chain below or equal to stable topoheight.
pub stable_version: Balance
}

Expand Down
94 changes: 47 additions & 47 deletions xelis_common/src/api/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ pub struct GetBlockTemplateResult {

#[derive(Serialize, Deserialize, PartialEq)]
pub struct GetMinerWorkResult {
// algorithm to use
// Algorithm to use
pub algorithm: Algorithm,
// template is miner job in hex format
// Template is miner job in hex format
pub miner_work: String,
// block height
// Block height
pub height: u64,
// difficulty required for valid block POW
// Difficulty required for valid block POW
pub difficulty: Difficulty,
// topoheight of the daemon
// this is for visual purposes only
// Topoheight of the daemon
// This is for visual purposes only
pub topoheight: u64,
}

Expand Down Expand Up @@ -252,7 +252,7 @@ pub struct GetInfoResult {
pub block_reward: u64,
pub dev_reward: u64,
pub miner_reward: u64,
// count how many transactions are present in mempool
// Count how many transactions are present in mempool
pub mempool_size: usize,
// software version on which the daemon is running
pub version: String,
Expand All @@ -262,7 +262,7 @@ pub struct GetInfoResult {

#[derive(Serialize, Deserialize)]
pub struct SubmitTransactionParams {
pub data: String // should be in hex format
pub data: String // Should be in hex format
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -371,13 +371,13 @@ pub struct GetTransactionsParams {

#[derive(Serialize, Deserialize)]
pub struct TransactionResponse<'a> {
// in which blocks it was included
// In which blocks it was included
pub blocks: Option<HashSet<Hash>>,
// in which blocks it was executed
// In which blocks it was executed
pub executed_in_block: Option<Hash>,
// if it is in mempool
// If it is in mempool
pub in_mempool: bool,
// if its a mempool tx, we add the timestamp when it was added
// If its a mempool tx, we add the timestamp when it was added
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub first_seen: Option<TimestampSeconds>,
Expand Down Expand Up @@ -470,16 +470,16 @@ pub struct IsTxExecutedInBlockParams<'a> {
// Struct to define dev fee threshold
#[derive(serde::Serialize, serde::Deserialize)]
pub struct DevFeeThreshold {
// block height to start dev fee
// Block height to start dev fee
pub height: u64,
// percentage of dev fee, example 10 = 10%
// Percentage of dev fee, example 10 = 10%
pub fee_percentage: u64
}

// Struct to define hard fork
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct HardFork {
// block height to start hard fork
// Block height to start hard fork
pub height: u64,
// Block version to use
pub version: BlockVersion,
Expand All @@ -504,11 +504,11 @@ pub struct GetMempoolCacheParams<'a> {

#[derive(Serialize, Deserialize)]
pub struct GetMempoolCacheResult {
// lowest nonce used
// Lowest nonce used
min: u64,
// highest nonce used
// Highest nonce used
max: u64,
// all txs ordered by nonce
// All TXs ordered by nonce
txs: Vec<Hash>,
// All "final" cached balances used
balances: HashMap<Hash, CiphertextCache>
Expand Down Expand Up @@ -559,51 +559,51 @@ pub struct MakeIntegratedAddressParams<'a> {
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum NotifyEvent {
// When a new block is accepted by chain
// it contains NewBlockEvent as value
// When a new block is accepted by chain,
// it contains NewBlockEvent as value.
NewBlock,
// When a block (already in chain or not) is ordered (new topoheight)
// it contains BlockOrderedEvent as value
// When a block (already in chain or not) is ordered (new topoheight),
// it contains BlockOrderedEvent as value.
BlockOrdered,
// When a block that was ordered is not in the new DAG order
// it contains BlockOrphanedEvent that got orphaned
// When a block that was ordered is not in the new DAG order,
// it contains BlockOrphanedEvent that got orphaned.
BlockOrphaned,
// When stable height has changed (different than the previous one)
// it contains StableHeightChangedEvent struct as value
// When stable height has changed (different than the previous one),
// it contains StableHeightChangedEvent struct as value.
StableHeightChanged,
// When stable topoheight has changed (different than the previous one)
// it contains StableTopoHeightChangedEvent struct as value
// When stable topoheight has changed (different than the previous one),
// it contains StableTopoHeightChangedEvent struct as value.
StableTopoHeightChanged,
// When a transaction that was executed in a block is not reintroduced in mempool
// It contains TransactionOrphanedEvent as value
// When a transaction that was executed in a block is not reintroduced in mempool,
// It contains TransactionOrphanedEvent as value.
TransactionOrphaned,
// When a new transaction is added in mempool
// it contains TransactionAddedInMempoolEvent struct as value
// When a new transaction is added in mempool,
// it contains TransactionAddedInMempoolEvent struct as value.
TransactionAddedInMempool,
// When a transaction has been included in a valid block & executed on chain
// it contains TransactionExecutedEvent struct as value
// When a transaction has been included in a valid block & executed on chain,
// it contains TransactionExecutedEvent struct as value.
TransactionExecuted,
// When a registered TX SC Call hash has been executed by chain
// TODO: Smart Contracts
TransactionSCResult,
// When a new asset has been registered
// TODO: Smart Contracts
NewAsset,
// When a new peer has connected to us
// It contains PeerConnectedEvent struct as value
// When a new peer has connected to us,
// it contains PeerConnectedEvent struct as value.
PeerConnected,
// When a peer has disconnected from us
// It contains PeerDisconnectedEvent struct as value
// When a peer has disconnected from us,
// it contains PeerDisconnectedEvent struct as value.
PeerDisconnected,
// Peer peerlist updated, its all its connected peers
// It contains PeerPeerListUpdatedEvent as value
// Peer peerlist updated, its all its connected peers,
// it contains PeerPeerListUpdatedEvent as value.
PeerPeerListUpdated,
// Peer has been updated through a ping packet
// Contains PeerStateUpdatedEvent as value
// Peer has been updated through a ping packet,
// contains PeerStateUpdatedEvent as value.
PeerStateUpdated,
// When a peer of a peer has disconnected
// and that he notified us
// It contains PeerPeerDisconnectedEvent as value
// and he notified us,
// it contains PeerPeerDisconnectedEvent as value.
PeerPeerDisconnected,
}

Expand All @@ -613,18 +613,18 @@ pub type NewBlockEvent = BlockResponse;
// Value of NotifyEvent::BlockOrdered
#[derive(Serialize, Deserialize)]
pub struct BlockOrderedEvent<'a> {
// block hash in which this event was triggered
// Block hash in which this event was triggered
pub block_hash: Cow<'a, Hash>,
pub block_type: BlockType,
// the new topoheight of the block
// The new topoheight of the block
pub topoheight: u64,
}

// Value of NotifyEvent::BlockOrphaned
#[derive(Serialize, Deserialize)]
pub struct BlockOrphanedEvent<'a> {
pub block_hash: Cow<'a, Hash>,
// Tpoheight of the block before being orphaned
// Topoheight of the block before being orphaned
pub old_topoheight: u64
}

Expand Down
14 changes: 7 additions & 7 deletions xelis_common/src/api/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum DataConversionError {
UnexpectedValue(ValueType),
}

// All types availables
// All types available
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Hash, Clone, Copy)]
pub enum ValueType {
Bool,
Expand Down Expand Up @@ -189,9 +189,9 @@ impl DataElement {
}

impl Serializer for DataElement {
// Don't do any pre-allocation because of infinite depth
// Don't do any pre-allocation because of infinite depth.
// Otherwise an attacker could generate big depth with high size until max limit
// which can create OOM on low devices
// which can create OOM on low devices.
fn read(reader: &mut Reader) -> Result<Self, ReaderError> {
Ok(match reader.read_u8()? {
0 => Self::Value(DataValue::read(reader)?),
Expand Down Expand Up @@ -225,7 +225,7 @@ impl Serializer for DataElement {
}
Self::Array(values) => {
writer.write_u8(1);
writer.write_u8(values.len() as u8); // we accept up to 255 values
writer.write_u8(values.len() as u8); // We accept up to 255 values
for value in values {
value.write(writer);
}
Expand Down Expand Up @@ -273,9 +273,9 @@ pub enum DataValue {
U64(u64),
U128(u128),
Hash(Hash),
// This is a specific type for optimized size of binary data
// Because above variants rewrite for each element the byte of the element and of each value
// It supports up to 65535 bytes (u16::MAX)
// This is a specific type for optimized size of binary data.
// Because the above variants rewrite for each element the byte of the element and of each value
// It supports up to 65535 bytes (u16::MAX).
Blob(Vec<u8>),
}

Expand Down
16 changes: 8 additions & 8 deletions xelis_common/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@ impl From<RPCTransactionType<'_>> for TransactionType {

// This is exactly the same as the one in xelis_common/src/transaction/mod.rs
// We use this one for serde (de)serialization
// So we have addresses displayed as strings and not Public Key as bytes
// This is much more easier for developers relying on the API
// So we have addresses displayed as strings and not Public Key as bytes.
// This is much more easier for developers relying on the API.
#[derive(Serialize, Deserialize, Clone)]
pub struct RPCTransaction<'a> {
pub hash: Cow<'a, Hash>,
/// Version of the transaction
pub version: TxVersion,
// Source of the transaction
/// Source of the transaction
pub source: Address,
/// Type of the transaction
pub data: RPCTransactionType<'a>,
/// Fees in XELIS
pub fee: u64,
/// nonce must be equal to the one on chain account
/// used to prevent replay attacks and have ordered transactions
/// Nonce must be equal to the one on chain account
/// Used to prevent replay attacks and have ordered transactions
pub nonce: u64,
/// We have one source commitment and equality proof per asset used in the tx.
pub source_commitments: Cow<'a, Vec<SourceCommitment>>,
Expand Down Expand Up @@ -178,12 +178,12 @@ impl<'a> From<RPCTransaction<'a>> for Transaction {
}

// We create a type above it so for deserialize we can use this type directly
// and not have to specify the lifetime
// and not have to specify the lifetime.
pub type TransactionResponse = RPCTransaction<'static>;

#[derive(Serialize, Deserialize)]
pub struct SplitAddressParams {
// address which must be in integrated form
// Address which must be in integrated form
pub address: Address
}

Expand All @@ -203,7 +203,7 @@ fn default_true_value() -> bool {
true
}

// same here
// Same here
fn default_false_value() -> bool {
false
}
Loading