Skip to content

Commit

Permalink
Merge branch 'v8/develop' into v8/paranet-ual-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zsculac authored Jan 30, 2025
2 parents aaf8496 + b8478dd commit 0c7a2af
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
50 changes: 37 additions & 13 deletions src/modules/triple-store/implementation/ot-triple-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,23 +270,47 @@ class OtTripleStore {
return this.ask(repository, query);
}

async createKnowledgeCollectionNamedGraphs(repository, uals, assetsNQuads, visibility) {
const query = `
PREFIX schema: <${SCHEMA_CONTEXT}>
INSERT DATA {
${uals
.map(
(ual, index) => `
async createKnowledgeCollectionNamedGraphs(
repository,
uals,
assetsNQuads,
visibility,
retries = 5,
retryDelay = 10,
) {
const queries = uals.map(
(ual, index) => `
PREFIX schema: <${SCHEMA_CONTEXT}>
INSERT DATA {
GRAPH <${ual}/${visibility}> {
${assetsNQuads[index].join('\n')}
}
`,
)
.join('\n')}
}
`,
);
for (const [index, query] of queries.entries()) {
let attempts = 0;
let success = false;

while (attempts < retries && !success) {
try {
await this.queryVoid(repository, query);
success = true;
} catch (error) {
attempts += 1;
if (attempts < retries) {
this.logger.warn(
`Insert failed for GRAPH <${uals[index]}/${visibility}>. Attempt ${attempts}/${retries}. Retrying in ${retryDelay}ms.`,
);
await setTimeout(retryDelay);
} else {
throw new Error(
`Failed to insert into GRAPH <${uals[index]}/${visibility}> after ${retries} attempts.`,
);
}
}
}
`;

await this.queryVoid(repository, query);
}
}

async deleteKnowledgeCollectionNamedGraphs(repository, uals) {
Expand Down
12 changes: 6 additions & 6 deletions src/service/sharding-table-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ class ShardingTableService {
}

async dial(peerId) {
const { addresses } = await this.findPeerAddressAndProtocols(peerId);
if (addresses.length) {
try {
try {
const { addresses } = await this.findPeerAddressAndProtocols(peerId);
if (addresses.length) {
if (peerId !== this.networkModuleManager.getPeerId().toB58String()) {
this.logger.trace(`Dialing peer ${peerId}.`);
await this.networkModuleManager.dial(peerId);
}
await this.updatePeerRecordLastSeenAndLastDialed(peerId);
} catch (error) {
this.logger.trace(`Unable to dial peer ${peerId}. Error: ${error.message}`);
} else {
await this.updatePeerRecordLastDialed(peerId);
}
} else {
} catch (error) {
this.logger.trace(`Unable to dial peer ${peerId}. Error: ${error.message}`);
await this.updatePeerRecordLastDialed(peerId);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/triple-store-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TripleStoreService {
knowledgeCollectionUAL,
triples,
retries = 5,
retryDelay = 0,
retryDelay = 50,
) {
this.logger.info(
`Inserting Knowledge Collection with the UAL: ${knowledgeCollectionUAL} ` +
Expand Down

0 comments on commit 0c7a2af

Please sign in to comment.