Skip to content
Snippets Groups Projects
Commit 276b7c58 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Add udc/amendments/init

parent 09c25b81
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ Protocol implementation: ...@@ -18,7 +18,7 @@ Protocol implementation:
✔ REST service to store a OpenPGP certificate in AA format, with signature of it AA format too - pks/add @done (13-07-12 01:20) ✔ REST service to store a OpenPGP certificate in AA format, with signature of it AA format too - pks/add @done (13-07-12 01:20)
2) Managing Amendment submission: 2) Managing Amendment submission:
REST service to push root certificates used to initialize Amendment Chain - udc/amendments/init REST service to view root certificates used to initialize Amendment Chain - udc/amendments/init @done (13-07-12 23:55)
☐ REST service for receiving an Amendment data structure - udc/amendments/submit ☐ REST service for receiving an Amendment data structure - udc/amendments/submit
☐ Check Amendment structure ☐ Check Amendment structure
☐ Check Amendment eligibility according to the Node rules (notably UD amount) ☐ Check Amendment eligibility according to the Node rules (notably UD amount)
......
var fs = require('fs'),
util = require('util'),
async = require('async'),
orm = require('orm'),
_ = require('underscore'),
stream = require('stream');
module.exports.init = function (initKeys, req, res) {
var PublicKey = req.models.PublicKey;
var pubkeys = [];
async.forEach(initKeys, function (initkey, done) {
var pk = new PublicKey({ raw:initkey.data });
pk.construct(function (err) {
pubkeys.push(pk);
done(err);
});
}, function (err) {
if(err)
res.send(503, err);
else{
res.writeHead(200, {"Content-type": "text/plain"});
res.end(JSON.stringify(pubkeys));
}
});
};
module.exports.submit = function (req, res) {
};
module.exports.members = function (req, res) {
};
module.exports.self = function (req, res) {
};
module.exports.voters = function (req, res) {
};
module.exports.vote = function (req, res) {
};
\ No newline at end of file
var async = require('async');
var fs = require('fs');
function Configurer(config) {
this.config = config;
this.parseFiles = function (callback) {
var obj = this;
if (obj.config.initKeys) {
async.forEach(obj.config.initKeys, function(file, done){
fs.readFile(file.path, {encoding: "utf8"}, function (err, data) {
file.data = data;
done(err);
});
},
callback);
}
else{
callback();
}
return this;
};
}
module.exports = function (config) {
return new Configurer(config);
};
\ No newline at end of file
var pks = require('./pks'), var pks = require('./pks'),
udc = require('./udc'), amend = require('./amendments'),
express = require('express'), express = require('express'),
orm = require('orm'), orm = require('orm'),
async = require('async'), async = require('async'),
...@@ -7,9 +7,10 @@ config = require('../config'), ...@@ -7,9 +7,10 @@ config = require('../config'),
path = require('path'), path = require('path'),
_ = require('underscore'), _ = require('underscore'),
nodecoin = require('../lib/nodecoin'); nodecoin = require('../lib/nodecoin');
configurer = require('../lib/configurer');
module.exports.pks = pks; module.exports.pks = pks;
module.exports.udc = udc; module.exports.amendments = amend;
module.exports.express = { module.exports.express = {
route: function(app){ route: function(app){
...@@ -22,7 +23,7 @@ module.exports.express = { ...@@ -22,7 +23,7 @@ module.exports.express = {
app.get( '/pks/lookup', pks.lookup); app.get( '/pks/lookup', pks.lookup);
app.get( '/pks/add', pks.add.get); app.get( '/pks/add', pks.add.get);
app.post( '/pks/add', pks.add.post); app.post( '/pks/add', pks.add.post);
app.post( '/udc/amendments/init', notImplemented); app.get( '/udc/amendments/init', _(amend.init).partial(app.get('config').initKeys));
app.post( '/udc/amendments/submit', notImplemented); app.post( '/udc/amendments/submit', notImplemented);
app.post( '/udc/amendments/vote', notImplemented); app.post( '/udc/amendments/vote', notImplemented);
app.get( '/udc/amendments/view/:amendment_id/members', notImplemented); app.get( '/udc/amendments/view/:amendment_id/members', notImplemented);
...@@ -49,7 +50,17 @@ module.exports.express = { ...@@ -49,7 +50,17 @@ module.exports.express = {
} }
}; };
configurer(config).parseFiles(function (err) {
if(!err){
console.log("Initkeys loaded.");
}
else{
console.log(err);
}
});
// all environments // all environments
app.set('config', config);
app.set('port', process.env.PORT || config.server.port); app.set('port', process.env.PORT || config.server.port);
app.use(express.favicon(__dirname + '/../public/favicon.ico')); app.use(express.favicon(__dirname + '/../public/favicon.ico'));
app.use(express.static(__dirname + '/../public')); app.use(express.static(__dirname + '/../public'));
......
module.exports = {};
\ No newline at end of file
...@@ -298,7 +298,7 @@ This URL is used to manage OpenPGP certificates, making NodeCoin acting **like** ...@@ -298,7 +298,7 @@ This URL is used to manage OpenPGP certificates, making NodeCoin acting **like**
### udc/* ### udc/*
This URL pattern manages all the data used by NodeCoin based on the PKS. This URL pattern manages all the data used by NodeCoin based on the PKS.
* `amendments/init` is used to POST the initial keys used to forge the initial amendment (aka. Monetary Contract). * `amendments/init` is used to GET the initial keys used to forge the initial amendment (aka. Monetary Contract).
* `amendments/submit` is used to POST an amendment with the required signatures (votes) in ASCII-Armored format. * `amendments/submit` is used to POST an amendment with the required signatures (votes) in ASCII-Armored format.
* `amendments/view/[AMENDMENT_ID]/members` is a Merkle URL referencing to the members of the Web of Trust. * `amendments/view/[AMENDMENT_ID]/members` is a Merkle URL referencing to the members of the Web of Trust.
* `amendments/view/[AMENDMENT_ID]/self` shows the raw data of the amendment with the given `[AMENDMENT_ID]`. * `amendments/view/[AMENDMENT_ID]/self` shows the raw data of the amendment with the given `[AMENDMENT_ID]`.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment