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
c9541c41
Commit
c9541c41
authored
7 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#1098
Proof-of-work should be decoupled from BMA pulls
parent
1316c5b5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/modules/prover/lib/constants.ts
+0
-2
0 additions, 2 deletions
app/modules/prover/lib/constants.ts
app/modules/prover/lib/permanentProver.ts
+0
-37
0 additions, 37 deletions
app/modules/prover/lib/permanentProver.ts
app/modules/prover/lib/prover.ts
+0
-7
0 additions, 7 deletions
app/modules/prover/lib/prover.ts
with
0 additions
and
46 deletions
app/modules/prover/lib/constants.ts
+
0
−
2
View file @
c9541c41
export
const
Constants
=
{
PULLING_MAX_DURATION
:
10
*
1000
,
// 10 seconds
CORES_MAXIMUM_USE_IN_PARALLEL
:
8
,
MINIMAL_ZEROS_TO_SHOW_IN_LOGS
:
3
,
...
...
This diff is collapsed.
Click to expand it.
app/modules/prover/lib/permanentProver.ts
+
0
−
37
View file @
c9541c41
import
{
BlockGeneratorWhichProves
}
from
"
./blockGenerator
"
import
{
ConfDTO
}
from
"
../../../lib/dto/ConfDTO
"
import
{
BlockProver
}
from
"
./blockProver
"
import
{
Constants
}
from
"
./constants
"
import
{
DBBlock
}
from
"
../../../lib/db/DBBlock
"
import
{
dos2unix
}
from
"
../../../lib/common-libs/dos2unix
"
import
{
parsers
}
from
"
../../../lib/common-libs/parsers/index
"
...
...
@@ -29,10 +28,6 @@ export class PermanentProver {
private
lastComputedBlock
:
any
=
null
private
resolveContinuePromise
:
any
=
null
private
continuePromise
:
any
=
null
private
pullingResolveCallback
:
any
=
null
private
timeoutPullingCallback
:
any
=
null
private
pullingFinishedPromise
:
Querable
<
any
>|
null
=
null
private
timeoutPulling
:
any
=
null
constructor
(
private
server
:
any
)
{
this
.
logger
=
server
.
logger
;
...
...
@@ -43,9 +38,6 @@ export class PermanentProver {
// Promises triggering the prooving lopp
this
.
resolveContinuePromise
=
null
;
this
.
continuePromise
=
new
Promise
((
resolve
)
=>
this
.
resolveContinuePromise
=
resolve
);
this
.
pullingResolveCallback
=
null
this
.
timeoutPullingCallback
=
null
this
.
pullingFinishedPromise
=
querablep
(
Promise
.
resolve
());
this
.
loops
=
0
;
...
...
@@ -59,30 +51,6 @@ export class PermanentProver {
this
.
resolveContinuePromise
(
true
);
}
// When we detected a pulling, we stop the PoW loop
pullingDetected
()
{
if
(
this
.
pullingFinishedPromise
&&
this
.
pullingFinishedPromise
.
isResolved
())
{
this
.
pullingFinishedPromise
=
querablep
(
Promise
.
race
([
// We wait for end of pulling signal
new
Promise
((
res
)
=>
this
.
pullingResolveCallback
=
res
),
// Security: if the end of pulling signal is not emitted after some, we automatically trigger it
new
Promise
((
res
)
=>
this
.
timeoutPullingCallback
=
()
=>
{
this
.
logger
.
warn
(
'
Pulling not finished after %s ms, continue PoW
'
,
Constants
.
PULLING_MAX_DURATION
);
res
();
})
]));
}
// Delay the triggering of pulling timeout
if
(
this
.
timeoutPulling
)
{
clearTimeout
(
this
.
timeoutPulling
);
}
this
.
timeoutPulling
=
setTimeout
(
this
.
timeoutPullingCallback
,
Constants
.
PULLING_MAX_DURATION
);
}
pullingFinished
()
{
return
this
.
pullingResolveCallback
&&
this
.
pullingResolveCallback
()
}
async
startPermanence
()
{
let
permanenceResolve
=
()
=>
{}
...
...
@@ -120,11 +88,6 @@ export class PermanentProver {
const
trial
=
await
this
.
server
.
getBcContext
().
getIssuerPersonalizedDifficulty
(
selfPubkey
);
this
.
checkTrialIsNotTooHigh
(
trial
,
current
,
selfPubkey
);
const
lastIssuedByUs
=
current
.
issuer
==
selfPubkey
;
if
(
this
.
pullingFinishedPromise
&&
!
this
.
pullingFinishedPromise
.
isFulfilled
())
{
this
.
logger
.
warn
(
'
Waiting for the end of pulling...
'
);
await
this
.
pullingFinishedPromise
;
this
.
logger
.
warn
(
'
Pulling done. Continue proof-of-work loop.
'
);
}
if
(
lastIssuedByUs
&&
!
this
.
promiseOfWaitingBetween2BlocksOfOurs
)
{
this
.
promiseOfWaitingBetween2BlocksOfOurs
=
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
theConf
.
powDelay
));
this
.
logger
.
warn
(
'
Waiting
'
+
theConf
.
powDelay
+
'
ms before starting to compute next block...
'
);
...
...
This diff is collapsed.
Click to expand it.
app/modules/prover/lib/prover.ts
+
0
−
7
View file @
c9541c41
...
...
@@ -21,13 +21,6 @@ export class Prover extends stream.Transform {
this
.
permaProver
.
prover
.
changePoWPrefix
((
obj
.
nodeIndexInPeers
+
1
)
*
10
);
// We multiply by 10 to give room to computers with < 100 cores
}
else
if
(
obj
.
cpu
!==
undefined
)
{
this
.
permaProver
.
prover
.
changeCPU
(
obj
.
cpu
);
// We multiply by 10 to give room to computers with < 100 cores
}
else
if
(
obj
.
pulling
!==
undefined
)
{
if
(
obj
.
pulling
===
'
processing
'
)
{
this
.
permaProver
.
pullingDetected
();
}
else
if
(
obj
.
pulling
===
'
finished
'
)
{
this
.
permaProver
.
pullingFinished
();
}
}
}
done
&&
done
();
...
...
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