Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
duniter
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
232
Issues
232
List
Boards
Labels
Milestones
Merge Requests
10
Merge Requests
10
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nodes
typescript
duniter
Commits
93a06c6b
Commit
93a06c6b
authored
Aug 27, 2014
by
Cédric Moreau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated `powPeriod` interpretation in code
parent
faa15343
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
23 deletions
+12
-23
app/lib/wizard.js
app/lib/wizard.js
+7
-15
app/models/configuration.js
app/models/configuration.js
+2
-5
app/service/KeychainService.js
app/service/KeychainService.js
+3
-3
No files found.
app/lib/wizard.js
View file @
93a06c6b
...
...
@@ -291,21 +291,7 @@ var tasks = {
async
.
apply
(
simpleInteger
,
"
Certification validity duration
"
,
"
sigValidity
"
,
conf
),
async
.
apply
(
simpleInteger
,
"
Number of valid certifications required to be a member
"
,
"
sigQty
"
,
conf
),
async
.
apply
(
simpleInteger
,
"
Minimum number of leading zeros for a proof-of-work
"
,
"
powZeroMin
"
,
conf
),
function
(
next
){
choose
(
"
Lowering proof-of-work difficulty using a percentage of WoT size
"
,
!
conf
.
powPeriodC
,
function
ifPercentage
()
{
conf
.
powPeriodC
=
false
;
async
.
waterfall
([
async
.
apply
(
simpleInteger
,
"
Number of blocks to wait for lowering difficulty = % members count, how much
"
,
"
powPeriod
"
,
conf
),
],
next
);
},
function
ifConstant
()
{
conf
.
powPeriodC
=
true
;
async
.
waterfall
([
async
.
apply
(
simpleInteger
,
"
Number of blocks to wait to lower proof-of-work difficulty
"
,
"
powPeriod
"
,
conf
),
],
next
);
});
},
async
.
apply
(
simplePercentOrPositiveInteger
,
"
Number of blocks to wait for lowering difficulty
"
,
"
powPeriod
"
,
conf
),
function
(
next
){
choose
(
"
Participate writing the keychain (when member)
"
,
conf
.
participate
,
function
participate
()
{
...
...
@@ -357,3 +343,9 @@ function simpleFloat (question, property, conf, done) {
return
input
&&
input
.
toString
().
match
(
/^
[
0-9
]
+
(\.[
0-9
]
+
)?
$/
)
?
true
:
false
;
},
done
);
}
function
simplePercentOrPositiveInteger
(
question
,
property
,
conf
,
done
)
{
simpleValue
(
question
,
property
,
conf
[
property
],
conf
,
function
(
input
)
{
return
input
&&
(
input
.
toString
().
match
(
/^
[
1-9
][
0-9
]
*$/
)
||
input
.
toString
().
match
(
/^0
\.[
0-9
]
+$/
))
?
true
:
false
;
},
done
);
}
\ No newline at end of file
app/models/configuration.js
View file @
93a06c6b
...
...
@@ -23,7 +23,6 @@ var ConfigurationSchema = new Schema({
sigQty
:
{
"
type
"
:
Number
,
"
default
"
:
5
},
powZeroMin
:
{
"
type
"
:
Number
,
"
default
"
:
4
},
powPeriod
:
{
"
type
"
:
Number
,
"
default
"
:
1
},
powPeriodC
:
{
"
type
"
:
Boolean
,
"
default
"
:
true
},
// Default using Constant value '1'
participate
:
{
"
type
"
:
Boolean
,
"
default
"
:
true
},
// Participate to writing the keychain
tsInterval
:
{
"
type
"
:
Number
,
"
default
"
:
30
},
});
...
...
@@ -46,10 +45,8 @@ ConfigurationSchema.virtual('createNext').set(function (create) {
ConfigurationSchema
.
pre
(
'
save
'
,
function
(
next
)
{
// Force sync saving
var
sync
=
_
({}).
extend
(
this
.
sync
);
this
.
sync
=
{};
this
.
sync
=
sync
;
if
(
this
.
powPeriod
>=
1
)
this
.
powPeriod
=
parseInt
(
this
.
powPeriod
);
if
(
!
this
.
kmanagement
||
!
this
.
kmanagement
.
match
(
/^
(
ALL|KEYS
)
$/
)){
logger
.
error
(
'
Incorrect --kmanagement value, reset to default `KEYS` value
'
);
...
...
app/service/KeychainService.js
View file @
93a06c6b
...
...
@@ -546,9 +546,9 @@ function KeyService (conn, conf, PublicKeyService, PeeringService) {
if
(
last
)
{
var
leadingZeros
=
last
.
hash
.
match
(
/^0+/
)[
0
];
lastBlockPenality
=
leadingZeros
.
length
-
conf
.
powZeroMin
+
1
;
var
powPeriodIs
Contant
=
conf
.
powPeriodC
;
var
nbPeriodsToWait
=
(
powPeriodIsContant
?
conf
.
powPeriod
:
Math
.
floor
(
conf
.
powPeriod
/
100
*
currentWoTsize
))
;
nbWaitedPeriods
=
Math
.
floor
((
nextBlockNumber
-
last
.
number
)
/
nbPeriodsToWait
);
var
powPeriodIs
Percentage
=
conf
.
powPeriod
<
1
;
var
nbPeriodsToWait
=
powPeriodIsPercentage
?
Math
.
floor
(
conf
.
powPeriod
*
currentWoTsize
)
:
conf
.
powPeriod
;
nbWaitedPeriods
=
Math
.
floor
((
nextBlockNumber
-
1
-
last
.
number
)
/
nbPeriodsToWait
);
// -1 to say "excluded"
}
var
nbZeros
=
Math
.
max
(
conf
.
powZeroMin
,
conf
.
powZeroMin
+
lastBlockPenality
-
nbWaitedPeriods
);
next
(
null
,
nbZeros
);
...
...
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