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
e4988bbd
Commit
e4988bbd
authored
5 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#1396
: ensure that the bug is fixed => now the revert is neutral again
parent
907a2106
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/dal/indexDAL/leveldb/LevelDBCindex.ts
+13
-6
13 additions, 6 deletions
app/lib/dal/indexDAL/leveldb/LevelDBCindex.ts
test/integration/fork-resolution/block-with-comebacker-revert.ts
+3
-4
3 additions, 4 deletions
...tegration/fork-resolution/block-with-comebacker-revert.ts
with
16 additions
and
10 deletions
app/lib/dal/indexDAL/leveldb/LevelDBCindex.ts
+
13
−
6
View file @
e4988bbd
import
{
MonitorExecutionTime
}
from
"
../../../debug/MonitorExecutionTime
"
import
{
MonitorExecutionTime
}
from
"
../../../debug/MonitorExecutionTime
"
import
{
CindexEntry
,
FullCindexEntry
,
Indexer
,
reduceBy
}
from
"
../../../indexer
"
import
{
CindexEntry
,
FullCindexEntry
,
Indexer
,
reduce
,
reduceBy
}
from
"
../../../indexer
"
import
{
LevelUp
}
from
'
levelup
'
import
{
LevelUp
}
from
'
levelup
'
import
{
LevelDBTable
}
from
"
./LevelDBTable
"
import
{
LevelDBTable
}
from
"
./LevelDBTable
"
import
{
Underscore
}
from
"
../../../common-libs/underscore
"
import
{
Underscore
}
from
"
../../../common-libs/underscore
"
...
@@ -147,11 +147,18 @@ export class LevelDBCindex extends LevelDBTable<LevelDBCindexEntry> implements C
...
@@ -147,11 +147,18 @@ export class LevelDBCindex extends LevelDBTable<LevelDBCindexEntry> implements C
}
}
// Remove the "received" arrays
// Remove the "received" arrays
for
(
const
e
of
toRemove
)
{
for
(
const
e
of
toRemove
)
{
const
entry
=
await
this
.
get
(
e
.
receiver
)
const
receiver
=
await
this
.
get
(
e
.
receiver
)
const
issuer
=
await
this
.
get
(
e
.
issuer
)
const
certification
=
reduce
(
issuer
.
issued
.
filter
(
i
=>
i
.
receiver
===
e
.
receiver
))
// We remove ONLY IF no valid link still exist, i.e. we remove if the link **has expired** (we may be here because
// of a certification replay before term that is being reverted ==> in such case, even after the revert, the link
// between issuer and receiver is still valid. So don't remove it.
if
(
certification
.
expired_on
)
{
// Remove the certification
// Remove the certification
entry
.
received
=
entry
.
received
.
filter
(
issuer
=>
issuer
!==
e
.
issuer
)
receiver
.
received
=
receiver
.
received
.
filter
(
issuer
=>
issuer
!==
e
.
issuer
)
// Persist
// Persist
await
this
.
put
(
e
.
receiver
,
entry
)
await
this
.
put
(
e
.
receiver
,
receiver
)
}
}
}
// Remove the expires_on index entries
// Remove the expires_on index entries
const
expires
=
Underscore
.
uniq
(
toRemove
.
filter
(
e
=>
e
.
expires_on
).
map
(
e
=>
e
.
expires_on
))
const
expires
=
Underscore
.
uniq
(
toRemove
.
filter
(
e
=>
e
.
expires_on
).
map
(
e
=>
e
.
expires_on
))
...
...
This diff is collapsed.
Click to expand it.
test/integration/fork-resolution/block-with-comebacker-revert.ts
+
3
−
4
View file @
e4988bbd
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
// GNU Affero General Public License for more details.
// GNU Affero General Public License for more details.
import
{
assertEqual
,
writeBasicTestWithConfAnd2Users
}
from
"
../tools/test-framework
"
import
{
assertEqual
,
writeBasicTestWithConfAnd2Users
}
from
"
../tools/test-framework
"
import
{
assertThrows
}
from
"
../../unit-tools
"
import
{
CommonConstants
}
from
"
../../../app/lib/common-libs/constants
"
import
{
CommonConstants
}
from
"
../../../app/lib/common-libs/constants
"
const
currentVersion
=
CommonConstants
.
BLOCK_GENERATED_VERSION
const
currentVersion
=
CommonConstants
.
BLOCK_GENERATED_VERSION
...
@@ -105,10 +104,10 @@ describe('Block revert with a comebacker in it', () => writeBasicTestWithConfAnd
...
@@ -105,10 +104,10 @@ describe('Block revert with a comebacker in it', () => writeBasicTestWithConfAnd
})
})
test
(
'
(t = 12 #3) resolution should work
'
,
async
(
s1
)
=>
{
test
(
'
(t = 12 #3) resolution should work
'
,
async
(
s1
)
=>
{
await
assertThrows
(
s1
.
resolve
(),
'
BLOCK_WASNT_COMMITTED
'
)
await
s1
.
resolve
(
)
const
b
=
await
s1
.
dal
.
getBlockCurrent
()
const
b
=
await
s1
.
dal
.
getBlockCurrent
()
assertEqual
(
b
.
membersCount
,
2
)
assertEqual
(
b
.
membersCount
,
3
)
assertEqual
(
b
.
number
,
2
1
)
assertEqual
(
b
.
number
,
2
2
)
})
})
after
(()
=>
{
after
(()
=>
{
...
...
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