This branch refactors the PHPCoin codebase to support multiple networks (mainnet and testnet) from a single main branch. The active network is determined by the contents of a ./chain_id file.
- Multi-network support: The codebase was refactored to support multiple networks from a single branch.
chain_idfile: The./chain_idfile is now the source of truth for determining the active network.00for mainnet,01for testnet.- Network-specific configurations: Per-chain files for config, checkpoints, rewards, coinspecs, and genesis have been created.
- Dynamic loading: The code now dynamically loads the correct network-specific files based on the
chain_id. - Refactored network identification: The code has been refactored to use
CHAIN_IDinstead ofNETWORKfor network identification. - Updated scripts: The
install_node.sh,build/docker/miner/start.sh, andbuild/docker/node/docker_start.shscripts have been updated to be driven by thechain_idfile. - Safe defaults: The system now safely defaults to mainnet if the
chain_idfile is missing or invalid.
- Back up the database:
sudo mysqldump phpcoin > phpcoin_backup.sql - Back up the application directory:
sudo cp -a /var/www/phpcoin-mainnet /var/www/phpcoin-mainnet.bak
- Move the installation directory:
sudo mv /var/www/phpcoin-mainnet /var/www/phpcoin
- Update the code:
cd /var/www/phpcoin git pull origin one_branch_to_rule_them_all - Rename the database:
sudo mysql -e "RENAME DATABASE phpcoin TO phpcoin_00;" - Create the
chain_idfile:echo "00" > chain_id
- Handle the configuration file:
After this, you will need to manually copy your old settings from
cd /var/www/phpcoin mv config/config.inc.php config/config.inc.php.bak cp config/config-sample.inc.php config/config.inc.phpconfig.inc.php.bakto the newconfig.inc.php. - Re-run the install script to update configurations:
cd /var/www/phpcoin sudo bash scripts/install_node.sh
- Back up the database:
sudo mysqldump phpcoin > phpcoin_backup.sql - Back up the application directory:
sudo cp -a /var/www/phpcoin-testnet /var/www/phpcoin-testnet.bak
- Move the installation directory:
sudo mv /var/www/phpcoin-testnet /var/www/phpcoin
- Update the code:
cd /var/www/phpcoin git pull origin one_branch_to_rule_them_all - Rename the database:
sudo mysql -e "RENAME DATABASE phpcoin TO phpcoin_01;" - Create the
chain_idfile:echo "01" > chain_id
- Handle the configuration file:
After this, you will need to manually copy your old settings from
cd /var/www/phpcoin mv config/config.inc.php config/config.inc.php.bak cp config/config-sample.inc.php config/config.inc.phpconfig.inc.php.bakto the newconfig.inc.php. - Re-run the install script to update configurations:
cd /var/www/phpcoin sudo bash scripts/install_node.sh
install_node.sh- Run the script with a
chain_idfile containing00and verify that a mainnet node is installed.- Check that the
phpcoin_00database is created. - Check that the nginx configuration is created for port 80.
- Check that the mainnet blockchain is imported.
- Check that the
- Run the script with a
chain_idfile containing01and verify that a testnet node is installed.- Check that the
phpcoin_01database is created. - Check that the nginx configuration is created for port 81.
- Check that the testnet blockchain is imported.
- Check that the
- Run the script without a
chain_idfile and verify that a mainnet node is installed by default.
- Run the script with a
- Node
- Build and run the node container with
CHAIN_ID=00and verify that a mainnet node is started. - Build and run the node container with
CHAIN_ID=01and verify that a testnet node is started.
- Build and run the node container with
- Miner
- Build and run the miner container with a
chain_idfile containing00and verify that it connects to the mainnet mining node. - Build and run the miner container with a
chain_idfile containing01and verify that it connects to the testnet mining node.
- Build and run the miner container with a
- Database Connection
- Verify that the application connects to the
phpcoin_00database whenchain_idis00. - Verify that the application connects to the
phpcoin_01database whenchain_idis01.
- Verify that the application connects to the
- Configuration Loading
- Verify that the correct
config.XX.php,checkpoints.XX.php,rewards.XX.php,coinspec.XX.php, andgenesis.XX.phpfiles are loaded based on thechain_id.
- Verify that the correct
- Network-specific Logic
- Verify that all logic that was previously dependent on the
NETWORKconstant now correctly uses theCHAIN_IDconstant. - Specifically check the following files:
include/class/Blockchain.phpinclude/class/Transaction.phpweb/apps/common/include/top.phpweb/apps/explorer/address.php
- Verify that all logic that was previously dependent on the
The auto-update feature is compatible with the One Branch system. The chain_id of the node will be preserved during the auto-update process. The auto-updater is also branch-aware, meaning it will pull updates for the currently checked-out git branch, making it safe to use on development branches.