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
4ba69926
Commit
4ba69926
authored
10 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Add simple unique command gen-next
parent
1c4170a5
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/KeychainService.js
+85
-33
85 additions, 33 deletions
app/service/KeychainService.js
bin/ucoind
+5
-0
5 additions, 0 deletions
bin/ucoind
with
90 additions
and
33 deletions
app/service/KeychainService.js
+
85
−
33
View file @
4ba69926
...
...
@@ -756,6 +756,22 @@ function KeyService (conn, conf, PublicKeyService) {
* Generate a "newcomers" keyblock
*/
this
.
generateUpdates
=
function
(
done
)
{
async
.
waterfall
([
function
(
next
){
findUpdates
(
next
);
},
function
(
updates
,
subupdates
,
next
){
KeyBlock
.
current
(
function
(
err
,
current
)
{
next
(
null
,
current
||
null
,
updates
,
subupdates
);
});
},
function
(
current
,
updates
,
subupdates
,
next
){
createNewcomerBlock
(
current
,
null
,
{},
updates
,
subupdates
,
next
);
},
],
done
);
}
function
findUpdates
(
done
)
{
var
updates
=
{};
var
subupdates
=
{};
async
.
waterfall
([
...
...
@@ -802,15 +818,9 @@ function KeyService (conn, conf, PublicKeyService) {
],
callback
);
},
next
);
},
function
(
next
){
KeyBlock
.
current
(
function
(
err
,
current
)
{
next
(
null
,
current
||
null
);
],
function
(
err
)
{
done
(
err
,
updates
,
subupdates
);
});
},
function
(
current
,
next
){
createNewcomerBlock
(
current
,
null
,
{},
updates
,
subupdates
,
next
);
},
],
done
);
}
/**
...
...
@@ -860,11 +870,16 @@ function KeyService (conn, conf, PublicKeyService) {
* Generate a "newcomers" keyblock
*/
this
.
generateNewcomersAuto
=
function
(
done
)
{
var
filtering
=
function
(
preJoinData
,
next
)
{
KeychainService
.
generateNewcomersBlock
(
noFiltering
,
iteratedChecking
,
done
);
}
function
noFiltering
(
preJoinData
,
next
)
{
// No manual filtering, takes all
next
(
null
,
preJoinData
);
};
var
checking
=
function
(
newcomers
,
checkWoTForNewcomers
,
done
)
{
}
function
iteratedChecking
(
newcomers
,
checkWoTForNewcomers
,
done
)
{
var
passingNewcomers
=
[];
async
.
forEachSeries
(
newcomers
,
function
(
newcomer
,
callback
){
checkWoTForNewcomers
(
passingNewcomers
.
concat
(
newcomer
),
function
(
err
)
{
...
...
@@ -878,14 +893,50 @@ function KeyService (conn, conf, PublicKeyService) {
done
(
null
,
passingNewcomers
);
});
}
KeychainService
.
generateNewcomersBlock
(
filtering
,
checking
,
done
);
}
this
.
generateNext
=
function
(
done
)
{
KeychainService
.
generateNextBlock
(
findUpdates
,
noFiltering
,
iteratedChecking
,
done
);
};
/**
* Generate a "newcomers" keyblock
*/
this
.
generateNewcomersBlock
=
function
(
filteringFunc
,
checkingWoTFunc
,
done
)
{
// 1. See available keychanges
var
withoutUpdates
=
function
(
updates
)
{
updates
(
null
,
{},
{});
};
KeychainService
.
generateNextBlock
(
withoutUpdates
,
filteringFunc
,
checkingWoTFunc
,
done
);
};
/**
* Generate next keyblock, gathering both updates & newcomers
*/
this
.
generateNextBlock
=
function
(
findUpdateFunc
,
filteringFunc
,
checkingWoTFunc
,
done
)
{
var
updates
=
{};
var
subupdates
=
{};
async
.
waterfall
([
function
(
next
)
{
// First, check for members' key updates
findUpdateFunc
(
next
);
},
function
(
theUpdates
,
theSubupdates
,
next
)
{
updates
=
theUpdates
;
subupdates
=
theSubupdates
;
findNewcomers
(
filteringFunc
,
checkingWoTFunc
,
next
);
},
function
(
current
,
newWoT
,
joinData
,
otherUpdates
,
next
){
// Merges updates
_
(
otherUpdates
).
keys
().
forEach
(
function
(
fpr
){
if
(
!
updates
[
fpr
])
updates
[
fpr
]
=
otherUpdates
[
fpr
];
else
updates
[
fpr
].
concat
(
otherUpdates
[
fpr
]);
});
// Create the block
createNewcomerBlock
(
current
,
newWoT
,
joinData
,
updates
,
subupdates
,
next
);
},
],
done
);
};
function
findNewcomers
(
filteringFunc
,
checkingWoTFunc
,
done
)
{
var
wotMembers
=
[];
var
preJoinData
=
{};
var
joinData
=
{};
...
...
@@ -893,6 +944,7 @@ function KeyService (conn, conf, PublicKeyService) {
var
current
;
async
.
waterfall
([
function
(
next
){
// Second, check for newcomers
KeyBlock
.
current
(
function
(
err
,
currentBlock
)
{
current
=
currentBlock
;
next
();
...
...
@@ -1009,11 +1061,11 @@ function KeyService (conn, conf, PublicKeyService) {
});
updates
[
signedFPR
]
=
keptCertifs
;
});
//
Create the block
createNewcomerBlock
(
current
,
wotMembers
.
concat
(
realNewcomers
),
finalJoinData
,
updates
,
{},
next
);
}
,
//
Send back the new WoT, the joining data and key updates for newcomers' signature of WoT
next
(
null
,
current
,
wotMembers
.
concat
(
realNewcomers
),
finalJoinData
,
updates
);
}
],
done
);
}
;
}
function
computeNewLinks
(
theNewcomers
,
joinData
,
updates
,
members
)
{
var
newLinks
=
{};
...
...
This diff is collapsed.
Click to expand it.
bin/ucoind
+
5
−
0
View file @
4ba69926
...
...
@@ -221,6 +221,11 @@ function handleKey (server, key, isManaged, message) {
});
}
program
.
command
(
'
gen-next [host] [port] [difficulty]
'
)
.
description
(
'
Tries to generate the next keyblock of the keychain, with both updates & newcomers
'
)
.
action
(
service
(
DO_NOT_LISTEN_HTTP
,
ucoin
.
createWOTServer
,
generateAndSend
(
"
generateNext
"
)));
program
.
command
(
'
gen-empty-next [host] [port] [difficulty]
'
)
.
description
(
'
Tries to generate the next keyblock of the keychain without any changes
'
)
...
...
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