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
3d4b3960
Commit
3d4b3960
authored
9 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Fix: could not manually add peer which had forked
parent
fb05dfcc
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/service/PeeringService.js
+18
-7
18 additions, 7 deletions
app/service/PeeringService.js
bin/ucoind
+1
-1
1 addition, 1 deletion
bin/ucoind
with
19 additions
and
8 deletions
app/service/PeeringService.js
+
18
−
7
View file @
3d4b3960
...
...
@@ -42,24 +42,37 @@ function PeeringService(server, pair, dal) {
done
=
eraseIfAlreadyRecorded
;
eraseIfAlreadyRecorded
=
false
;
}
return
that
.
submitP
(
peering
,
eraseIfAlreadyRecorded
)
.
then
((
res
)
=>
done
(
null
,
res
))
.
catch
(
done
);
};
this
.
submitP
=
function
(
peering
,
eraseIfAlreadyRecorded
,
cautious
){
let
thePeer
=
new
Peer
(
peering
);
let
sp
=
thePeer
.
block
.
split
(
'
-
'
);
let
blockNumber
=
sp
[
0
];
let
blockHash
=
sp
[
1
];
let
sigTime
=
0
;
let
block
;
let
makeCheckings
=
cautious
||
cautious
===
undefined
;
return
co
(
function
*
()
{
if
(
makeCheckings
)
{
let
goodSignature
=
localValidator
(
null
).
checkPeerSignature
(
thePeer
);
if
(
!
goodSignature
)
{
throw
'
Signature from a peer must match
'
;
}
}
if
(
thePeer
.
block
==
constants
.
PEER
.
SPECIAL_BLOCK
)
{
thePeer
.
statusTS
=
0
;
thePeer
.
status
=
'
UP
'
;
}
else
{
block
=
yield
dal
.
getBlockByNumberAndHashOrNull
(
blockNumber
,
blockHash
);
if
(
!
block
)
{
if
(
!
block
&&
makeCheckings
)
{
throw
constants
.
PEER
.
UNKNOWN_REFERENCE_BLOCK
;
}
else
if
(
!
block
)
{
thePeer
.
block
=
constants
.
PEER
.
SPECIAL_BLOCK
;
thePeer
.
statusTS
=
0
;
thePeer
.
status
=
'
UP
'
;
}
}
sigTime
=
block
?
block
.
medianTime
:
0
;
...
...
@@ -84,10 +97,8 @@ function PeeringService(server, pair, dal) {
peerEntity
.
hash
=
String
(
sha1
(
peerEntity
.
getRawSigned
())).
toUpperCase
();
yield
dal
.
savePeer
(
peerEntity
);
let
res
=
Peer
.
statics
.
peerize
(
peerEntity
);
done
(
null
,
res
);
return
res
;
})
.
catch
(
done
);
});
};
var
peerFifo
=
async
.
queue
(
function
(
task
,
callback
)
{
...
...
This diff is collapsed.
Click to expand it.
bin/ucoind
+
1
−
1
View file @
3d4b3960
...
...
@@ -156,7 +156,7 @@ program
return
Q
.
nfcall
(
node
.
network
.
peering
.
get
)
.
then
(
function
(
peering
){
logger
.
info
(
'
Apply peering ...
'
);
return
Q
.
nfcall
(
server
.
PeeringService
.
submit
,
peering
,
ERASE_IF_ALREADY_RECORDED
)
return
server
.
PeeringService
.
submit
P
(
peering
,
ERASE_IF_ALREADY_RECORDED
,
!
program
.
nocautious
)
.
then
(
function
()
{
logger
.
info
(
'
Applied
'
);
return
server
.
dal
.
getPeer
(
server
.
PeeringService
.
pubkey
)
...
...
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