Commit 4d0547f8 authored by Eriksson Monteiro's avatar Eriksson Monteiro

update millix node v1.10.9-tangled

parent 46ec5ad3
...@@ -774,8 +774,8 @@ export const NETWORK_SHORT_TIME_WAIT_MAX = 1500; ...@@ -774,8 +774,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 = 1622201109; export const NODE_MILLIX_BUILD_DATE = 1622937315;
export const NODE_MILLIX_VERSION = '1.10.8-tangled'; export const NODE_MILLIX_VERSION = '1.10.9-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;
......
...@@ -186,21 +186,6 @@ ...@@ -186,21 +186,6 @@
"enable": true "enable": true
} }
}, },
"wallet_balance_sync": {
"type": "function",
"group": "wallet",
"processor": "localhost_wallet",
"payload": {
"module": "wallet",
"function_name": "_doSyncBalanceForAddresses"
},
"priority": 1,
"option_list": {
"run_always": 1,
"run_delay": 10000,
"enable": true
}
},
"wallet_retry_validation_update": { "wallet_retry_validation_update": {
"type": "function", "type": "function",
"group": "wallet", "group": "wallet",
......
...@@ -119,15 +119,28 @@ export class WalletSync { ...@@ -119,15 +119,28 @@ export class WalletSync {
} }
database.firstShardZeroORShardRepository('transaction', shardID, (transactionRepository) => { database.firstShardZeroORShardRepository('transaction', shardID, (transactionRepository) => {
return new Promise((resolve, reject) => { return transactionRepository.getTransactionInput({
transactionRepository.getTransactionInput({
output_transaction_id: transactionID, output_transaction_id: transactionID,
output_shard_id : shardID, output_shard_id : shardID,
output_position : outputPosition output_position : outputPosition
}) }).then(input => {
.then(input => input ? transactionRepository.getTransaction(input.transaction_id) : reject()) if (input) {
.then(transaction => resolve(transaction)) /* check if there is any input that is double spend.
.catch(() => reject()); if so, we should force updating this transaction output as spent.
*/
return transactionRepository.listTransactionInput({
'transaction_input.transaction_id' : input.transaction_id,
is_double_spend: 1
}).then(doubleSpendInputList => {
if (doubleSpendInputList.length > 0) {
return Promise.reject();
}
return transactionRepository.getTransaction(input.transaction_id);
});
}
else {
return Promise.reject();
}
}); });
}).then(spendingTransaction => { }).then(spendingTransaction => {
// skip if we already know that the tx is spent // skip if we already know that the tx is spent
......
...@@ -560,7 +560,12 @@ class WalletUtils { ...@@ -560,7 +560,12 @@ class WalletUtils {
resolve(true); resolve(true);
} }
else { else {
this.isConsumingExpiredOutputs(transaction.transaction_input_list, transactionDate) // before 1620603935 the refresh time was 3 days
// now the refresh time is 10 min (TRANSACTION_OUTPUT_EXPIRE_OLDER_THAN)
const expireMinutes = transactionDate.getTime() <= 1620603935000 ? 4320 : config.TRANSACTION_OUTPUT_EXPIRE_OLDER_THAN;
let maximumOldestDate = new Date(transactionDate.getTime());
maximumOldestDate.setMinutes(maximumOldestDate.getMinutes() - expireMinutes);
this.isConsumingExpiredOutputs(transaction.transaction_input_list, maximumOldestDate)
.then(isConsumingExpired => { .then(isConsumingExpired => {
resolve(!isConsumingExpired); resolve(!isConsumingExpired);
}) })
...@@ -576,7 +581,7 @@ class WalletUtils { ...@@ -576,7 +581,7 @@ class WalletUtils {
return signature.verify(objectHash.getHashBuffer(message), sign, publicKey); return signature.verify(objectHash.getHashBuffer(message), sign, publicKey);
} }
isConsumingExpiredOutputs(inputList, transactionDate) { isConsumingExpiredOutputs(inputList, maximumOldestDate) {
return new Promise(resolve => { return new Promise(resolve => {
async.eachSeries(inputList, (input, callback) => { async.eachSeries(inputList, (input, callback) => {
let output_shard = input.output_shard_id; let output_shard = input.output_shard_id;
...@@ -589,10 +594,7 @@ class WalletUtils { ...@@ -589,10 +594,7 @@ class WalletUtils {
callback(false); callback(false);
} }
else { else {
let maximumOldest = new Date(transactionDate.getTime()); if ((maximumOldestDate - sourceTransaction.transaction_date) > 0) {
maximumOldest.setMinutes(maximumOldest.getMinutes() - config.TRANSACTION_OUTPUT_EXPIRE_OLDER_THAN);
if ((maximumOldest - sourceTransaction.transaction_date) > 0) {
// Meaning it // Meaning it
// consumed an // consumed an
// expired output // expired output
...@@ -768,6 +770,9 @@ class WalletUtils { ...@@ -768,6 +770,9 @@ class WalletUtils {
return Promise.reject('private key set is required'); return Promise.reject('private key set is required');
} }
let maximumOldestDate = new Date(transactionDate.getTime());
maximumOldestDate.setMinutes(maximumOldestDate.getMinutes() - config.TRANSACTION_OUTPUT_EXPIRE_OLDER_THAN);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let allocatedFunds = 0; let allocatedFunds = 0;
const amount = _.sum(_.map(outputList, o => o.amount)) + _.sum(_.map(feeOutputList, o => o.amount)); const amount = _.sum(_.map(outputList, o => o.amount)) + _.sum(_.map(feeOutputList, o => o.amount));
...@@ -803,7 +808,7 @@ class WalletUtils { ...@@ -803,7 +808,7 @@ class WalletUtils {
})) }))
.then((signatureList) => peer.getNodeAddress() .then((signatureList) => peer.getNodeAddress()
.then(() => signatureList)) .then(() => signatureList))
.then(signatureList => this.isConsumingExpiredOutputs(inputList, transactionDate).then(isConsumingExpiredOutputs => [ .then(signatureList => this.isConsumingExpiredOutputs(inputList, maximumOldestDate).then(isConsumingExpiredOutputs => [
signatureList, signatureList,
isConsumingExpiredOutputs isConsumingExpiredOutputs
])) ]))
......
This diff is collapsed.
...@@ -109,4 +109,4 @@ db.initialize() ...@@ -109,4 +109,4 @@ db.initialize()
} }
}) })
.then(() => setTimeout(() => wallet.syncAddresses(), 2000)); .then(() => setTimeout(() => wallet.syncAddresses(), 2000));
//millix v1.10.8-tangled //millix v1.10.9-tangled
...@@ -774,18 +774,18 @@ class Peer { ...@@ -774,18 +774,18 @@ class Peer {
}); });
} }
addressTransactionSync(address, updated, ws) { walletTransactionSync(addressKeyIdentifier, excludeTransactionList, ws) {
if (network.registeredClients.length === 0) { if (network.registeredClients.length === 0) {
return address; return;
} }
console.log('[peer] requesting transaction sync for address:', address, ' from ', updated); console.log('[peer] requesting transaction sync for wallet: ', addressKeyIdentifier);
let payload = { let payload = {
type : 'address_transaction_sync', type : 'wallet_transaction_sync',
content: { content: {
address, address_key_identifier: addressKeyIdentifier,
updated exclude_transaction_id_list: excludeTransactionList
} }
}; };
...@@ -800,18 +800,6 @@ class Peer { ...@@ -800,18 +800,6 @@ class Peer {
console.log('[WARN]: try to send data over a closed connection.'); console.log('[WARN]: try to send data over a closed connection.');
} }
} }
else {
network.registeredClients.forEach(ws => {
try {
ws.nodeConnectionReady && !(ws.inBound && !ws.bidirectional) && ws.send(data);
}
catch (e) {
console.log('[WARN]: try to send data over a closed connection.');
}
});
}
return address;
} }
transactionSyncResponse(content, ws) { transactionSyncResponse(content, ws) {
...@@ -954,11 +942,6 @@ class Peer { ...@@ -954,11 +942,6 @@ class Peer {
return; return;
} }
return walletSync.getTransactionUnresolvedData(transactionID)
.then(unresolvedTransaction => {
if (unresolvedTransaction) {
return;
}
let payload = { let payload = {
type : 'transaction_sync_by_date_response:' + network.nodeID, type : 'transaction_sync_by_date_response:' + network.nodeID,
content: {transaction_id_list: transactionList} content: {transaction_id_list: transactionList}
...@@ -973,7 +956,6 @@ class Peer { ...@@ -973,7 +956,6 @@ class Peer {
catch (e) { catch (e) {
console.log('[WARN]: try to send data over a closed connection.'); console.log('[WARN]: try to send data over a closed connection.');
} }
});
} }
transactionSyncByDate(beginTimestamp, endTimestamp, excludeTransactionList, ws) { transactionSyncByDate(beginTimestamp, endTimestamp, excludeTransactionList, ws) {
...@@ -982,7 +964,7 @@ class Peer { ...@@ -982,7 +964,7 @@ class Peer {
let start = Date.now(); let start = Date.now();
let nodeID = ws.nodeID; let nodeID = ws.nodeID;
console.log(`[peer] requesting transaction sync by date from ${new Date(beginTimestamp)} to ${new Date(endTimestamp)} : node ${nodeID}`); console.log(`[peer] requesting transaction sync by date from ${new Date(beginTimestamp * 1000)} to ${new Date(endTimestamp * 1000)} : node ${nodeID}`);
let payload = { let payload = {
type : 'transaction_sync_by_date', type : 'transaction_sync_by_date',
content: { content: {
......
...@@ -96,7 +96,7 @@ CREATE TABLE `transaction` ...@@ -96,7 +96,7 @@ CREATE TABLE `transaction`
is_parent TINYINT NOT NULL DEFAULT 0 CHECK (is_parent = 0 OR is_parent = 1), is_parent TINYINT NOT NULL DEFAULT 0 CHECK (is_parent = 0 OR is_parent = 1),
timeout_date INT NULL CHECK(length(timeout_date) <= 10 AND TYPEOF(timeout_date) IN ('integer', 'null')), timeout_date INT NULL CHECK(length(timeout_date) <= 10 AND TYPEOF(timeout_date) IN ('integer', 'null')),
is_timeout TINYINT NOT NULL DEFAULT 0 CHECK (is_timeout = 0 OR is_timeout = 1), is_timeout TINYINT NOT NULL DEFAULT 0 CHECK (is_timeout = 0 OR is_timeout = 1),
status TINYINT NOT NULL DEFAULT 1 CHECK (length(status) <= 3 AND TYPEOF(status) = 'integer'), status TINYINT NOT NULL DEFAULT 1 CHECK (length(status) <= 3 AND TYPEOF(status) = 'integer'), /*1: default, 2: prune, 3: invalid*/
create_date INT NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INTEGER)) CHECK(length(create_date) <= 10 AND TYPEOF(create_date) = 'integer') create_date INT NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INTEGER)) CHECK(length(create_date) <= 10 AND TYPEOF(create_date) = 'integer')
); );
CREATE INDEX idx_transaction_status_is_stable_transaction_date ON `transaction` (status, is_stable, transaction_date); CREATE INDEX idx_transaction_status_is_stable_transaction_date ON `transaction` (status, is_stable, transaction_date);
...@@ -174,7 +174,7 @@ CREATE TABLE transaction_output ...@@ -174,7 +174,7 @@ CREATE TABLE transaction_output
is_spent TINYINT NOT NULL DEFAULT 0 CHECK (is_spent = 0 OR is_spent = 1), is_spent TINYINT NOT NULL DEFAULT 0 CHECK (is_spent = 0 OR is_spent = 1),
double_spend_date INT NULL CHECK(length(double_spend_date) <= 10 AND TYPEOF(double_spend_date) IN ('integer', 'null')), -- NOT NULL if double spend double_spend_date INT NULL CHECK(length(double_spend_date) <= 10 AND TYPEOF(double_spend_date) IN ('integer', 'null')), -- NOT NULL if double spend
is_double_spend TINYINT NOT NULL DEFAULT 0 CHECK (is_double_spend = 0 OR is_double_spend = 1), is_double_spend TINYINT NOT NULL DEFAULT 0 CHECK (is_double_spend = 0 OR is_double_spend = 1),
status TINYINT NOT NULL DEFAULT 1 CHECK (length(status) <= 3 AND TYPEOF(status) = 'integer'), status TINYINT NOT NULL DEFAULT 1 CHECK (length(status) <= 3 AND TYPEOF(status) = 'integer'), /*1: default, 2: expired*/
create_date INT NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INTEGER)) CHECK(length(create_date) <= 10 AND TYPEOF(create_date) = 'integer'), create_date INT NOT NULL DEFAULT (CAST(strftime('%s', 'now') AS INTEGER)) CHECK(length(create_date) <= 10 AND TYPEOF(create_date) = 'integer'),
PRIMARY KEY (transaction_id, output_position), PRIMARY KEY (transaction_id, output_position),
FOREIGN KEY (transaction_id) REFERENCES `transaction` (transaction_id), FOREIGN KEY (transaction_id) REFERENCES `transaction` (transaction_id),
......
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