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
a9f9f1d5
Commit
a9f9f1d5
authored
7 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[fix] #1068 Branch rebasing might fail with already known fork blocks
parent
9411e51b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/modules/crawler/lib/crawler.ts
+16
-10
16 additions, 10 deletions
app/modules/crawler/lib/crawler.ts
app/service/BlockchainService.ts
+7
-0
7 additions, 0 deletions
app/service/BlockchainService.ts
with
23 additions
and
10 deletions
app/modules/crawler/lib/crawler.ts
+
16
−
10
View file @
a9f9f1d5
...
@@ -403,6 +403,8 @@ export class BlockCrawler {
...
@@ -403,6 +403,8 @@ export class BlockCrawler {
return
block
;
return
block
;
}
}
async
applyMainBranch
(
block
:
BlockDTO
):
Promise
<
boolean
>
{
async
applyMainBranch
(
block
:
BlockDTO
):
Promise
<
boolean
>
{
const
existing
=
await
server
.
dal
.
getAbsoluteBlockByNumberAndHash
(
block
.
number
,
block
.
hash
)
if
(
!
existing
)
{
let
addedBlock
=
await
server
.
writeBlock
(
block
,
false
)
let
addedBlock
=
await
server
.
writeBlock
(
block
,
false
)
if
(
!
this
.
lastDownloaded
)
{
if
(
!
this
.
lastDownloaded
)
{
this
.
lastDownloaded
=
await
dao
.
remoteCurrent
(
node
);
this
.
lastDownloaded
=
await
dao
.
remoteCurrent
(
node
);
...
@@ -415,6 +417,10 @@ export class BlockCrawler {
...
@@ -415,6 +417,10 @@ export class BlockCrawler {
server
.
streamPush
(
addedBlock
);
server
.
streamPush
(
addedBlock
);
}
}
}
}
}
else
{
this
.
crawler
.
logger
&&
this
.
crawler
.
logger
.
info
(
'
Downloaded already known block#%s-%s, try to fork...
'
,
block
.
number
,
block
.
hash
)
await
server
.
BlockchainService
.
tryToFork
()
}
return
true
return
true
}
}
async
removeForks
():
Promise
<
boolean
>
{
async
removeForks
():
Promise
<
boolean
>
{
...
...
This diff is collapsed.
Click to expand it.
app/service/BlockchainService.ts
+
7
−
0
View file @
a9f9f1d5
...
@@ -169,6 +169,13 @@ export class BlockchainService extends FIFOService {
...
@@ -169,6 +169,13 @@ export class BlockchainService extends FIFOService {
}
}
}
}
async
tryToFork
()
{
return
this
.
pushFIFO
(
"
tryToFork
"
,
async
()
=>
{
const
current
=
await
this
.
mainContext
.
current
()
await
this
.
eventuallySwitchOnSideChain
(
current
)
})
}
private
async
eventuallySwitchOnSideChain
(
current
:
DBBlock
)
{
private
async
eventuallySwitchOnSideChain
(
current
:
DBBlock
)
{
const
branches
=
await
this
.
branches
()
const
branches
=
await
this
.
branches
()
const
blocksAdvanceInBlocks
=
this
.
conf
.
switchOnHeadAdvance
const
blocksAdvanceInBlocks
=
this
.
conf
.
switchOnHeadAdvance
...
...
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