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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
9cf59871
Commit
9cf59871
authored
10 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Add currency parameters configuration
parent
c20eaf46
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/lib/wizard.js
+41
-1
41 additions, 1 deletion
app/lib/wizard.js
app/models/configuration.js
+8
-0
8 additions, 0 deletions
app/models/configuration.js
app/service/KeychainService.js
+9
-14
9 additions, 14 deletions
app/service/KeychainService.js
bin/ucoind
+41
-17
41 additions, 17 deletions
bin/ucoind
with
99 additions
and
32 deletions
app/lib/wizard.js
+
41
−
1
View file @
9cf59871
...
@@ -16,7 +16,7 @@ var IPV6_REGEXP = /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}
...
@@ -16,7 +16,7 @@ var IPV6_REGEXP = /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}
function
Wizard
()
{
function
Wizard
()
{
this
.
configAll
=
function
(
conf
,
done
)
{
this
.
configAll
=
function
(
conf
,
done
)
{
doTasks
([
'
currency
'
,
'
openpgp
'
,
'
network
'
,
'
key
'
],
conf
,
done
);
doTasks
([
'
currency
'
,
'
openpgp
'
,
'
network
'
,
'
key
'
,
'
ucp
'
],
conf
,
done
);
};
};
this
.
configCurrency
=
function
(
conf
,
done
)
{
this
.
configCurrency
=
function
(
conf
,
done
)
{
...
@@ -34,6 +34,10 @@ function Wizard () {
...
@@ -34,6 +34,10 @@ function Wizard () {
this
.
configKey
=
function
(
conf
,
done
)
{
this
.
configKey
=
function
(
conf
,
done
)
{
doTasks
([
'
key
'
],
conf
,
done
);
doTasks
([
'
key
'
],
conf
,
done
);
};
};
this
.
configUCP
=
function
(
conf
,
done
)
{
doTasks
([
'
ucp
'
],
conf
,
done
);
};
}
}
function
doTasks
(
todos
,
conf
,
done
)
{
function
doTasks
(
todos
,
conf
,
done
)
{
...
@@ -279,6 +283,42 @@ var tasks = {
...
@@ -279,6 +283,42 @@ var tasks = {
}
}
}
}
],
done
);
],
done
);
},
ucp
:
function
(
conf
,
done
)
{
async
.
waterfall
([
async
.
apply
(
simpleInteger
,
"
Delay between 2 identical certifications
"
,
"
sigDelay
"
,
conf
),
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
);
});
},
function
(
next
){
choose
(
"
Participate writing the keychain (when member)
"
,
conf
.
participate
,
function
participate
()
{
conf
.
participate
=
true
;
next
();
},
function
doNotParticipate
()
{
conf
.
participate
=
false
;
next
();
});
},
async
.
apply
(
simpleInteger
,
"
Acceptable time offset when receiving a new keyblock
"
,
"
tsInterval
"
,
conf
),
],
done
);
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
app/models/configuration.js
+
8
−
0
View file @
9cf59871
...
@@ -18,6 +18,14 @@ var ConfigurationSchema = new Schema({
...
@@ -18,6 +18,14 @@ var ConfigurationSchema = new Schema({
kmanagement
:
{
"
type
"
:
String
,
"
default
"
:
"
ALL
"
},
kmanagement
:
{
"
type
"
:
String
,
"
default
"
:
"
ALL
"
},
kaccept
:
{
"
type
"
:
String
,
"
default
"
:
"
ALL
"
},
kaccept
:
{
"
type
"
:
String
,
"
default
"
:
"
ALL
"
},
upInterval
:
{
"
type
"
:
Number
,
"
default
"
:
3600
*
1000
},
upInterval
:
{
"
type
"
:
Number
,
"
default
"
:
3600
*
1000
},
sigDelay
:
{
"
type
"
:
Number
,
"
default
"
:
3600
*
24
*
365
*
5
},
// 5 years by default
sigValidity
:
{
"
type
"
:
Number
,
"
default
"
:
3600
*
24
*
365
},
// 1 year by default
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
},
});
});
ConfigurationSchema
.
virtual
(
'
createNext
'
).
get
(
function
()
{
ConfigurationSchema
.
virtual
(
'
createNext
'
).
get
(
function
()
{
...
...
This diff is collapsed.
Click to expand it.
app/service/KeychainService.js
+
9
−
14
View file @
9cf59871
...
@@ -27,13 +27,6 @@ function KeyService (conn, conf, PublicKeyService) {
...
@@ -27,13 +27,6 @@ function KeyService (conn, conf, PublicKeyService) {
var
Link
=
conn
.
model
(
'
Link
'
);
var
Link
=
conn
.
model
(
'
Link
'
);
var
Key
=
conn
.
model
(
'
Key
'
);
var
Key
=
conn
.
model
(
'
Key
'
);
var
MINIMUM_ZERO_START
=
1
;
var
PROOF_OF_WORK_PERIOD
=
1
;
// Value 1 allows for continuous single-member writing with minimum difficulty
var
LINK_QUANTITY_MIN
=
1
;
var
MAX_STEPS
=
1
;
var
MAX_LINK_VALIDITY
=
3600
*
24
*
30
;
// 30 days
var
MAX_TIMESTAMP_DELAY
=
30
;
// in seconds
this
.
load
=
function
(
done
)
{
this
.
load
=
function
(
done
)
{
done
();
done
();
};
};
...
@@ -137,7 +130,7 @@ function KeyService (conn, conf, PublicKeyService) {
...
@@ -137,7 +130,7 @@ function KeyService (conn, conf, PublicKeyService) {
return
;
return
;
}
}
// Test timestamp
// Test timestamp
if
(
Math
.
abs
(
block
.
timestamp
-
now
.
utcZero
().
timestamp
())
>
MAX_TIMESTAMP_DELAY
)
{
if
(
Math
.
abs
(
block
.
timestamp
-
now
.
utcZero
().
timestamp
())
>
conf
.
tsInterval
)
{
next
(
'
Timestamp does not match this node
\'
s time
'
);
next
(
'
Timestamp does not match this node
\'
s time
'
);
return
;
return
;
}
}
...
@@ -477,13 +470,13 @@ function KeyService (conn, conf, PublicKeyService) {
...
@@ -477,13 +470,13 @@ function KeyService (conn, conf, PublicKeyService) {
var
count
=
links
.
length
;
var
count
=
links
.
length
;
if
(
newLinks
[
target
]
&&
newLinks
[
target
].
length
)
if
(
newLinks
[
target
]
&&
newLinks
[
target
].
length
)
count
+=
newLinks
[
target
].
length
;
count
+=
newLinks
[
target
].
length
;
next
(
count
<
LINK_QUANTITY_MIN
&&
'
Key
'
+
target
.
substring
(
24
)
+
'
does not have enough links (
'
+
count
+
'
/
'
+
LINK_QUANTITY_MIN
+
'
)
'
);
next
(
count
<
conf
.
sigQty
&&
'
Key
'
+
target
.
substring
(
24
)
+
'
does not have enough links (
'
+
count
+
'
/
'
+
conf
.
sigQty
+
'
)
'
);
},
},
],
done
);
],
done
);
}
}
function
checkProofOfWork
(
block
,
done
)
{
function
checkProofOfWork
(
block
,
done
)
{
var
powRegexp
=
new
RegExp
(
'
^0{
'
+
MINIMUM_ZERO_START
+
'
}
'
);
var
powRegexp
=
new
RegExp
(
'
^0{
'
+
conf
.
powZeroMin
+
'
}
'
);
if
(
!
block
.
hash
.
match
(
powRegexp
))
if
(
!
block
.
hash
.
match
(
powRegexp
))
done
(
'
Not a proof-of-work
'
);
done
(
'
Not a proof-of-work
'
);
else
{
else
{
...
@@ -497,15 +490,17 @@ function KeyService (conn, conf, PublicKeyService) {
...
@@ -497,15 +490,17 @@ function KeyService (conn, conf, PublicKeyService) {
function
(
last
,
next
){
function
(
last
,
next
){
if
(
last
)
{
if
(
last
)
{
var
leadingZeros
=
last
.
hash
.
match
(
/^0+/
)[
0
];
var
leadingZeros
=
last
.
hash
.
match
(
/^0+/
)[
0
];
lastBlockPenality
=
leadingZeros
.
length
-
MINIMUM_ZERO_START
+
1
;
lastBlockPenality
=
leadingZeros
.
length
-
conf
.
powZeroMin
+
1
;
nbWaitedPeriods
=
Math
.
floor
((
block
.
number
-
last
.
number
)
/
PROOF_OF_WORK_PERIOD
);
var
powPeriodIsContant
=
conf
.
powPeriodC
;
var
nbPeriodsToWait
=
(
powPeriodIsContant
?
conf
.
powPeriod
:
Math
.
floor
(
conf
.
powPeriod
/
100
*
block
.
membersCount
));
nbWaitedPeriods
=
Math
.
floor
((
block
.
number
-
last
.
number
)
/
nbPeriodsToWait
);
next
();
next
();
}
else
{
}
else
{
next
();
next
();
}
}
},
},
function
(
next
){
function
(
next
){
var
nbZeros
=
Math
.
max
(
MINIMUM_ZERO_START
,
MINIMUM_ZERO_START
+
lastBlockPenality
-
nbWaitedPeriods
);
var
nbZeros
=
Math
.
max
(
conf
.
powZeroMin
,
conf
.
powZeroMin
+
lastBlockPenality
-
nbWaitedPeriods
);
var
powRegexp
=
new
RegExp
(
'
^0{
'
+
nbZeros
+
'
,}
'
);
var
powRegexp
=
new
RegExp
(
'
^0{
'
+
nbZeros
+
'
,}
'
);
if
(
!
block
.
hash
.
match
(
powRegexp
))
if
(
!
block
.
hash
.
match
(
powRegexp
))
next
(
'
Wrong proof-of-work level: given
'
+
block
.
hash
.
match
(
/^0+/
)[
0
].
length
+
'
zeros, required was
'
+
nbZeros
+
'
zeros
'
);
next
(
'
Wrong proof-of-work level: given
'
+
block
.
hash
.
match
(
/^0+/
)[
0
].
length
+
'
zeros, required was
'
+
nbZeros
+
'
zeros
'
);
...
@@ -721,7 +716,7 @@ function KeyService (conn, conf, PublicKeyService) {
...
@@ -721,7 +716,7 @@ function KeyService (conn, conf, PublicKeyService) {
function
computeObsoleteLinks
(
block
,
done
)
{
function
computeObsoleteLinks
(
block
,
done
)
{
async
.
waterfall
([
async
.
waterfall
([
function
(
next
){
function
(
next
){
Link
.
obsoletes
(
block
.
timestamp
-
MAX_LINK_VALIDITY
,
next
);
Link
.
obsoletes
(
block
.
timestamp
-
conf
.
sigValidity
,
next
);
},
},
function
(
next
){
function
(
next
){
Key
.
getMembers
(
next
);
Key
.
getMembers
(
next
);
...
...
This diff is collapsed.
Click to expand it.
bin/ucoind
+
41
−
17
View file @
9cf59871
...
@@ -42,6 +42,13 @@ program
...
@@ -42,6 +42,13 @@ program
.
option
(
'
--remotep <port>
'
,
'
Remote port others may use to contact this node
'
)
.
option
(
'
--remotep <port>
'
,
'
Remote port others may use to contact this node
'
)
.
option
(
'
--kmanagement <ALL|KEYS>
'
,
'
Define key management policy
'
)
.
option
(
'
--kmanagement <ALL|KEYS>
'
,
'
Define key management policy
'
)
.
option
(
'
--kaccept <ALL|KEYS>
'
,
'
Define key acceptance policy
'
)
.
option
(
'
--kaccept <ALL|KEYS>
'
,
'
Define key acceptance policy
'
)
.
option
(
'
--sigDelay <timestamp>
'
,
'
Minimum delay between 2 certifications of a same issuer for a same recipient, in seconds.
'
)
.
option
(
'
--sigValidity <timestamp>
'
,
'
Validity duration of a certification, in seconds.
'
)
.
option
(
'
--sigQty <number>
'
,
'
Minimum number of required certifications to be a member/stay as a member
'
)
.
option
(
'
--powZeroMin <number>
'
,
'
Minimum number of leading zeros for a proof-of-work
'
)
.
option
(
'
--powPeriod <number>
'
,
'
Number of blocks to wait to decrease proof-of-work difficulty by one
'
)
.
option
(
'
--particpate <Y|N>
'
,
'
Participate to writing the keychain
'
)
.
option
(
'
--tsInterval <number>
'
,
'
Number of seconds as acceptable offset when receiving a keyblock
'
)
.
option
(
'
--openpgpjs
'
,
'
Prefer using embedded Openpgpjs implementation for signing requests
'
)
.
option
(
'
--openpgpjs
'
,
'
Prefer using embedded Openpgpjs implementation for signing requests
'
)
;
;
...
@@ -103,7 +110,8 @@ program
...
@@ -103,7 +110,8 @@ program
'
currency
'
:
wiz
.
configCurrency
,
'
currency
'
:
wiz
.
configCurrency
,
'
openpgp
'
:
wiz
.
configOpenpgp
,
'
openpgp
'
:
wiz
.
configOpenpgp
,
'
network
'
:
wiz
.
configNetwork
,
'
network
'
:
wiz
.
configNetwork
,
'
key
'
:
wiz
.
configKey
'
key
'
:
wiz
.
configKey
,
'
ucp
'
:
wiz
.
configUCP
};
};
var
wizDo
=
task
[
step
]
||
wiz
.
configAll
;
var
wizDo
=
task
[
step
]
||
wiz
.
configAll
;
async
.
waterfall
([
async
.
waterfall
([
...
@@ -444,6 +452,15 @@ function overrideConf(conf) {
...
@@ -444,6 +452,15 @@ function overrideConf(conf) {
policy
:
{
policy
:
{
keys
:
program
.
kmanagement
,
keys
:
program
.
kmanagement
,
pubkeys
:
program
.
kaccept
pubkeys
:
program
.
kaccept
},
ucp
:
{
sigDelay
:
program
.
sigDelay
,
sigValidity
:
program
.
sigValidity
,
sigQty
:
program
.
sigQty
,
powZeroMin
:
program
.
powZeroMin
,
powPeriod
:
program
.
powPeriod
,
particpate
:
program
.
particpate
,
tsInterval
:
program
.
tsInterval
}
}
};
};
...
@@ -463,6 +480,13 @@ function overrideConf(conf) {
...
@@ -463,6 +480,13 @@ function overrideConf(conf) {
if
(
cli
.
server
.
remote
.
port
!=
undefined
)
conf
.
remoteport
=
cli
.
server
.
remote
.
port
;
if
(
cli
.
server
.
remote
.
port
!=
undefined
)
conf
.
remoteport
=
cli
.
server
.
remote
.
port
;
if
(
cli
.
policy
.
keys
)
conf
.
kmanagement
=
cli
.
policy
.
keys
;
if
(
cli
.
policy
.
keys
)
conf
.
kmanagement
=
cli
.
policy
.
keys
;
if
(
cli
.
policy
.
pubkeys
)
conf
.
kaccept
=
cli
.
policy
.
pubkeys
;
if
(
cli
.
policy
.
pubkeys
)
conf
.
kaccept
=
cli
.
policy
.
pubkeys
;
if
(
cli
.
ucp
.
sigDelay
)
conf
.
sigDelay
=
cli
.
ucp
.
sigDelay
;
if
(
cli
.
ucp
.
sigValidity
)
conf
.
sigValidity
=
cli
.
ucp
.
sigValidity
;
if
(
cli
.
ucp
.
sigQty
)
conf
.
sigQty
=
cli
.
ucp
.
sigQty
;
if
(
cli
.
ucp
.
powZeroMin
)
conf
.
powZeroMin
=
cli
.
ucp
.
powZeroMin
;
if
(
cli
.
ucp
.
powPeriod
)
conf
.
powPeriod
=
cli
.
ucp
.
powPeriod
;
if
(
cli
.
ucp
.
participate
)
conf
.
participate
=
cli
.
ucp
.
participate
==
'
Y
'
;
if
(
cli
.
ucp
.
tsInterval
)
conf
.
tsInterval
=
cli
.
ucp
.
tsInterval
;
// Specific internal settings
// Specific internal settings
conf
.
createNext
=
true
;
conf
.
createNext
=
true
;
...
...
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