apxtrib/routes/nationchains.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-01-22 09:53:09 +00:00
const express = require( 'express' );
2023-02-10 10:48:45 +00:00
const config = require( '../tribes/townconf.js' );
2023-01-22 09:53:09 +00:00
// Classes
const Nationchains = require( '../models/Nationchains.js' );
// Middlewares
const checkHeaders = require( '../middlewares/checkHeaders' );
const isAuthenticated = require( '../middlewares/isAuthenticated' );
const hasAccessrighton = require( '../middlewares/hasAccessrighton' );
const router = express.Router();
/*
Manage the social world
@Todo
Manage a new nation
A major create a nation with at least a town => nation:{name, towns:[]} contracts/nationname.js + contracts/townsname.js
Manage a new towns in a nation => update nation:[nationname:towns:[]} contracts/townname.js
*/
router.post( '/push', checkHeaders, ( req, res ) => {
2023-03-27 05:52:21 +00:00
// Get information from other apxtrib instance in req.body
2023-01-22 09:53:09 +00:00
// check req.body.hashnext => means this is a candidate to validate next block
//
// return it's own information back with the last call to Nationchains.synchronize()
res.send( { status: 200, payload: { moreinfo: fs.readFileSync( `${config.tribes}/${config.mayorId}/nationchains/nodes/${config.rootURL}`, 'utf-8' ) } } )
} )
module.exports = router;