Merge pull request #1565 from jagerman/next-height-is-now

Next height is now
This commit is contained in:
Jason Rhinelander 2022-06-19 12:34:24 -03:00 committed by GitHub
commit 502f88cdc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -207,7 +207,7 @@ namespace cryptonote {
if (cryptonote::is_valid_address(address, m_nettype)) {
cryptonote::address_parse_info addr_info {};
cryptonote::get_account_address_from_str(addr_info, m_nettype, address);
uint64_t next_payout_height = addr_info.address.next_payout_height(block_height - 1, conf.BATCHING_INTERVAL);
uint64_t next_payout_height = addr_info.address.next_payout_height(block_height, conf.BATCHING_INTERVAL);
if (block_height == next_payout_height) {
payments.emplace_back(
std::move(address),

View File

@ -150,10 +150,11 @@ uint64_t account_public_address::modulus(uint64_t interval) const
uint64_t account_public_address::next_payout_height(uint64_t current_height, uint64_t interval) const
{
uint64_t next_payout_height = current_height + (modulus(interval) - current_height % interval);
if (next_payout_height <= current_height)
next_payout_height += interval;
return next_payout_height;
auto pay_offset = modulus(interval);
auto curr_offset = current_height % interval;
if (pay_offset < curr_offset)
pay_offset += interval;
return current_height + pay_offset - curr_offset;
}
}