Skip to content

Commit

Permalink
Merge PR #123 from 'randomlogin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
rithvikvibhu committed Mar 5, 2024
2 parents 42aa53d + 2b52d29 commit 026b1ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
17 changes: 10 additions & 7 deletions integration/test/hesiod-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('Hesiod', function() {
});

const {answer} = await util.resolver.resolve(qs);
assert.strictEqual(answer.length, 5);
assert.strictEqual(answer.length, 6);

assert.strictEqual(answer[0].name, 'hash.tip.chain.hnsd.');
assert.strictEqual(answer[0].data.txt[0], util.node.chain.tip.hash.toString('hex'));
Expand All @@ -120,14 +120,17 @@ describe('Hesiod', function() {
assert.strictEqual(answer[1].data.txt[0], String(util.node.chain.tip.height));
assert.strictEqual(answer[1].data.txt[0], '6000');

assert.strictEqual(answer[2].name, 'time.tip.chain.hnsd.');
assert.strictEqual(answer[2].data.txt[0], String(util.node.chain.tip.time));
assert.strictEqual(answer[2].name, 'name_root.tip.chain.hnsd.');
assert.strictEqual(answer[2].data.txt[0], util.node.chain.tip.treeRoot.toString('hex'));

assert.strictEqual(answer[3].name, 'time.tip.chain.hnsd.');
assert.strictEqual(answer[3].data.txt[0], String(util.node.chain.tip.time));

assert.strictEqual(answer[3].name, 'synced.chain.hnsd.');
assert.strictEqual(answer[3].data.txt[0], 'true');
assert.strictEqual(answer[4].name, 'synced.chain.hnsd.');
assert.strictEqual(answer[4].data.txt[0], 'true');

assert.strictEqual(answer[4].name, 'progress.chain.hnsd.');
assert.strictEqual(answer[4].data.txt[0], '1.000000');
assert.strictEqual(answer[5].name, 'progress.chain.hnsd.');
assert.strictEqual(answer[5].data.txt[0], '1.000000');
});
});

Expand Down
2 changes: 2 additions & 0 deletions src/chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ hsk_chain_add(hsk_chain_t *chain, const hsk_header_t *h) {
const uint8_t *hash = hsk_header_cache(hdr);

hsk_chain_log(chain, "adding block: %s\n", hsk_hex_encode32(hash));
hsk_chain_log(chain, "tree_root %s timestamp %d \n",
hsk_hex_encode32(hdr->name_root), hdr->time);

int64_t now = hsk_timedata_now(chain->td);

Expand Down
5 changes: 5 additions & 0 deletions src/hesiod.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ hsk_hesiod_resolve(hsk_dns_req_t *req, hsk_ns_t *ns) {
goto fail;
}

if (hsk_dns_is_subdomain(req->name, "name_root.tip.chain.hnsd.")) {
if (!hsk_hesiod_txt_push_hash("name_root.tip.chain.hnsd.", ns->pool->chain.tip->name_root, an))
goto fail;
}

if (hsk_dns_is_subdomain(req->name, "time.tip.chain.hnsd.")) {
if (!hsk_hesiod_txt_push_u64("time.tip.chain.hnsd.",
ns->pool->chain.tip->time,
Expand Down

0 comments on commit 026b1ce

Please sign in to comment.