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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
86b69e01
Commit
86b69e01
authored
7 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Debug why sync fails on G1-Test
parent
291593d2
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/lib/computation/QuickSync.ts
+3
-0
3 additions, 0 deletions
app/lib/computation/QuickSync.ts
app/modules/crawler/lib/sync.ts
+13
-5
13 additions, 5 deletions
app/modules/crawler/lib/sync.ts
with
16 additions
and
5 deletions
app/lib/computation/QuickSync.ts
+
3
−
0
View file @
86b69e01
...
@@ -166,6 +166,9 @@ export class QuickSynchronizer {
...
@@ -166,6 +166,9 @@ export class QuickSynchronizer {
}
}
}))
}))
if
(
sync_cindex
.
length
)
sync_cindex
.
map
(
c
=>
console
.
log
(
c
))
if
(
sync_mindex
.
length
)
sync_mindex
.
map
(
c
=>
console
.
log
(
c
))
if
(
sync_iindex
.
length
)
sync_iindex
.
map
(
c
=>
console
.
log
(
c
))
// Flush the INDEX (not bindex, which is particular)
// Flush the INDEX (not bindex, which is particular)
await
this
.
dal
.
mindexDAL
.
insertBatch
(
sync_mindex
);
await
this
.
dal
.
mindexDAL
.
insertBatch
(
sync_mindex
);
await
this
.
dal
.
iindexDAL
.
insertBatch
(
sync_iindex
);
await
this
.
dal
.
iindexDAL
.
insertBatch
(
sync_iindex
);
...
...
This diff is collapsed.
Click to expand it.
app/modules/crawler/lib/sync.ts
+
13
−
5
View file @
86b69e01
...
@@ -22,6 +22,7 @@ const _ = require('underscore');
...
@@ -22,6 +22,7 @@ const _ = require('underscore');
const
moment
=
require
(
'
moment
'
);
const
moment
=
require
(
'
moment
'
);
const
multimeter
=
require
(
'
multimeter
'
);
const
multimeter
=
require
(
'
multimeter
'
);
const
makeQuerablePromise
=
require
(
'
querablep
'
);
const
makeQuerablePromise
=
require
(
'
querablep
'
);
const
directory
=
require
(
'
../../../lib/system/directory
'
)
const
CONST_BLOCKS_CHUNK
=
250
;
const
CONST_BLOCKS_CHUNK
=
250
;
const
EVAL_REMAINING_INTERVAL
=
1000
;
const
EVAL_REMAINING_INTERVAL
=
1000
;
...
@@ -610,6 +611,7 @@ class P2PDownloader {
...
@@ -610,6 +611,7 @@ class P2PDownloader {
private
downloads
:
any
=
{};
private
downloads
:
any
=
{};
private
startResolver
:
any
private
startResolver
:
any
private
downloadStarter
:
Promise
<
any
>
private
downloadStarter
:
Promise
<
any
>
private
getDAL
:
Promise
<
FileDAL
>
constructor
(
constructor
(
private
currency
:
string
,
private
currency
:
string
,
...
@@ -623,6 +625,11 @@ class P2PDownloader {
...
@@ -623,6 +625,11 @@ class P2PDownloader {
private
dal
:
FileDAL
,
private
dal
:
FileDAL
,
private
slowOption
:
any
)
{
private
slowOption
:
any
)
{
this
.
getDAL
=
(
async
()
=>
{
const
params
=
await
directory
.
getHomeParams
(
false
,
'
/home/cgeek/.config/duniter/duniter_default
'
)
return
new
FileDAL
(
params
)
})()
this
.
TOO_LONG_TIME_DOWNLOAD
=
"
No answer after
"
+
this
.
MAX_DELAY_PER_DOWNLOAD
+
"
ms, will retry download later.
"
;
this
.
TOO_LONG_TIME_DOWNLOAD
=
"
No answer after
"
+
this
.
MAX_DELAY_PER_DOWNLOAD
+
"
ms, will retry download later.
"
;
this
.
nbBlocksToDownload
=
Math
.
max
(
0
,
to
-
localNumber
);
this
.
nbBlocksToDownload
=
Math
.
max
(
0
,
to
-
localNumber
);
this
.
numberOfChunksToDownload
=
Math
.
ceil
(
this
.
nbBlocksToDownload
/
CONST_BLOCKS_CHUNK
);
this
.
numberOfChunksToDownload
=
Math
.
ceil
(
this
.
nbBlocksToDownload
/
CONST_BLOCKS_CHUNK
);
...
@@ -866,6 +873,7 @@ class P2PDownloader {
...
@@ -866,6 +873,7 @@ class P2PDownloader {
*/
*/
private
async
downloadChunk
(
index
:
number
):
Promise
<
BlockDTO
[]
>
{
private
async
downloadChunk
(
index
:
number
):
Promise
<
BlockDTO
[]
>
{
// The algorithm to download a chunk
// The algorithm to download a chunk
const
tmpDAL
=
await
this
.
getDAL
const
from
=
this
.
localNumber
+
1
+
index
*
CONST_BLOCKS_CHUNK
;
const
from
=
this
.
localNumber
+
1
+
index
*
CONST_BLOCKS_CHUNK
;
let
count
=
CONST_BLOCKS_CHUNK
;
let
count
=
CONST_BLOCKS_CHUNK
;
if
(
index
==
this
.
numberOfChunksToDownload
-
1
)
{
if
(
index
==
this
.
numberOfChunksToDownload
-
1
)
{
...
@@ -873,19 +881,19 @@ class P2PDownloader {
...
@@ -873,19 +881,19 @@ class P2PDownloader {
}
}
try
{
try
{
const
fileName
=
this
.
currency
+
"
/chunk_
"
+
index
+
"
-
"
+
CONST_BLOCKS_CHUNK
+
"
.json
"
;
const
fileName
=
this
.
currency
+
"
/chunk_
"
+
index
+
"
-
"
+
CONST_BLOCKS_CHUNK
+
"
.json
"
;
if
(
this
.
localNumber
<=
0
&&
(
await
t
his
.
dal
.
confDAL
.
coreFS
.
exists
(
fileName
)))
{
if
(
this
.
localNumber
<=
0
&&
(
await
t
mpDAL
.
confDAL
.
coreFS
.
exists
(
fileName
)))
{
this
.
handler
[
index
]
=
{
this
.
handler
[
index
]
=
{
host
:
'
filesystem
'
,
host
:
'
filesystem
'
,
port
:
'
blockchain
'
,
port
:
'
blockchain
'
,
resetFunction
:
()
=>
t
his
.
dal
.
confDAL
.
coreFS
.
remove
(
fileName
)
resetFunction
:
()
=>
t
mpDAL
.
confDAL
.
coreFS
.
remove
(
fileName
)
};
};
return
(
await
t
his
.
dal
.
confDAL
.
coreFS
.
readJSON
(
fileName
)).
blocks
;
return
(
await
t
mpDAL
.
confDAL
.
coreFS
.
readJSON
(
fileName
)).
blocks
;
}
else
{
}
else
{
const
chunk
:
any
=
await
this
.
p2pDownload
(
from
,
count
,
index
);
const
chunk
:
any
=
await
this
.
p2pDownload
(
from
,
count
,
index
);
// Store the file to avoid re-downloading
// Store the file to avoid re-downloading
if
(
this
.
localNumber
<=
0
&&
chunk
.
length
===
CONST_BLOCKS_CHUNK
)
{
if
(
this
.
localNumber
<=
0
&&
chunk
.
length
===
CONST_BLOCKS_CHUNK
)
{
await
t
his
.
dal
.
confDAL
.
coreFS
.
makeTree
(
this
.
currency
);
await
t
mpDAL
.
confDAL
.
coreFS
.
makeTree
(
this
.
currency
);
await
t
his
.
dal
.
confDAL
.
coreFS
.
writeJSON
(
fileName
,
{
blocks
:
chunk
});
await
t
mpDAL
.
confDAL
.
coreFS
.
writeJSON
(
fileName
,
{
blocks
:
chunk
});
}
}
return
chunk
;
return
chunk
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Cédric Moreau
@c-geek
mentioned in commit
cf04e781
·
7 years ago
mentioned in commit
cf04e781
mentioned in commit cf04e781b4fb87f6f80339de0a20a2576b01eed4
Toggle commit list
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