Skip to content

Commit

Permalink
fix(core-database): set last height before initializing last bl… (#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
spkjp authored and faustbrian committed Oct 23, 2019
1 parent cbd4abc commit 3f80f38
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/core-database/src/database-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,16 @@ export class DatabaseService implements Database.IDatabaseService {
let lastBlock: Interfaces.IBlock;
let tries = 5;

// Ensure the config manager is initialized, before attempting to call `fromData`
// which otherwise uses potentially wrong milestones.
let lastHeight: number = 1;
const latest: Interfaces.IBlockData = await this.connection.blocksRepository.latest();
if (latest) {
lastHeight = latest.height;
}

Managers.configManager.setHeight(lastHeight);

const getLastBlock = async (): Promise<Interfaces.IBlock> => {
try {
return await this.getLastBlock();
Expand Down

0 comments on commit 3f80f38

Please sign in to comment.