This file defines the core state management functions for the Canopy blockchain, handling accounts, pools, and the overall token supply. It provides the essential operations needed to maintain the financial state of the blockchain.
The account.go file implements functionality for:
Accounts are the fundamental entities in the blockchain that can hold tokens. Each account has:
The file provides functions to:
An account in Canopy is similar to a bank account in the traditional financial system. It has an address (like an account number) and a balance. When you want to send tokens to someone, your account balance decreases and the recipient’s account balance increases.
Pools are special-purpose accounts without individual owners. They are used to hold tokens for specific blockchain functions. Unlike regular accounts that are controlled by users with private keys, pools are managed by the blockchain protocol itself according to predefined rules.
For example, a pool might hold tokens that are:
Pools are identified by numeric IDs rather than addresses, making it clear that they are not controlled by any individual user.
The Supply Tracker maintains information about the total token supply and its distribution across the blockchain. It tracks:
This component provides a comprehensive view of the blockchain’s financial state, similar to how a central bank might track the money supply in a traditional economy.
The file implements a state machine pattern to manage blockchain state. All state changes follow these principles:
For example, when transferring tokens between accounts:
This ensures that the blockchain’s financial state remains consistent and accurate at all times.
The file implements several economic mechanisms:
When users submit transactions, they pay fees that are:
These fees serve two purposes:
The system tracks tokens that are:
This staking mechanism is crucial for the security of proof-of-stake blockchains like Canopy.
The system can:
This allows for flexible monetary policy similar to how central banks manage fiat currencies.