You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This proposal aims to simplify Pagu by introducing a Bot Identifier. Let’s examine the current challenges:
Problems
Multiple Binaries
Pagu compiles separately for each platform. For instance, we have binaries like pagu_discord, pagu_telegram, etc.
It would be advantageous if Pagu could operate on all platforms using a single, uniform binary.
Multiple Configurations
Each bot requires a separate configuration file, even though most settings are identical. For example, pagu_discord_staging and pagu_discord_mainnet share nearly all the same configurations, differing only in their Discord tokens.
Complicated Command Definitions
Commands are tied to specific bots. For example, the Faucet command is used to distribute test coins to developers on the testnet and should only operate on Discord's testnet. To achieve this, the PlatformID and Target are defined per command. For the Faucet command, the platform is set to Discord, and the target is set to Testnet.
Solutions
The issues above can be addressed by defining a Bot ID. This Bot ID acts as an enumerator with the following values:
typeBotIDintconst (
BotID_CLI_MainnetBotID=1//nolint // underscores used for BotIDBotID_CLI_TestnetBotID=2//nolint // underscores used for BotIDBotID_Discord_MainnetBotID=3//nolint // underscores used for BotIDBotID_Discord_StagingBotID=4//nolint // underscores used for BotIDBotID_Discord_ModeratorBotID=5//nolint // underscores used for BotIDBotID_Discord_TestnetBotID=6//nolint // underscores used for BotIDBotID_Telegram_MainnetBotID=7//nolint // underscores used for BotID
)
Defining the Bot ID enables us to create a global configuration file. An example of such a configuration is:
List of Pactus nodes that Pagu can connect to for retrieving information about the Pactus network.# These nodes must have public gRPC endpoints.nodes:
mainnet:
- "bootstrap1.pactus.org:50051"
- "bootstrap2.pactus.org:50051"
- "bootstrap3.pactus.org:50051"
- "bootstrap4.pactus.org:50051"testnet:
- "testnet1.pactus.org:50051"
- "testnet2.pactus.org:50051"
- "testnet3.pactus.org:50051"
- "testnet4.pactus.org:50051"# Wallet configurationwallet:
mainnet-full:
address: pc1... # Wallet address for transactionspath: ./config/wallet.sample.full # Path to wallet filepassword: # Wallet file passwordmainnet-neutered:
address: pc1... path: ./config/wallet.sample.neuteredtestnet:
address: tpc1...path: ./config/wallet.sample.testnetpassword: # Wallet file password# Phoenix (TestNet) configurationphoenix:
faucet_amount: 5# Amount of coins sent when the faucet is used# Database configurationdatabase:
url: "sqlite:db.sqlite"# Database type and connection string# Discord integration configurationdiscord:
mainnet:
guild_id:
token:
staging:
guild_id:
token:
moderator:
guild_id:
token:
testnet:
guild_id:
token:
# Telegram integration configurationtelegram:
mainnet:
bot_token:
# Logger configurationlogger:
level: "info"# Logging level (debug, info, warn, error, or fatal)filename: "pagu.log"# Log file namemax_size: 10# Maximum log file size (MB)max_backups: 10# Maximum backup log files to retaincompress: true # Compress old log filestargets: [file, console] # Logging targets (file, console, or both)
Given this global configuration and a Bot ID, we can generate the corresponding configuration for each bot. For example, using the moderator Bot ID, we can select the mainnet nodes, the Discord ID of the moderator, and the neutered wallet configuration to build the bot-specific configuration.
Command Definition
Using BotID, we can simplify command definitions by specifying the set of BotIDs that can execute a given command. For example, for the Faucet command, we can simply assign BotID_CLI_Testnet and BotID_Discord_Testnet.
Direct Consequences
This refactor allows us to have a single binary for all platforms. To start Pagu, the following command can be used:
This proposal aims to simplify Pagu by introducing a Bot Identifier. Let’s examine the current challenges:
Problems
Multiple Binaries
Pagu compiles separately for each platform. For instance, we have binaries like
pagu_discord
,pagu_telegram
, etc.It would be advantageous if Pagu could operate on all platforms using a single, uniform binary.
Multiple Configurations
Each bot requires a separate configuration file, even though most settings are identical. For example,
pagu_discord_staging
andpagu_discord_mainnet
share nearly all the same configurations, differing only in their Discord tokens.Complicated Command Definitions
Commands are tied to specific bots. For example, the Faucet command is used to distribute test coins to developers on the testnet and should only operate on Discord's testnet. To achieve this, the
PlatformID
andTarget
are defined per command. For the Faucet command, the platform is set to Discord, and the target is set to Testnet.Solutions
The issues above can be addressed by defining a Bot ID. This Bot ID acts as an enumerator with the following values:
Defining the Bot ID enables us to create a global configuration file. An example of such a configuration is:
Given this global configuration and a Bot ID, we can generate the corresponding configuration for each bot. For example, using the
moderator
Bot ID, we can select the mainnet nodes, the Discord ID of the moderator, and the neutered wallet configuration to build the bot-specific configuration.Command Definition
Using BotID, we can simplify command definitions by specifying the set of BotIDs that can execute a given command. For example, for the Faucet command, we can simply assign
BotID_CLI_Testnet
andBotID_Discord_Testnet
.Direct Consequences
This refactor allows us to have a single binary for all platforms. To start Pagu, the following command can be used:
This streamlined approach simplifies the architecture, reduces redundancy, and enhances maintainability.
The text was updated successfully, but these errors were encountered: