Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
timothe
duniter
Commits
f9282124
Commit
f9282124
authored
Apr 28, 2019
by
Cédric Moreau
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/fork-wot-distance' into dev
parents
bf86827f
bd13d60e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
4 deletions
+72
-4
app/cli.ts
app/cli.ts
+1
-0
app/lib/common-libs/programOptions.ts
app/lib/common-libs/programOptions.ts
+1
-0
app/lib/dal/fileDAL.ts
app/lib/dal/fileDAL.ts
+3
-1
app/modules/crawler/lib/sync/v2/GlobalIndexStream.ts
app/modules/crawler/lib/sync/v2/GlobalIndexStream.ts
+2
-2
app/modules/dump.ts
app/modules/dump.ts
+12
-1
test/integration/certification/certification-replay.ts
test/integration/certification/certification-replay.ts
+53
-0
No files found.
app/cli.ts
View file @
f9282124
...
...
@@ -74,6 +74,7 @@ export const ExecuteCommand = () => {
.
option
(
'
--isolate
'
,
'
Avoid the node to send peering or status informations to the network
'
)
.
option
(
'
--forksize <size>
'
,
'
Maximum size of fork window
'
,
parseInt
)
.
option
(
'
--notrim
'
,
'
Disable the INDEX trimming.
'
)
.
option
(
'
--notrimc
'
,
'
Disable the C_INDEX trimming specifically.
'
)
.
option
(
'
--memory
'
,
'
Memory mode
'
)
;
...
...
app/lib/common-libs/programOptions.ts
View file @
f9282124
...
...
@@ -17,6 +17,7 @@ export interface ProgramOptions {
mdb
?:
string
home
?:
string
notrim
?:
boolean
notrimc
?:
boolean
// Specificaly disable for c_index
nosbx
?:
boolean
nopeers
?:
boolean
nop2p
?:
boolean
...
...
app/lib/dal/fileDAL.ts
View file @
f9282124
...
...
@@ -1089,7 +1089,9 @@ export class FileDAL {
await
this
.
bindexDAL
.
trimBlocks
(
maxNumber
)
await
this
.
iindexDAL
.
trimRecords
(
maxNumber
)
await
this
.
mindexDAL
.
trimRecords
(
maxNumber
)
await
this
.
cindexDAL
.
trimExpiredCerts
(
maxNumber
)
if
(
!
cliprogram
.
notrimc
)
{
await
this
.
cindexDAL
.
trimExpiredCerts
(
maxNumber
)
}
}
await
this
.
sindexDAL
.
trimConsumedSource
(
maxNumber
)
await
this
.
dividendDAL
.
trimConsumedUDs
(
maxNumber
)
...
...
app/modules/crawler/lib/sync/v2/GlobalIndexStream.ts
View file @
f9282124
...
...
@@ -275,8 +275,8 @@ export class GlobalIndexStream extends Duplex {
})
}
if
(
data
.
cindex
.
length
)
{
await
this
.
updateWotbLinks
(
data
.
cindex
)
if
(
sync_
cindex
.
length
)
{
await
this
.
updateWotbLinks
(
sync_
cindex
)
}
gData
.
gindex
.
iindex
=
sync_iindex
gData
.
gindex
.
mindex
=
sync_mindex
...
...
app/modules/dump.ts
View file @
f9282124
...
...
@@ -22,6 +22,7 @@ import {dumpWotWizard} from "./dump/wotwizard/wotwizard.dump"
import
{
OtherConstants
}
from
"
../lib/other_constants
"
import
{
Querable
,
querablep
}
from
"
../lib/common-libs/querable
"
import
{
dumpBlocks
,
dumpForks
}
from
"
./dump/blocks/dump.blocks
"
import
{
newResolveTimeoutPromise
}
from
"
../lib/common-libs/timeout-promise
"
const
Table
=
require
(
'
cli-table
'
)
...
...
@@ -88,6 +89,10 @@ module.exports = {
await
dumpTable
(
server
,
name
,
cond
)
break
case
'
wot
'
:
await
dumpWot
(
server
)
break
case
'
history
'
:
await
dumpHistory
(
server
,
name
)
break
...
...
@@ -181,7 +186,7 @@ async function dumpTable(server: Server, name: string, condition?: string) {
break
case
'
c_index
'
:
rows
=
await
server
.
dal
.
cindexDAL
.
findRawWithOrder
(
criterion
,
[[
'
writtenOn
'
,
false
],
[
'
issuer
'
,
false
],
[
'
receiver
'
,
false
]])
dump
(
rows
,
[
'
op
'
,
'
issuer
'
,
'
receiver
'
,
'
created_on
'
,
'
written_on
'
,
'
sig
'
,
'
expires_on
'
,
'
expired_on
'
,
'
chainable_on
'
,
'
from_wid
'
,
'
to_wid
'
])
dump
(
rows
,
[
'
op
'
,
'
issuer
'
,
'
receiver
'
,
'
created_on
'
,
'
written_on
'
,
'
sig
'
,
'
expires_on
'
,
'
expired_on
'
,
'
chainable_on
'
,
'
from_wid
'
,
'
to_wid
'
,
'
replayable_on
'
])
break
case
'
s_index
'
:
const
rowsTX
=
await
server
.
dal
.
sindexDAL
.
findRawWithOrder
(
criterion
,
[[
'
writtenOn
'
,
false
],
[
'
identifier
'
,
false
],
[
'
pos
'
,
false
]])
...
...
@@ -256,6 +261,12 @@ async function dumpHistory(server: Server, pub: string) {
}
}
async
function
dumpWot
(
server
:
Server
)
{
const
data
=
server
.
dal
.
wotb
.
dumpWoT
()
console
.
log
(
data
)
await
newResolveTimeoutPromise
(
1000
,
null
)
}
async
function
getDateFor
(
server
:
Server
,
blockstamp
:
string
)
{
const
b
=
(
await
server
.
dal
.
getAbsoluteBlockByBlockstamp
(
blockstamp
))
as
DBBlock
const
s
=
"
"
+
b
.
number
...
...
test/integration/certification/certification-replay.ts
View file @
f9282124
...
...
@@ -72,6 +72,59 @@ describe('Certification replay', () => writeBasicTestWithConfAnd2Users({
assertEqual
(
reduce
(
reducableFromCat
).
expires_on
,
now
+
4
+
10
)
// The expiration date should have changed! (this is the interest of a replay)
})
test
(
'
should correctly update wotb: current state
'
,
async
(
s1
)
=>
{
assertEqual
(
s1
.
_server
.
dal
.
wotb
.
dumpWoT
(),
`[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [1] [1] -> 1 |
[1] [1] [1] [1] -> 0 |
`
)
})
test
(
'
should correctly update wotb: toc joins (t + 6)
'
,
async
(
s1
,
cat
,
tac
,
toc
)
=>
{
await
s1
.
commit
({
time
:
now
+
6
})
await
s1
.
commit
({
time
:
now
+
6
})
await
toc
.
createIdentity
()
await
cat
.
cert
(
toc
)
await
tac
.
cert
(
toc
)
await
toc
.
join
()
await
s1
.
commit
({
time
:
now
+
6
})
assertEqual
(
s1
.
_server
.
dal
.
wotb
.
dumpWoT
(),
`[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [1] [2] -> 1 |
[1] [1] [1] [2] -> 0 |
[2] [1] [2] [0] -> 0 | 1 |
`
)
})
test
(
'
should correctly update wotb: toc => cat
'
,
async
(
s1
,
cat
,
tac
,
toc
)
=>
{
await
s1
.
commit
({
time
:
now
+
6
})
await
toc
.
cert
(
cat
)
await
s1
.
commit
({
time
:
now
+
12
})
assertEqual
(
s1
.
_server
.
dal
.
wotb
.
dumpWoT
(),
`[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [2] [2] -> 1 | 2 |
[1] [1] [1] [2] -> 0 |
[2] [1] [2] [1] -> 0 | 1 |
`
)
})
test
(
'
should correctly update wotb: cat loses 1 cert
'
,
async
(
s1
)
=>
{
await
s1
.
commit
({
time
:
now
+
12
})
assertEqual
(
s1
.
_server
.
dal
.
wotb
.
dumpWoT
(),
`[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [1] [2] -> 2 |
[1] [1] [1] [1] -> 0 |
[2] [1] [2] [1] -> 0 | 1 |
`
)
})
test
(
'
should correctly update wotb: tac loses 1 cert and gets kicked
'
,
async
(
s1
)
=>
{
await
s1
.
commit
({
time
:
now
+
14
})
// Change `Time`
await
s1
.
commit
({
time
:
now
+
14
})
// Change `MedianTime`
await
s1
.
commit
({
time
:
now
+
14
})
// Kick
assertEqual
(
s1
.
_server
.
dal
.
wotb
.
dumpWoT
(),
`[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [1] [1] -> 2 |
[1] [0] [0] [1] ->
[2] [1] [2] [1] -> 0 | 1 |
`
)
})
after
(()
=>
{
CommonConstants
.
BLOCK_NEW_GENERATED_VERSION
=
10
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment