Skip to content

Commit

Permalink
namestate: fix expire block for closed names.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Sep 26, 2023
1 parent 871e401 commit 7da5443
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/covenants/namestate.js
Expand Up @@ -724,7 +724,8 @@ class NameState extends bio.Struct {
assert((height >>> 0) === height);
assert(network && network.names);

const spacing = network.pow.targetSpacing;
const {blocksPerDay} = network.pow;
const blocksPerHour = blocksPerDay / 24;

const {
treeInterval,
Expand Down Expand Up @@ -759,7 +760,7 @@ class NameState extends bio.Struct {
const start = this.height;
const end = this.height + openPeriod;
const blocks = end - height;
const hours = ((blocks * spacing) / 60 / 60);
const hours = blocks / blocksPerHour;

stats.openPeriodStart = start;
stats.openPeriodEnd = end;
Expand All @@ -772,7 +773,7 @@ class NameState extends bio.Struct {
const start = this.height;
const end = this.height + lockupPeriod;
const blocks = end - height;
const hours = ((blocks * spacing) / 60 / 60);
const hours = blocks / blocksPerHour;

stats.lockupPeriodStart = start;
stats.lockupPeriodEnd = end;
Expand All @@ -785,7 +786,7 @@ class NameState extends bio.Struct {
const start = this.height + openPeriod;
const end = start + biddingPeriod;
const blocks = end - height;
const hours = ((blocks * spacing) / 60 / 60);
const hours = blocks / blocksPerHour;

stats.bidPeriodStart = start;
stats.bidPeriodEnd = end;
Expand All @@ -798,7 +799,7 @@ class NameState extends bio.Struct {
const start = this.height + openPeriod + biddingPeriod;
const end = start + revealPeriod;
const blocks = end - height;
const hours = ((blocks * spacing) / 60 / 60);
const hours = blocks / blocksPerHour;

stats.revealPeriodStart = start;
stats.revealPeriodEnd = end;
Expand All @@ -809,11 +810,10 @@ class NameState extends bio.Struct {
}
case states.CLOSED: {
const start = this.renewal;
const end = this.claimed ?
claimPeriod :
start + renewalWindow;
const normalEnd = start + renewalWindow;
const end = this.claimed ? Math.max(claimPeriod, normalEnd) : normalEnd;
const blocks = end - height;
const days = ((blocks * spacing) / 60 / 60 / 24);
const days = blocks / blocksPerDay;

stats.renewalPeriodStart = start;
stats.renewalPeriodEnd = end;
Expand All @@ -827,7 +827,7 @@ class NameState extends bio.Struct {
const start = this.transfer;
const end = start + transferLockup;
const blocks = end - height;
const hours = ((blocks * spacing) / 60 / 60);
const hours = blocks / blocksPerHour;

stats.transferLockupStart = start;
stats.transferLockupEnd = end;
Expand All @@ -841,7 +841,7 @@ class NameState extends bio.Struct {
const start = this.revoked;
const end = start + auctionMaturity;
const blocks = end - height;
const hours = ((blocks * spacing) / 60 / 60);
const hours = blocks / blocksPerHour;

stats.revokePeriodStart = start;
stats.revokePeriodEnd = end;
Expand Down
1 change: 1 addition & 0 deletions test/namestate-test.js
Expand Up @@ -175,6 +175,7 @@ describe('Namestate', function() {
'hoursUntilValidFinalize'
]
);

heightWithTransfer++;
}

Expand Down

0 comments on commit 7da5443

Please sign in to comment.