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
65fe5616
Commit
65fe5616
authored
5 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[feat] sync: print sync duration at end
parent
1affed5f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/modules/crawler/lib/sync.ts
+4
-2
4 additions, 2 deletions
app/modules/crawler/lib/sync.ts
app/modules/crawler/lib/sync/Watcher.ts
+11
-5
11 additions, 5 deletions
app/modules/crawler/lib/sync/Watcher.ts
with
15 additions
and
7 deletions
app/modules/crawler/lib/sync.ts
+
4
−
2
View file @
65fe5616
...
@@ -140,6 +140,7 @@ export class Synchroniser extends stream.Duplex {
...
@@ -140,6 +140,7 @@ export class Synchroniser extends stream.Duplex {
this
.
logger
.
info
(
"
Sync started.
"
);
this
.
logger
.
info
(
"
Sync started.
"
);
const
fullSync
=
!
to
;
const
fullSync
=
!
to
;
const
syncStartTime
=
Date
.
now
();
//============
//============
// Blockchain headers
// Blockchain headers
...
@@ -240,9 +241,10 @@ export class Synchroniser extends stream.Duplex {
...
@@ -240,9 +241,10 @@ export class Synchroniser extends stream.Duplex {
await
this
.
syncStrategy
.
syncPeers
(
fullSync
,
to
);
await
this
.
syncStrategy
.
syncPeers
(
fullSync
,
to
);
}
}
this
.
watcher
.
end
();
const
syncDuration
=
Date
.
now
()
-
syncStartTime
;
this
.
watcher
.
end
(
syncDuration
);
this
.
push
({
sync
:
true
});
this
.
push
({
sync
:
true
});
this
.
logger
.
info
(
"
Sync finished
.
"
);
this
.
logger
.
info
(
"
Sync finished
(duration %s ms).
"
,
syncDuration
);
}
catch
(
err
)
{
}
catch
(
err
)
{
this
.
push
({
sync
:
false
,
msg
:
err
});
this
.
push
({
sync
:
false
,
msg
:
err
});
err
&&
err
&&
...
...
This diff is collapsed.
Click to expand it.
app/modules/crawler/lib/sync/Watcher.ts
+
11
−
5
View file @
65fe5616
...
@@ -11,7 +11,7 @@ export interface Watcher {
...
@@ -11,7 +11,7 @@ export interface Watcher {
appliedPercent
(
pct
?:
number
):
number
;
appliedPercent
(
pct
?:
number
):
number
;
sbxPercent
(
pct
?:
number
):
number
;
sbxPercent
(
pct
?:
number
):
number
;
peersPercent
(
pct
?:
number
):
number
;
peersPercent
(
pct
?:
number
):
number
;
end
():
void
;
end
(
duration
?:
number
):
void
;
reserveNodes
(
nodesAvailable
:
P2pCandidate
[]):
void
;
reserveNodes
(
nodesAvailable
:
P2pCandidate
[]):
void
;
...
@@ -114,8 +114,8 @@ export class EventWatcher extends events.EventEmitter implements Watcher {
...
@@ -114,8 +114,8 @@ export class EventWatcher extends events.EventEmitter implements Watcher {
return
method
(
pct
);
return
method
(
pct
);
}
}
end
():
void
{
end
(
syncDuration
?:
number
):
void
{
this
.
innerWatcher
.
end
();
this
.
innerWatcher
.
end
(
syncDuration
);
}
}
onEvent
(
e
:
EventName
,
cb
:
(
pct
:
number
)
=>
void
)
{
onEvent
(
e
:
EventName
,
cb
:
(
pct
:
number
)
=>
void
)
{
...
@@ -261,8 +261,14 @@ export class MultimeterWatcher implements Watcher {
...
@@ -261,8 +261,14 @@ export class MultimeterWatcher implements Watcher {
return
0
;
return
0
;
}
}
end
()
{
end
(
duration
?:
number
)
{
if
(
duration
)
{
const
durationSecs
=
Math
.
floor
(
duration
/
1000
);
const
durationMillisRemain
=
duration
%
1000
;
this
.
multi
.
write
(
"
\n
All done in
"
+
durationSecs
+
"
.
"
+
durationMillisRemain
+
"
seconds.
\n
"
);
}
else
{
this
.
multi
.
write
(
"
\n
All done.
\n
"
);
this
.
multi
.
write
(
"
\n
All done.
\n
"
);
}
this
.
multi
.
destroy
();
this
.
multi
.
destroy
();
}
}
...
...
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