Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
68087678
Commit
68087678
authored
7 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#1142
Avoid possible memory leak with HEAD cache
parent
8d51bc3c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/modules/ws2p/lib/WS2PCluster.ts
+12
-6
12 additions, 6 deletions
app/modules/ws2p/lib/WS2PCluster.ts
with
12 additions
and
6 deletions
app/modules/ws2p/lib/WS2PCluster.ts
+
12
−
6
View file @
68087678
...
@@ -116,8 +116,8 @@ export class WS2PCluster {
...
@@ -116,8 +116,8 @@ export class WS2PCluster {
// More recent?
// More recent?
if
(
!
this
.
headsCache
[
fullId
]
||
parseInt
(
this
.
headsCache
[
fullId
].
blockstamp
)
<
parseInt
(
blockstamp
))
{
if
(
!
this
.
headsCache
[
fullId
]
||
parseInt
(
this
.
headsCache
[
fullId
].
blockstamp
)
<
parseInt
(
blockstamp
))
{
// Check that issuer is a member and that the block exists
// Check that issuer is a member and that the block exists
const
memberKey
=
await
this
.
isMemberKey
(
pub
)
const
isAllowed
=
pub
===
this
.
server
.
conf
.
pair
.
pub
||
this
.
isConnectedKey
(
pub
)
||
(
await
this
.
isMemberKey
(
pub
)
)
if
(
memberKey
)
{
if
(
isAllowed
)
{
const
exists
=
await
this
.
existsBlock
(
blockstamp
)
const
exists
=
await
this
.
existsBlock
(
blockstamp
)
if
(
exists
)
{
if
(
exists
)
{
this
.
headsCache
[
fullId
]
=
{
blockstamp
,
message
,
sig
}
this
.
headsCache
[
fullId
]
=
{
blockstamp
,
message
,
sig
}
...
@@ -152,8 +152,8 @@ export class WS2PCluster {
...
@@ -152,8 +152,8 @@ export class WS2PCluster {
// More recent?
// More recent?
if
(
!
this
.
headsCache
[
fullId
]
||
parseInt
(
this
.
headsCache
[
fullId
].
blockstamp
)
<
parseInt
(
blockstamp
))
{
if
(
!
this
.
headsCache
[
fullId
]
||
parseInt
(
this
.
headsCache
[
fullId
].
blockstamp
)
<
parseInt
(
blockstamp
))
{
// Check that issuer is a member and that the block exists
// Check that issuer is a member and that the block exists
const
memberKey
=
await
this
.
isMemberKey
(
pub
)
const
isAllowed
=
pub
===
this
.
server
.
conf
.
pair
.
pub
||
this
.
isConnectedKey
(
pub
)
||
(
await
this
.
isMemberKey
(
pub
)
)
if
(
memberKey
)
{
if
(
isAllowed
)
{
const
exists
=
await
this
.
existsBlock
(
blockstamp
)
const
exists
=
await
this
.
existsBlock
(
blockstamp
)
if
(
exists
)
{
if
(
exists
)
{
this
.
headsCache
[
fullId
]
=
{
blockstamp
,
message
,
sig
}
this
.
headsCache
[
fullId
]
=
{
blockstamp
,
message
,
sig
}
...
@@ -195,11 +195,17 @@ export class WS2PCluster {
...
@@ -195,11 +195,17 @@ export class WS2PCluster {
// Do we have this block in the DB?
// Do we have this block in the DB?
isMember
=
!!
(
await
this
.
server
.
dal
.
isMember
(
pub
))
isMember
=
!!
(
await
this
.
server
.
dal
.
isMember
(
pub
))
}
}
if
(
isMember
)
{
// Update the last time it was checked
// Update the last time it was checked
this
.
memberkeysCache
[
pub
]
=
Date
.
now
()
this
.
memberkeysCache
[
pub
]
=
Date
.
now
()
}
return
isMember
return
isMember
}
}
private
isConnectedKey
(
pub
:
string
)
{
return
this
.
getConnectedPubkeys
().
indexOf
(
pub
)
!==
-
1
}
private
async
existsBlock
(
blockstamp
:
string
)
{
private
async
existsBlock
(
blockstamp
:
string
)
{
let
exists
=
false
let
exists
=
false
if
(
this
.
blockstampsCache
[
blockstamp
])
{
if
(
this
.
blockstampsCache
[
blockstamp
])
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment