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
43817783
Commit
43817783
authored
10 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Added UTC+0 timestamp constraint for new keyblocks
parent
63737d0e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/common.js
+4
-0
4 additions, 0 deletions
app/lib/common.js
app/service/KeychainService.js
+9
-2
9 additions, 2 deletions
app/service/KeychainService.js
with
13 additions
and
2 deletions
app/lib/common.js
+
4
−
0
View file @
43817783
...
...
@@ -42,6 +42,10 @@ String.prototype.hexstrdump = function() {
};
Date
.
prototype
.
utc
=
function
(){
return
new
Date
();
};
Date
.
prototype
.
utcZero
=
function
(){
return
new
Date
(
this
.
getTime
()
+
this
.
getTimezoneOffset
()
*
60
*
1000
);
};
...
...
This diff is collapsed.
Click to expand it.
app/service/KeychainService.js
+
9
−
2
View file @
43817783
...
...
@@ -28,10 +28,11 @@ function KeyService (conn, conf, PublicKeyService) {
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
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
)
{
done
();
...
...
@@ -103,6 +104,7 @@ function KeyService (conn, conf, PublicKeyService) {
}
this
.
submitKeyBlock
=
function
(
kb
,
done
)
{
var
now
=
new
Date
();
var
block
=
new
KeyBlock
(
kb
);
block
.
issuer
=
kb
.
pubkey
.
fingerprint
;
var
currentBlock
=
null
;
...
...
@@ -134,6 +136,11 @@ function KeyService (conn, conf, PublicKeyService) {
next
(
'
PreviousIssuer does not target current block
'
);
return
;
}
// Test timestamp
if
(
Math
.
abs
(
block
.
timestamp
-
now
.
utcZero
().
timestamp
())
>
MAX_TIMESTAMP_DELAY
)
{
next
(
'
Timestamp does not match this node
\'
s time
'
);
return
;
}
// Check the challenge depending on issuer
checkProofOfWork
(
block
,
next
);
},
...
...
@@ -1342,7 +1349,7 @@ function KeyService (conn, conf, PublicKeyService) {
async
.
whilst
(
function
(){
return
!
pow
.
match
(
powRegexp
);
},
function
(
next
)
{
var
newTS
=
new
Date
().
timestamp
();
var
newTS
=
new
Date
().
utcZero
().
timestamp
();
if
(
newTS
==
block
.
timestamp
)
{
block
.
nonce
++
;
}
else
{
...
...
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