Skip to content

Commit

Permalink
pallet doc refactorred
Browse files Browse the repository at this point in the history
  • Loading branch information
taniasaleem committed Jul 12, 2024
1 parent 245e18d commit f5fc0c1
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 20 deletions.
27 changes: 23 additions & 4 deletions pallets/elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,32 @@
//!
//!
//!
//! The flowchart represents the logical flow and interactions within the pallet, detailing how various functions and operations are interconnected. It begins with different entry points corresponding to various operations: setting shard configuration, setting electable members, handling member online/offline events, handling shard offline events.
//! The flowchart represents the logical flow and interactions within the pallet,
//! detailing how various functions and operations are interconnected. It begins
//! with different entry points corresponding to various operations: setting
//! shard configuration, setting electable members, handling member online/offline
//! events, handling shard offline events.
//!
//! **Set Shard Configuration** Flow starts by ensuring the caller is a root user, validating the shard size and threshold, updating the storage, emitting an event, iterating through unassigned members, and trying to elect a new shard.
//! **Set Shard Configuration** Flow starts by ensuring the caller is a root user,
//! validating the shard size and threshold, updating the storage, emitting an
//! event, iterating through unassigned members, and trying to elect a new shard.
//!
//! **Member Online** Flow checks if the member is part of a shard. If not, it verifies if the member is electable, adds them to the unassigned list, and attempts to elect a new shard. If the member is already part of a shard, it simply notifies the shards interface.
//! **Member Online** Flow checks if the member is part of a shard. If not, it
//! verifies if the member is electable, adds them to the unassigned list, and
//! attempts to elect a new shard. If the member is already part of a shard, it
//! simply notifies the shards interface.
//!
//! **Shard Offline Flow** adds the shard members to the unassigned list and tries to elect a new shard. **Try Elect Shard** Flow evaluates if a new shard can be formed, removes the selected members from the unassigned list, and creates a new shard using the shards interface. **New Shard Members** Flow retrieves the required shard size, gathers unassigned and online members, ensures there are enough members to form a shard, sorts members by stake, selects the top members to form the shard, and returns the selected members.
//! **Shard Offline** Flow adds the shard members to the unassigned list and tries
//! to elect a new shard.
//!
//! **Try Elect Shard** Flow evaluates if a new shard can be formed, removes the
//! selected members from the unassigned list, and creates a new shard using the
//! shards interface.
//!
//! **New Shard Members** Flow retrieves the required shard size, gathers
//! unassigned and online members, ensures there are enough members to form a
//! shard, sorts members by stake, selects the top members to form the shard, and
//! returns the selected members.
//!
#![doc = simple_mermaid::mermaid!("../docs/elections_flow.mmd")]
//!
Expand Down
13 changes: 9 additions & 4 deletions pallets/members/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#![cfg_attr(not(feature = "std"), no_std)]

//! This pallet manages members' registration, heartbeat functionality, and member management within a decentralized network.
//! This pallet manages members' registration, heartbeat functionality, and
//! member management within a decentralized network.
//!
//! This flowchart represents the control flow and interactions of callable functions (`register_member`, `send_heartbeat`, `unregister_member`). It shows the decision points, data operations, and event emissions along with error handling where applicable.
//! This flowchart represents the control flow and interactions of callable
//! functions (`register_member`, `send_heartbeat`, `unregister_member`). It shows
//! the decision points, data operations, and event emissions along with error
//! handling where applicable.
//!
//!
#![doc = simple_mermaid::mermaid!("../docs/member_calls.mmd")]
//!
//! This flowchart illustrates the decision-making and steps taken within the on_initialize function, highlighting the main actions and checks performed during the process.
//!
//! This flowchart illustrates the decision-making and steps taken within the
//! `on_initialize` function, highlighting the main actions and checks performed
//! during the process.
//!
#![doc = simple_mermaid::mermaid!("../docs/member_hooks.mmd")]
//!
Expand Down
18 changes: 13 additions & 5 deletions pallets/networks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#![cfg_attr(not(feature = "std"), no_std)]
//! The network pallet manages the registration and configuration of various
//! blockchain networks within a decentralized system. It provides functionality
//! to add new networks, retrieve network information, and ensures each network
//! is uniquely identified by a `NetworkId`.
//!
//! The network pallet manages the registration and configuration of various blockchain networks within a decentralized system. It provides functionality to add new networks, retrieve network information, and ensures each network is uniquely identified by a `NetworkId`.
//! ## Features
//!
//! ## Features
//! - Allows privileged users to add new blockchain networks with unique
//! `ChainName` and `ChainNetwork` combinations. This operation requires root
//! authorization.
//!
//! - Allows privileged users to add new blockchain networks with unique `ChainName` and `ChainNetwork` combinations. This operation requires root authorization.
//! - Maintains storage of network configurations using a mapping between
//! `NetworkId` and `(ChainName, ChainNetwork)` tuples.
//!
//! - Initializes the pallet with predefined network configurations during
//! blockchain genesis, ensuring seamless operation from the start.
//!
//! - Maintains storage of network configurations using a mapping between `NetworkId` and `(ChainName, ChainNetwork)` tuples.
//!
//! - Initializes the pallet with predefined network configurations during blockchain genesis, ensuring seamless operation from the start.
#![doc = simple_mermaid::mermaid!("../docs/network_flow.mmd")]

#[cfg(feature = "runtime-benchmarks")]
Expand Down
28 changes: 22 additions & 6 deletions pallets/tasks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
#![cfg_attr(not(feature = "std"), no_std)]
//! # Timechain Task Pallet
//!
//! This chart shows all the extrinsics and events of the task pallet. It categorizes the extrinsics into two types: those that can be called by root or council, and those that can be called by any user. The root or council extrinsics are related to administrative tasks, while user extrinsics are related to task operations and submissions.
//!
//! This chart shows all the extrinsics and events of the task pallet. It
//! categorizes the extrinsics into two types: those that can be called by
//! root or council, and those that can be called by any user. The root or
//! council extrinsics are related to administrative tasks, while user
//! extrinsics are related to task operations and submissions.
//!
#![doc = simple_mermaid::mermaid!("../docs/tasks_extrinsics.mmd")]
//!
//! ## **Task Pallet Lifecycle and Operations**
//!
// #![doc = simple_mermaid::mermaid!("../docs/tasks_tb.mmd")]
//!
//! This flowchart outlines the lifecycle of a task in the task pallet. It starts with task creation and checks if the shard is online. If successful, the task is assigned to a shard and progresses through various phases (sign, write, read). Upon completion, rewards are paid out. Tasks can also be reset, and error handling includes retrying or canceling tasks.
//! This flowchart outlines the lifecycle of a task in the task pallet. It
//! starts with task creation and checks if the shard is online. If successful,
//! the task is assigned to a shard and progresses through various phases
//! (sign, write, read). Upon completion, rewards are paid out. Tasks can also
//! be reset, and error handling includes retrying or canceling tasks.
//!
#![doc = simple_mermaid::mermaid!("../docs/tasks_lr.mmd")]
//!
//! ## **Unregister Gateways**
//! This flowchart illustrates the process for unregistering gateways in the task pallet. It ensures that only a root user can perform this action. The process involves clearing a specified number of gateways, all registered shards, and filtering tasks to determine their status and handle them appropriately. Errors during the process are logged and returned.
//! This flowchart illustrates the process for unregistering gateways in the
//! task pallet. It ensures that only a root user can perform this action. The
//! process involves clearing a specified number of gateways, all registered
//! shards, and filtering tasks to determine their status and handle them
//! appropriately. Errors during the process are logged and returned.
//!
#![doc = simple_mermaid::mermaid!("../docs/unregister_gateways.mmd")]
//! ## **Reset Tasks**
//! This flowchart shows the process for resetting tasks in the task pallet. It ensures that only a root user can initiate the reset. The reset process includes iterating over unassigned tasks and tasks associated with specific shards, resetting their phase state, and adding them back to unassigned tasks if necessary. The iteration stops once the maximum number of tasks to be reset is reached.
//!
//! ## **Reset Tasks**
//! This flowchart shows the process for resetting tasks in the task pallet. It
//! ensures that only a root user can initiate the reset. The reset process
//! includes iterating over unassigned tasks and tasks associated with
//! specific shards, resetting their phase state, and adding them back to
//! unassigned tasks if necessary. The iteration stops once the maximum
//! number of tasks to be reset is reached.
#![doc = simple_mermaid::mermaid!("../docs/reset_tasks.mmd")]

#[cfg(feature = "runtime-benchmarks")]
Expand Down
4 changes: 3 additions & 1 deletion pallets/timegraph/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
//! This pallet provides functionality for users to deposit and withdraw funds. It maintains a sequence for deposits and withdrawals to ensure order and prevent replay attacks.
//! This pallet provides functionality for users to deposit and withdraw funds.
//! It maintains a sequence for deposits and withdrawals to ensure order
//! and prevent replay attacks.
//!
//!
#![doc = simple_mermaid::mermaid!("../docs/timegraph_flows.mmd")]
Expand Down

0 comments on commit f5fc0c1

Please sign in to comment.