Commit 964b8ebb authored by Cédric Moreau's avatar Cédric Moreau

Now able to accept empty keyblocks

parent b4822868
......@@ -114,6 +114,7 @@ function extractKeyChanges(raw) {
var keychanges = [];
var currentKC;
var lines = raw.split(/\n/);
lines = lines.slice(0, lines.length - 1);
var nbKeys = 0;
lines.forEach(function(line){
if (line.match(/^#####----(F|N|U|L|B):[A-Z0-9]{40}----#####$/)) {
......
......@@ -175,7 +175,7 @@ function KeyService (conn, conf, PublicKeyService) {
checkPulseBlockKeychanges(block, done);
} else if (current) {
done('Post-root blocks are not managed yet');
checkNormalBlockKeychanges(block, done);
} else {
checkRootBlockKeychanges(block, function (err) {
......@@ -217,6 +217,29 @@ function KeyService (conn, conf, PublicKeyService) {
});
}
function checkNormalBlockKeychanges(block, done) {
var newLinks = {};
async.forEach(block.keysChanges, function(kc, callback){
if (kc.type != 'U') {
callback('Only UPDATE block are managed for now');
return;
}
async.waterfall([
function (next){
// Check keychange (certifications verification notably)
checkKeychange(block, kc, next);
},
function (next){
// Memorize new links from signatures
newLinks[kc.fingerprint] = kc.certifiers;
next();
},
], callback);
}, function (err) {
done(err, newLinks);
});
}
function checkKeychange (block, kc, done) {
try {
......@@ -933,6 +956,8 @@ function KeyService (conn, conf, PublicKeyService) {
block.version = 1;
block.currency = current.currency;
block.number = current.number + 1;
block.previousHash = current.hash;
block.previousIssuer = current.issuer;
// Members merkle
var stayers = members.slice(); // copy
var leavers = leaving.slice(); // copy
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment