Skip to content

Commit aabf5d1

Browse files
committed
Fix race condition in wallet-cache pseudocode and remove hardcoded paths
- Add engineStarted flag to prevent double startEngine() call in CachedWallet pseudocode - Replace hardcoded personal paths with relative paths in scrapebugs.md
1 parent a38ffe8 commit aabf5d1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.cursor/commands/scrapebugs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ Rules ready to add to review subagents:
301301
302302
To add these rules to review subagents, run:
303303
`/scraperev` with manual review, or manually add selected rules to:
304-
- `/Users/paul/git/edge-conventions/.cursor/agents/review-errors.md`
305-
- `/Users/paul/git/edge-conventions/.cursor/agents/review-react.md`
304+
- `.cursor/agents/review-errors.md`
305+
- `.cursor/agents/review-react.md`
306306
- etc.
307307
```
308308

docs/wallet-cache.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ Once a wallet is started (explicitly via `startEngine()`):
192192
class CachedWallet {
193193
private enginePromise: Promise<EdgeCurrencyEngine> | undefined
194194
private started: boolean = false
195+
private engineStarted: boolean = false
195196

196197
private async ensureEngine(): Promise<EdgeCurrencyEngine> {
197198
if (this.enginePromise == null) {
@@ -202,8 +203,9 @@ class CachedWallet {
202203

203204
private async createEngine(): Promise<EdgeCurrencyEngine> {
204205
const engine = await plugin.makeCurrencyEngine(...)
205-
// Only trigger startEngine if wallet is in started state
206-
if (this.started) {
206+
// Only trigger startEngine if wallet is in started state and engine not already started
207+
if (this.started && !this.engineStarted) {
208+
this.engineStarted = true
207209
engine.startEngine().catch(err => log.error(err))
208210
}
209211
return engine
@@ -214,7 +216,10 @@ class CachedWallet {
214216
this.started = true
215217
if (this.enginePromise != null) {
216218
const engine = await this.enginePromise
217-
engine.startEngine().catch(err => log.error(err))
219+
if (!this.engineStarted) {
220+
this.engineStarted = true
221+
engine.startEngine().catch(err => log.error(err))
222+
}
218223
}
219224
}
220225

0 commit comments

Comments
 (0)