canopy

Go Reference License

Package Controller

The Controller package serves as the central coordination hub for a Canopy blockchain node. It orchestrates the interactions between various system components and manages the node’s lifecycle from initialization through operation to shutdown.

Overview

The Controller acts as a “bus” between the core modules of the Canopy blockchain:

This package is responsible for ensuring these components work together seamlessly to maintain blockchain consensus, process transactions, and communicate with peers and parent chains.

Core Components

Controller Structure

The Controller contains references to all major subsystems and coordinates their interactions:

graph TD
    Controller --> FSM[State Machine]
    Controller --> Mempool
    Controller --> Consensus
    Controller --> P2P
    Controller --> RootChain[Root Chain Info]

    P2P -- Messages --> Controller
    Consensus -- State Updates --> FSM
    Mempool -- Transactions --> Consensus
    RootChain -- Validator Info --> Consensus
    FSM -- Blockchain State --> Controller

Block Processing System

The block processing system handles how blocks are:

This system ensures all nodes maintain consensus on the blockchain state through BFT consensus.

Consensus Management

The consensus management system:

Transaction System

The transaction system:

Certificate Result System

The Certificate Result system handles the post-consensus outcomes:

Security Features

The Controller implements several security measures:

Usage

The Controller is the primary entry point when initializing a Canopy blockchain node. After configuration and initialization of the core components (FSM, P2P, etc.), the Controller’s Start() method begins node operation, which continues until Stop() is called.

The Controller interacts closely with several other major Canopy components which in turn interact with each other at various levels:

Together, these components form a complete blockchain node capable of participating in the Canopy network.