account-sys
SystemService::AccountSys
struct SystemService::AccountSys {
const psibase::AccountNumber service; // "account-sys"
const psibase::AccountNumber inviteService; // "invite-sys"
const psibase::AccountNumber nullAccount; // AccountNumber 0 is reserved for the null account
init(...); // Only called once during chain initialization
newAccount(...); // Used to create a new account with a specified auth service
setAuthServ(...); // Used to update the auth service used by an account
exists(...); // Return value indicates whether the account `name` exists
billCpu(...); // Reduces the account balance. Aborts the transaction if the account does not have sufficient resources.
};
This service facilitates the creation of new accounts.
Only the AccountSys service itself and the inviteService may create new accounts.
Other services may also use this service to check if an account exists.
SystemService::AccountSys::init
void SystemService::AccountSys::init();
Only called once during chain initialization.
Creates accounts for other system services.
SystemService::AccountSys::newAccount
void SystemService::AccountSys::newAccount(
psibase::AccountNumber name,
psibase::AccountNumber authService,
bool requireNew
);
Used to create a new account with a specified auth service.
The accounts permitted to call this action are restricted to either AccountSys itself
or the service indicated by inviteService. If the requireNew flag is set, then
the action will fail if the name account already exists.
SystemService::AccountSys::setAuthServ
void SystemService::AccountSys::setAuthServ(
psibase::AccountNumber authService
);
Used to update the auth service used by an account.
SystemService::AccountSys::exists
bool SystemService::AccountSys::exists(
psibase::AccountNumber name
);
Return value indicates whether the account name exists.
SystemService::AccountSys::billCpu
void SystemService::AccountSys::billCpu(
psibase::AccountNumber name,
std::chrono::nanoseconds amount
);
Reduces the account balance. Aborts the transaction if the account does not have sufficient resources..
SystemService::AccountSysStatus
struct SystemService::AccountSysStatus {
uint32_t totalAccounts;
key(...);
};
Shows statistics accross accounts.
totalAccounts holds the total number of accounts on chain
SystemService::AccountSysStatus::key
std::tuple<> SystemService::AccountSysStatus::key() const;
SystemService::Account
struct SystemService::Account {
psibase::AccountNumber accountNum;
psibase::AccountNumber authService;
std::optional<ResourceLimit> resourceBalance;
key(...);
};
Structure of an account.
accountNum is the name of the account
authService is the service used to verify the transaction claims when accountNum is the sender
resourceBalance is the available resources for the account
SystemService::Account::key
psibase::AccountNumber SystemService::Account::key() const;