Skip to content

Commit

Permalink
fix: block processing stored bad nameId
Browse files Browse the repository at this point in the history
  • Loading branch information
silkroadnomad committed Jan 21, 2025
1 parent 5d475f2 commit af4edd0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion relay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libp2p-relay",
"version": "0.12.36",
"version": "0.12.37",
"private": true,
"scripts": {
"start:no-restart": "node src/relay.js",
Expand Down
5 changes: 4 additions & 1 deletion relay/src/pinner/blockProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ export async function processBlockAtHeight(height, electrumClient) {
.format('YYYY-MM-DD HH:mm:ss'),
n: vout.n,
value: vout.value,
nameId: nameOp,
op: nameOp.op,
nameId: nameId,
name_encoding: nameOp.name_encoding,
nameValue: nameValue,
value_encoding: nameOp.value_encoding,
address: vout.scriptPubKey?.addresses[0],
});
}
Expand Down
15 changes: 8 additions & 7 deletions relay/src/pinner/nameOpsFileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@ class LevelDBInterface {
}

export async function getOrCreateDB(orbitdb) {
if (this.db && this.db.isOpen && this.db.isOpen()) {
return this.db;
if (db && db.isOpen && db.isOpen()) {
return db;
}

if (dbType === 'orbitdb') {
this.db = new OrbitDBInterface(orbitdb);
await this.db.open();
db = new OrbitDBInterface(orbitdb);
await db.open();
} else if (dbType === 'leveldb') {
this.db = new LevelDBInterface();
db = new LevelDBInterface();
}

return this.db;
return db;
}

export async function updateDailyNameOpsFile(
Expand Down Expand Up @@ -162,6 +162,7 @@ export async function getLastNameOps(orbitdb, pageSize, from = 10, filter) {

for (const doc of allDocs) {
// Handle both OrbitDB (already JSON) and LevelDB (needs parsing)
console.log("dbType", dbType)
const nameOp = dbType === 'orbitdb' ? doc.nameOp : JSON.parse(doc).nameOp;

if (!nameOp) {
Expand Down Expand Up @@ -214,7 +215,7 @@ export async function closeDB() {
}

function applyFilter(nameOp, selectedFilter) {
console.log("applyFilter", nameOp, selectedFilter)
console.log("nameOp", nameOp.nameId, nameOp.nameValue)
const hasNameValue =
nameOp?.nameValue &&
nameOp.nameValue !== '' &&
Expand Down

0 comments on commit af4edd0

Please sign in to comment.