Skip to content

Commit

Permalink
Merge PR #817 from 'nodech/chain-cleanup-namestatus'
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed May 29, 2023
2 parents 61c1e05 + 0c834ac commit 433d5e9
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 28 deletions.
7 changes: 2 additions & 5 deletions lib/blockchain/chaindb.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,16 +1316,13 @@ class ChainDB {
/**
* Get name status.
* @param {Buffer} nameHash
* @param {Number} height - used for expiration checks.
* @returns {Promise<NameState>}
*/

async getNameStatus(nameHash, height, hardened) {
if (hardened == null)
hardened = false;

async getNameStatus(nameHash, height) {
assert(Buffer.isBuffer(nameHash));
assert((height >>> 0) === height);
assert(typeof hardened === 'boolean');

const network = this.network;
const ns = await this.getNameState(nameHash);
Expand Down
3 changes: 1 addition & 2 deletions lib/node/fullnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,7 @@ class FullNode extends Node {

async getNameStatus(nameHash) {
const height = this.chain.height + 1;
const hardened = await this.mempool.hasHardening();
return this.chain.db.getNameStatus(nameHash, height, hardened);
return this.chain.db.getNameStatus(nameHash, height);
}
}

Expand Down
4 changes: 1 addition & 3 deletions test/auction-reorg-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ function createNode() {
wallet.getNameStatus = async (nameHash) => {
assert(Buffer.isBuffer(nameHash));
const height = chain.height + 1;
const state = await chain.getNextState();
const hardened = state.hasHardening();
return chain.db.getNameStatus(nameHash, height, hardened);
return chain.db.getNameStatus(nameHash, height);
};

return wallet;
Expand Down
4 changes: 1 addition & 3 deletions test/auction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ function createNode() {
wallet.getNameStatus = async (nameHash) => {
assert(Buffer.isBuffer(nameHash));
const height = chain.height + 1;
const state = await chain.getNextState();
const hardened = state.hasHardening();
return chain.db.getNameStatus(nameHash, height, hardened);
return chain.db.getNameStatus(nameHash, height);
};

return wallet;
Expand Down
4 changes: 1 addition & 3 deletions test/chain-full-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,7 @@ describe('Chain', function() {
wallet.getNameStatus = async (nameHash) => {
assert(Buffer.isBuffer(nameHash));
const height = chain.height + 1;
const state = await chain.getNextState();
const hardened = state.hasHardening();
return chain.db.getNameStatus(nameHash, height, hardened);
return chain.db.getNameStatus(nameHash, height);
};
});

Expand Down
4 changes: 1 addition & 3 deletions test/mempool-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,7 @@ describe('Mempool', function() {
chaincoins.getNameStatus = async (nameHash) => {
assert(Buffer.isBuffer(nameHash));
const height = chain.height + 1;
const state = await chain.getNextState();
const hardened = state.hasHardening();
return chain.db.getNameStatus(nameHash, height, hardened);
return chain.db.getNameStatus(nameHash, height);
};

it('should create coins in chain', async () => {
Expand Down
4 changes: 1 addition & 3 deletions test/txstart-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ node.chain.on('connect', (entry, block) => {
wallet.getNameStatus = async (nameHash) => {
assert(Buffer.isBuffer(nameHash));
const height = node.chain.height + 1;
const state = await node.chain.getNextState();
const hardened = state.hasHardening();
return node.chain.db.getNameStatus(nameHash, height, hardened);
return node.chain.db.getNameStatus(nameHash, height);
};

describe('Disable TXs', function() {
Expand Down
8 changes: 2 additions & 6 deletions test/wallet-rescan-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ describe('Wallet rescan with namestate transitions', function() {
alice.getNameStatus = async (nameHash) => {
assert(Buffer.isBuffer(nameHash));
const height = node.chain.height + 1;
const state = await node.chain.getNextState();
const hardened = state.hasHardening();
return node.chain.db.getNameStatus(nameHash, height, hardened);
return node.chain.db.getNameStatus(nameHash, height);
};

const NAME = rules.grindName(GNAME_SIZE, 4, network);
Expand Down Expand Up @@ -300,9 +298,7 @@ describe('Wallet rescan with namestate transitions', function() {
alice.getNameStatus = async (nameHash) => {
assert(Buffer.isBuffer(nameHash));
const height = node.chain.height + 1;
const state = await node.chain.getNextState();
const hardened = state.hasHardening();
return node.chain.db.getNameStatus(nameHash, height, hardened);
return node.chain.db.getNameStatus(nameHash, height);
};

const NAME = rules.grindName(GNAME_SIZE, 4, network);
Expand Down

0 comments on commit 433d5e9

Please sign in to comment.