Meriadec Pillet
7 years ago
committed by
GitHub
8 changed files with 109 additions and 36 deletions
@ -0,0 +1,20 @@ |
|||||
|
// @flow
|
||||
|
|
||||
|
import { createCommand } from 'helpers/ipc' |
||||
|
import { Observable } from 'rxjs' |
||||
|
import withLibcore from 'helpers/withLibcore' |
||||
|
|
||||
|
const cmd = createCommand('libcoreHardReset', () => |
||||
|
Observable.create(o => { |
||||
|
withLibcore(async (core, njsWalletPool) => { |
||||
|
try { |
||||
|
njsWalletPool.eraseDataSince(new Date(0)) |
||||
|
o.complete() |
||||
|
} catch (e) { |
||||
|
o.error(e) |
||||
|
} |
||||
|
}) |
||||
|
}), |
||||
|
) |
||||
|
|
||||
|
export default cmd |
@ -0,0 +1,14 @@ |
|||||
|
import libcoreHardReset from 'commands/libcoreHardReset' |
||||
|
import { disable as disableDBMiddleware } from 'middlewares/db' |
||||
|
|
||||
|
import db from 'helpers/db' |
||||
|
import { delay } from 'helpers/promise' |
||||
|
|
||||
|
export default async function hardReset() { |
||||
|
// TODO: wait for the libcoreHardReset to be finished
|
||||
|
// actually, libcore doesnt goes back to js thread
|
||||
|
await Promise.race([libcoreHardReset.send().toPromise(), delay(500)]) |
||||
|
disableDBMiddleware() |
||||
|
db.resetAll() |
||||
|
await delay(500) |
||||
|
} |
Loading…
Reference in new issue