Commit 1f641fad authored by Eriksson Monteiro's avatar Eriksson Monteiro

update millix-node v1.11.6

parent 39531639
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<br> <br>
<a href="#"><img src="https://github.com/millix/millix-wallet/blob/master/app/icon.png?raw=true" alt="millix node" width="200"></a> <a href="#"><img src="https://github.com/millix/millix-wallet/blob/master/app/icon.png?raw=true" alt="millix node" width="200"></a>
<br> <br>
millix node <small>v1.11.5</small> millix node <small>v1.11.6</small>
<br> <br>
</h1> </h1>
......
...@@ -79,6 +79,7 @@ class Server { ...@@ -79,6 +79,7 @@ class Server {
} }
else { else {
console.log('api source code not found'); console.log('api source code not found');
database.getRepository('api').removeAPI(api.api_id);
} }
}); });
......
...@@ -766,8 +766,8 @@ export const NETWORK_SHORT_TIME_WAIT_MAX = 1500; ...@@ -766,8 +766,8 @@ export const NETWORK_SHORT_TIME_WAIT_MAX = 1500;
export const DATABASE_ENGINE = 'sqlite'; export const DATABASE_ENGINE = 'sqlite';
export const DATABASE_CONNECTION = {}; export const DATABASE_CONNECTION = {};
export const MILLIX_CIRCULATION = 9e15; export const MILLIX_CIRCULATION = 9e15;
export const NODE_MILLIX_BUILD_DATE = 1630421866; export const NODE_MILLIX_BUILD_DATE = 1631097631;
export const NODE_MILLIX_VERSION = '1.11.5-tangled'; export const NODE_MILLIX_VERSION = '1.11.6-tangled';
export const DATA_BASE_DIR_MAIN_NETWORK = './millix-tangled'; export const DATA_BASE_DIR_MAIN_NETWORK = './millix-tangled';
export const DATA_BASE_DIR_TEST_NETWORK = './millix-tangled'; export const DATA_BASE_DIR_TEST_NETWORK = './millix-tangled';
let DATA_BASE_DIR = MODE_TEST_NETWORK ? DATA_BASE_DIR_TEST_NETWORK : DATA_BASE_DIR_MAIN_NETWORK; let DATA_BASE_DIR = MODE_TEST_NETWORK ? DATA_BASE_DIR_TEST_NETWORK : DATA_BASE_DIR_MAIN_NETWORK;
......
...@@ -207,13 +207,6 @@ export class WalletTransactionConsensus { ...@@ -207,13 +207,6 @@ export class WalletTransactionConsensus {
message : `not validated in a depth of ${depth}` message : `not validated in a depth of ${depth}`
}); });
} }
else if (transaction && (transaction.status === 2 || database.getRepository('transaction').isExpired(transaction.transaction_date))) {
return reject({
cause : 'transaction_validation_max_depth',
transaction_id_fail: transactionID,
message : `transaction expired and not validated`
});
}
if (transaction && transaction.is_stable !== undefined) { // transaction object needs to be normalized if (transaction && transaction.is_stable !== undefined) { // transaction object needs to be normalized
transaction = database.getRepository('transaction').normalizeTransactionObject(transaction); transaction = database.getRepository('transaction').normalizeTransactionObject(transaction);
......
...@@ -108,4 +108,4 @@ db.initialize() ...@@ -108,4 +108,4 @@ db.initialize()
}); });
} }
}); });
//millix v1.11.5-tangled //millix v1.11.6-tangled
...@@ -16,6 +16,7 @@ import util from 'util'; ...@@ -16,6 +16,7 @@ import util from 'util';
import dns from 'dns'; import dns from 'dns';
import DHT from 'bittorrent-dht'; import DHT from 'bittorrent-dht';
import signature from '../core/crypto/signature'; import signature from '../core/crypto/signature';
import NatAPI from 'nat-api';
const WebSocketServer = Server; const WebSocketServer = Server;
...@@ -291,7 +292,11 @@ class Network { ...@@ -291,7 +292,11 @@ class Network {
this.addNode(node.node_prefix, node.node_address, node.node_port, node.node_port_api, node.node_id); this.addNode(node.node_prefix, node.node_address, node.node_port, node.node_port_api, node.node_id);
callback(); callback();
}, () => { }, () => {
_.each(_.shuffle(config.NODE_INITIAL_LIST), ({host, port_protocol: port, port_api: portApi}) => { _.each(_.shuffle(config.NODE_INITIAL_LIST), ({
host,
port_protocol: port,
port_api : portApi
}) => {
let prefix = config.WEBSOCKET_PROTOCOL; let prefix = config.WEBSOCKET_PROTOCOL;
let url = `${prefix}://${host}:${port}`; let url = `${prefix}://${host}:${port}`;
if ((!this._nodeList[url] || !this._nodeList[url].node_id) && (prefix && host && port && portApi)) { if ((!this._nodeList[url] || !this._nodeList[url].node_id) && (prefix && host && port && portApi)) {
...@@ -793,9 +798,35 @@ class Network { ...@@ -793,9 +798,35 @@ class Network {
} }
} }
doPortMapping() {
const portMapper = util.promisify(this.natAPI.map);
return portMapper({
publicPort : config.NODE_PORT,
privatePort: config.NODE_PORT,
protocol : 'TCP',
description: 'millix network'
})
.then(() => portMapper({
publicPort : config.NODE_PORT_API,
privatePort: config.NODE_PORT_API,
protocol : 'TCP',
description: 'millix api'
}))
.then(() => portMapper({
publicPort : config.NODE_PORT_DISCOVERY,
privatePort: config.NODE_PORT_DISCOVERY,
protocol : 'UDP',
description: 'millix discovery'
}));
}
_initializeServer(certificatePem, certificatePrivateKeyPem) { _initializeServer(certificatePem, certificatePrivateKeyPem) {
console.log('node id : ', this.nodeID); console.log('node id : ', this.nodeID);
this.startAcceptingConnections(certificatePem, certificatePrivateKeyPem); this.natAPI = new NatAPI();
this.doPortMapping()
.then(() => this.startAcceptingConnections(certificatePem, certificatePrivateKeyPem))
.catch(() => this.startAcceptingConnections(certificatePem, certificatePrivateKeyPem));
this.connectToNodes(); this.connectToNodes();
this.initialized = true; this.initialized = true;
eventBus.on('node_handshake', this._onNodeHandshake.bind(this)); eventBus.on('node_handshake', this._onNodeHandshake.bind(this));
...@@ -835,13 +866,21 @@ class Network { ...@@ -835,13 +866,21 @@ class Network {
console.log('[network] node public-ip', ip); console.log('[network] node public-ip', ip);
this.nodePublicIp = ip; this.nodePublicIp = ip;
walletUtils.loadNodeKeyAndCertificate() walletUtils.loadNodeKeyAndCertificate()
.then(({certificate_private_key_pem: certificatePrivateKeyPem, certificate_pem: certificatePem, node_private_key: privateKey, node_public_key: publicKey}) => { .then(({
certificate_private_key_pem: certificatePrivateKeyPem,
certificate_pem : certificatePem,
node_private_key : privateKey,
node_public_key : publicKey
}) => {
this.nodePrivateKey = privateKey; this.nodePrivateKey = privateKey;
this.nodePublicKey = base58.encode(publicKey.toBuffer()); this.nodePublicKey = base58.encode(publicKey.toBuffer());
this.nodeID = walletUtils.getNodeIdFromPublicKey(this.nodePublicKey); this.nodeID = walletUtils.getNodeIdFromPublicKey(this.nodePublicKey);
const nodeIDHash160 = objectHash.getSHA1Buffer(this.nodeID); const nodeIDHash160 = objectHash.getSHA1Buffer(this.nodeID);
this._initializeServer(certificatePem, certificatePrivateKeyPem); this._initializeServer(certificatePem, certificatePrivateKeyPem);
const bootstrap = _.map(config.NODE_INITIAL_LIST, ({host, port_discovery: port}) => `${host}:${port}`); const bootstrap = _.map(config.NODE_INITIAL_LIST, ({
host,
port_discovery: port
}) => `${host}:${port}`);
this.dht = new DHT({ this.dht = new DHT({
nodeId: nodeIDHash160, nodeId: nodeIDHash160,
verify: (sign, value, publicKeyRaw) => { verify: (sign, value, publicKeyRaw) => {
...@@ -863,7 +902,7 @@ class Network { ...@@ -863,7 +902,7 @@ class Network {
this.dht.on('node', node => { this.dht.on('node', node => {
console.log(`[network] new node discovered ${node.host}:${node.port}`); console.log(`[network] new node discovered ${node.host}:${node.port}`);
}); });
console.log(config.NODE_PORT_DISCOVERY);
this.dht.listen(config.NODE_PORT_DISCOVERY); this.dht.listen(config.NODE_PORT_DISCOVERY);
this.dht.on('listening', () => { this.dht.on('listening', () => {
const address = this.dht.address(); const address = this.dht.address();
...@@ -914,10 +953,11 @@ class Network { ...@@ -914,10 +953,11 @@ class Network {
newSeqNumber = 0; newSeqNumber = 0;
} }
const proxyData = previousProxyData[this.nodeID]; let newProxyData;
const nodeAddressDefault = address.address_key_identifier + address.address_version + address.address_key_identifier; const nodeAddressDefault = address.address_key_identifier + address.address_version + address.address_key_identifier;
if (this._shouldUpdateProxyData(proxyData, this.nodePublicIp, config.NODE_PORT, config.TRANSACTION_FEE_PROXY, nodeAddressDefault)) { if (this._shouldUpdateProxyData(previousProxyData, this.nodePublicIp, config.NODE_PORT, config.TRANSACTION_FEE_PROXY, nodeAddressDefault)) {
previousProxyData[this.nodeID] = { newProxyData = {
node_id : this.nodeID,
node_host : this.nodePublicIp, node_host : this.nodePublicIp,
node_prefix : config.WEBSOCKET_PROTOCOL, node_prefix : config.WEBSOCKET_PROTOCOL,
node_port : config.NODE_PORT, node_port : config.NODE_PORT,
...@@ -926,14 +966,20 @@ class Network { ...@@ -926,14 +966,20 @@ class Network {
node_address_default: nodeAddressDefault node_address_default: nodeAddressDefault
}; };
} }
else {
return;
}
const data = { const data = {
k : publicKey, k : publicKey,
seq : newSeqNumber, seq : newSeqNumber,
v : JSON.stringify(previousProxyData), v : JSON.stringify(newProxyData),
sign: function(buf) { sign: function(buf) {
return signature.sign(objectHash.getHashBuffer(buf, true), privateKey, 'buffer'); return signature.sign(objectHash.getHashBuffer(buf, true), privateKey, 'buffer');
} }
}; };
console.log(`[network] dht v=${data.v}, len=${data.v.length}`);
this.dht.put(data, (err, hash) => { this.dht.put(data, (err, hash) => {
console.log('[network] dht key identifier registered hash=', hash.toString('hex'), ', err=', err); console.log('[network] dht key identifier registered hash=', hash.toString('hex'), ', err=', err);
}); });
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
"jwks-rsa": "^1.5.1", "jwks-rsa": "^1.5.1",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"moment": "^2.24.0", "moment": "^2.24.0",
"nat-api": "^0.3.1",
"ntp-time-sync": "^0.1.0", "ntp-time-sync": "^0.1.0",
"public-ip": "^4.0.1", "public-ip": "^4.0.1",
"request": "^2.88.0", "request": "^2.88.0",
......
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