mirror of
https://github.com/EvernodeXRPL/sashimono.git
synced 2026-04-29 15:38:00 +00:00
Fixing Lease amount update in mismatches (#369)
This commit is contained in:
committed by
GitHub
parent
3199d2d559
commit
324300058a
@@ -128,16 +128,12 @@ class MessageBoard {
|
||||
const diskMb = Math.floor(sashiConfig.system.max_storage_kbytes / 1000);
|
||||
const cpuMicroSec = sashiConfig.system.max_cpu_us;
|
||||
const totalInstanceCount = sashiConfig.system.max_instance_count;
|
||||
// Allows to update the lease price if the figure deviates from the figure in host registration entry AND
|
||||
// * All the leases are acquired OR
|
||||
// * The price of an unsold lease is equal to the value in the configuration.
|
||||
const availableLeases = await this.hostClient.getLeases();
|
||||
const allowLeaseAmountUpdate = ((parseFloat(hostInfo.leaseAmount) !== this.cfg.xrpl.leaseAmount) &&
|
||||
(availableLeases.length === 0 || Number(availableLeases[0].Amount?.value) === this.cfg.xrpl.leaseAmount))
|
||||
if ((parseFloat(hostInfo.leaseAmount) !== this.cfg.xrpl.leaseAmount) && !allowLeaseAmountUpdate) {
|
||||
|
||||
const availableLeaseOffers = await this.hostClient.getLeaseOffers();
|
||||
if (availableLeaseOffers.length > 0 && (Number(availableLeaseOffers[0].Amount?.value) !== this.cfg.xrpl.leaseAmount)) {
|
||||
console.log("Lease amount inconsistency was found with existing leases.");
|
||||
console.log(`Using previous lease amount as ${hostInfo.leaseAmount} EVRs.`);
|
||||
this.cfg.xrpl.leaseAmount = parseFloat(hostInfo.leaseAmount);
|
||||
console.log(`Using previous lease amount as ${Number(availableLeaseOffers[0].Amount?.value)} EVRs.`);
|
||||
this.cfg.xrpl.leaseAmount = parseFloat(availableLeaseOffers[0].Amount?.value);
|
||||
this.persistConfig();
|
||||
}
|
||||
|
||||
@@ -148,7 +144,7 @@ class MessageBoard {
|
||||
hostInfo.cpuMicrosec === cpuMicroSec &&
|
||||
hostInfo.ramMb === ramMb &&
|
||||
hostInfo.diskMb === diskMb &&
|
||||
!allowLeaseAmountUpdate)) {
|
||||
hostInfo.leaseAmount === this.cfg.xrpl.leaseAmount)) {
|
||||
await this.#queueAction(async (submissionRefs) => {
|
||||
submissionRefs.refs ??= [{}];
|
||||
// Check again wether the transaction is validated before retry.
|
||||
|
||||
@@ -573,11 +573,9 @@ class Setup {
|
||||
});
|
||||
|
||||
const hostInfo = await hostClient.getHostInfo();
|
||||
const availableLeases = await hostClient.getLeases();
|
||||
const allowLeaseAmountUpdate = ((parseFloat(hostInfo.leaseAmount) !== cfg.xrpl.leaseAmount) &&
|
||||
(availableLeases.length === 0 || Number(availableLeases[0].Amount?.value) === acc.leaseAmount))
|
||||
if (!allowLeaseAmountUpdate) {
|
||||
acc.leaseAmount = parseFloat(hostInfo.leaseAmount);
|
||||
const availableLeaseOffers = await hostClient.getLeaseOffers();
|
||||
if (availableLeaseOffers.length > 0 && Number(availableLeaseOffers[0].Amount?.value) !== acc.leaseAmount) {
|
||||
acc.leaseAmount = parseFloat(availableLeaseOffers[0].Amount?.value);
|
||||
}
|
||||
|
||||
await hostClient.updateRegInfo(hostInfo.activeInstances, null, null, null, null, null, null, null, null, emailAddress, acc?.leaseAmount, { retryOptions: { maxRetryAttempts: MAX_TX_RETRY_ATTEMPTS, feeUplift: Math.floor(acc.affordableExtraFee / MAX_TX_RETRY_ATTEMPTS) } });
|
||||
|
||||
Reference in New Issue
Block a user