Skip to content

Commit

Permalink
fix: handle properly old blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdethier committed Oct 20, 2022
1 parent de1749c commit c5db895
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/logion/services/locsynchronization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class LocSynchronizer {
}
case "addFile": {
const locId = this.extractLocId('loc_id', extrinsic.args);
const hash = extrinsic.args['file'].get('hash_').toHex();
const hash = this.getFileHash(extrinsic);
await this.mutateLoc(locId, loc => loc.setFileAddedOn(hash, timestamp));
break;
}
Expand Down Expand Up @@ -88,6 +88,15 @@ export class LocSynchronizer {
return decimalToUuid(args[locIdKey].toString());
}

private getFileHash(extrinsic: any): string {
const file = extrinsic.args['file'];
if("hash_" in file) {
return file.get('hash_').toHex();
} else {
return file.get('hash').toHex();
}
}

private async mutateLoc(locId: string, mutator: (loc: LocRequestAggregateRoot) => void) {
const loc = await this.locRequestRepository.findById(locId);
if(loc !== null) {
Expand Down

0 comments on commit c5db895

Please sign in to comment.