Skip to content

Shared Readme

user_name edited this page Feb 17, 2023 · 2 revisions

Shared Module

Where Do I start?

  1. Look at the high level architecture diagram below
  2. Inspect node.go which is the main entrypoint to the node
  3. Familiarize yourself with modules/module.go and all the other interfaces under module.
  4. Ask a member of the team to walk you through types
  5. Dive deep into the module of your choise

Code Structure

shared                # [to-be-refactored] All of this is bound to change
├── codec             # App wide encoding (currently protobuf)
├── config            # Utilities to load and verify Node configurations
├── crypto            # Shared crypto utilities specific to Pocket
├── modules           # Interfaces to the core Pocket modules
|   ├── base_modules  # Base modules that are meant to be embed into the module structs in order to reduce boilerplate code
|   ├── module.go
|   ├── bus_module.go
|   ├── consensus_module.go
|   ├── p2p_module.go
|   ├── utility_module.go
|   ├── persistence_module.go
|   ├── telemetry_module.go
|   ├── types.go      # Shared interfaces
├── tests             # Cross-module and shared testing_artifacts (to be refactored to make testing more modular)
├── node.go           # The main entrypoint to the Pocket Node
├── bus.go            # Implementation of the Bus module

High Level Architecture

The key things to keep in mind are:

  • Every module has a 2 way pointer with the Bus, through which it can:
    • Call methods defined by the interfaces of other modules
    • Receive asynchronous events from the main events channel
  • The Persistence module is the only module that communicates with the local database
  • The P2P module is the only one that communicates with the outside world
  • RuntimeMgr abstracts the runtime and is injected in the modules (more details here)
flowchart TD
    subgraph Pocket Node
        subgraph Pocket's Application Specific Bus
            B("Bus")
            E("Main Events Channel")
            B <-.-> E
        end
        subgraph Pocket's Core Modules
            RMGR(RuntimeMgr)
            RMGR .-
            P(Persistence) & C(Consensus) & U(Utility) & P2P(P2P)
        end
        P <--> B
        C <--> B
        U <--> B
        P2P <--> B
        P <--> db
        P2P <-.-> N((Pocket Network))
        db[(Pocket Database)]
    end

    click P callback "Tooltip for a callback"
    click P call callback() "Tooltip for a callback"

    classDef module fill:#28f,stroke:#016,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
    class P,C,U,P2P,B module
Loading

Types

Intentionally left blank for now. Reach out to the team if you have questions.

Interfaces

Intentionally left blank for now. Reach out to the team if you have questions.

Clone this wiki locally