Skip to content

Commit

Permalink
Clear memory after handling each new block (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
colw authored and faboweb committed Nov 4, 2019
1 parent dee5640 commit 5525508
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/cosmos-node-subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class CosmosNodeSubscription {
publishUserTransactionAdded(this.network.id, address, tx)
})
})

this.cosmosAPI.clearMemory()
}
}

Expand Down
9 changes: 9 additions & 0 deletions lib/helpers/PerBlockCacheDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ class PerBlockCacheDataSource extends RESTDataSource {
cacheKeyFor(request) {
return `${request.url}_${this.blockHeight}`
}

clearMemory() {
// The memoizedResults map used for caching requests is never
// cleared automatically. The RESTDataSource assumes it will be
// created a new for each request.
// We maintain instances for parsing new block events on a network,
// so we have a need to call this manually.
this.memoizedResults.clear()
}
}

module.exports = {
Expand Down

0 comments on commit 5525508

Please sign in to comment.