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
7993adc4
Commit
7993adc4
authored
10 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Gen-next for root block now also add certifications of initial newcomers
parent
d76cec60
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/service/BlockchainService.js
+64
-34
64 additions, 34 deletions
app/service/BlockchainService.js
with
64 additions
and
34 deletions
app/service/BlockchainService.js
+
64
−
34
View file @
7993adc4
...
...
@@ -712,7 +712,15 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) {
this
.
generateNextBlock
=
function
(
findUpdateFunc
,
filteringFunc
,
checkingWoTFunc
,
done
)
{
var
updates
=
{};
var
exclusions
=
[];
var
current
=
null
;
async
.
waterfall
([
function
(
next
){
// Second, check for newcomers
Block
.
current
(
function
(
err
,
currentBlock
)
{
current
=
currentBlock
;
next
();
});
},
function
(
next
)
{
// First, check for members' exclusions
Identity
.
getToBeKicked
(
next
);
...
...
@@ -726,7 +734,8 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) {
},
function
(
theUpdates
,
next
)
{
updates
=
theUpdates
;
findNewcomers
(
filteringFunc
,
checkingWoTFunc
,
next
);
// Third, check for newcomers
findNewcomers
(
current
,
filteringFunc
,
checkingWoTFunc
,
next
);
},
function
(
current
,
newWoT
,
joinData
,
otherUpdates
,
next
){
// Merges updates
...
...
@@ -742,24 +751,20 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) {
],
done
);
};
function
findNewcomers
(
filteringFunc
,
checkingWoTFunc
,
done
)
{
function
findNewcomers
(
current
,
filteringFunc
,
checkingWoTFunc
,
done
)
{
var
wotMembers
=
[];
var
preJoinData
=
{};
var
joinData
=
{};
var
updates
=
{};
var
current
;
async
.
waterfall
([
function
(
next
){
// Second, check for newcomers
Block
.
current
(
function
(
err
,
currentBlock
)
{
current
=
currentBlock
;
next
();
});
},
function
(
next
){
Membership
.
find
({
membership
:
'
IN
'
,
certts
:
{
$gt
:
0
},
userid
:
{
$exists
:
true
}
},
next
);
},
function
(
mss
,
next
){
var
joiners
=
[];
mss
.
forEach
(
function
(
ms
)
{
joiners
.
push
(
ms
.
issuer
);
});
async
.
forEach
(
mss
,
function
(
ms
,
callback
){
var
join
=
{
identity
:
null
,
ms
:
ms
,
key
:
null
,
idHash
:
''
};
join
.
idHash
=
sha1
(
ms
.
userid
+
ms
.
certts
.
timestamp
()
+
ms
.
issuer
).
toUpperCase
();
...
...
@@ -770,7 +775,23 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) {
Identity
.
getByHash
(
join
.
idHash
,
callback
);
},
certs
:
function
(
callback
){
// Look for certifications fro WoT members
if
(
!
current
)
{
// Look for certifications from initial joiners
async
.
waterfall
([
function
(
next
)
{
Certification
.
to
(
ms
.
issuer
,
next
);
},
function
(
certs
,
next
)
{
var
finalCerts
=
[];
certs
.
forEach
(
function
(
cert
)
{
if
(
~
joiners
.
indexOf
(
cert
.
pubkey
))
finalCerts
.
push
(
cert
);
});
next
(
null
,
finalCerts
);
}
],
callback
);
}
else
{
// Look for certifications from WoT members
async
.
waterfall
([
function
(
next
)
{
Certification
.
toTarget
(
join
.
idHash
,
next
);
...
...
@@ -794,7 +815,8 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) {
next
(
null
,
finalCerts
);
});
}
],
callback
)
],
callback
);
}
},
},
next
);
},
...
...
@@ -1186,7 +1208,15 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) {
var
updates
=
{};
var
joinData
=
{};
var
exclusions
=
[];
var
current
=
null
;
async
.
waterfall
([
function
(
next
){
// Second, check for newcomers
Block
.
current
(
function
(
err
,
currentBlock
)
{
current
=
currentBlock
;
next
();
});
},
function
(
next
)
{
// First, check for members' key updates
findUpdates
(
next
);
...
...
@@ -1200,7 +1230,7 @@ function BlockchainService (conn, conf, IdentityService, PeeringService) {
done
(
err
,
newcomers
);
});
};
findNewcomers
(
withEnoughCerts
,
checkingWoTFunc
,
next
);
findNewcomers
(
current
,
withEnoughCerts
,
checkingWoTFunc
,
next
);
},
function
(
current
,
newWoT
,
theJoinData
,
otherUpdates
,
next
){
// Merges updates
...
...
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