Commit cec89073 authored by Cédric Moreau's avatar Cédric Moreau

Now allow to sync with an existing keychain

parent 65f69d44
......@@ -260,6 +260,17 @@ function KeyHelper (packetList) {
return this.getHashedPackets(subkeys);
};
this.hasSubkey = function (keyID){
var matched = false;
(key.subKeys || []).forEach(function(subkeyWrapper){
if (subkeyWrapper.isValidSigningKey(key.primaryKey) || subkeyWrapper.isValidEncryptionKey(key.primaryKey)) {
if (subkeyWrapper.subKey.getFingerprint().toUpperCase().match(new RegExp(keyID + '$')))
matched = true;
}
});
return matched;
};
this.getHashedCertifPackets = function (){
var certifs = this.getBase64primaryUserOtherCertifications(); // Array of 1 packet lists (signature)
return this.getHashedPackets(certifs);
......
This diff is collapsed.
......@@ -64,7 +64,7 @@ KeyBlockSchema.methods = {
[
"membersChanges",
].forEach(function(field){
json[field] = json[field] || [];
json[field] = that[field] || [];
});
[
"keysChanges",
......
......@@ -37,6 +37,10 @@ function KeyService (conn, conf, PublicKeyService, PeeringService) {
var Link = conn.model('Link');
var Key = conn.model('Key');
// Flag to say wether timestamp of received keyblocks should be tested
// Useful for synchronisation of old blocks
this.checkWithLocalTimestamp = true;
this.load = function (done) {
done();
};
......@@ -141,7 +145,7 @@ function KeyService (conn, conf, PublicKeyService, PeeringService) {
return;
}
// Test timestamp
if (Math.abs(block.timestamp - now.utcZero().timestamp()) > conf.tsInterval) {
if (KeychainService.checkWithLocalTimestamp && Math.abs(block.timestamp - now.utcZero().timestamp()) > conf.tsInterval) {
next('Timestamp does not match this node\'s time');
return;
}
......@@ -1472,6 +1476,7 @@ function KeyService (conn, conf, PublicKeyService, PeeringService) {
};
this.startGeneration = function (done) {
if (!conf.participate) return;
if (!PeeringService) {
done('Needed peering service activated.');
return;
......
......@@ -141,13 +141,15 @@ program
program
.command('sync [host] [port]')
.description('Tries to synchronise data with remote uCoin node')
.action(service(DO_NOT_LISTEN_HTTP, ucoin.createRegistryServer, function (host, port, server, conf) {
.action(service(DO_NOT_LISTEN_HTTP, ucoin.createPeerServer, function (host, port, server, conf) {
// Disable daemon
conf.sync.AMDaemon = "OFF";
conf.createNext = false;
// Stop keyblock generation
conf.participate = false;
async.series([
function (next) {
server.once('peerInited', next);
},
function (next){
// Synchronize
var Synchroniser = require('../app/lib/sync');
......
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