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;
export const DATABASE_ENGINE = 'sqlite';
export const DATABASE_CONNECTION = {};
export const MILLIX_CIRCULATION = 9e15;
export const NODE_MILLIX_BUILD_DATE = 1622201109;
export const NODE_MILLIX_VERSION = '1.10.8-tangled';
export const NODE_MILLIX_BUILD_DATE = 1622937315;
export const NODE_MILLIX_VERSION = '1.10.9-tangled';
export const DATA_BASE_DIR_MAIN_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;
......
......@@ -186,21 +186,6 @@
"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": {
"type": "function",
"group": "wallet",
......
......@@ -119,15 +119,28 @@ export class WalletSync {
}
database.firstShardZeroORShardRepository('transaction', shardID, (transactionRepository) => {
return new Promise((resolve, reject) => {
transactionRepository.getTransactionInput({
output_transaction_id: transactionID,
output_shard_id : shardID,
output_position : outputPosition
})
.then(input => input ? transactionRepository.getTransaction(input.transaction_id) : reject())
.then(transaction => resolve(transaction))
.catch(() => reject());
return transactionRepository.getTransactionInput({
output_transaction_id: transactionID,
output_shard_id : shardID,
output_position : outputPosition
}).then(input => {
if (input) {
/* check if there is any input that is double spend.
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 => {
// skip if we already know that the tx is spent
......
......@@ -560,7 +560,12 @@ class WalletUtils {
resolve(true);
}
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 => {
resolve(!isConsumingExpired);
})
......@@ -576,7 +581,7 @@ class WalletUtils {
return signature.verify(objectHash.getHashBuffer(message), sign, publicKey);
}
isConsumingExpiredOutputs(inputList, transactionDate) {
isConsumingExpiredOutputs(inputList, maximumOldestDate) {
return new Promise(resolve => {
async.eachSeries(inputList, (input, callback) => {
let output_shard = input.output_shard_id;
......@@ -589,10 +594,7 @@ class WalletUtils {
callback(false);
}
else {
let maximumOldest = new Date(transactionDate.getTime());
maximumOldest.setMinutes(maximumOldest.getMinutes() - config.TRANSACTION_OUTPUT_EXPIRE_OLDER_THAN);
if ((maximumOldest - sourceTransaction.transaction_date) > 0) {
if ((maximumOldestDate - sourceTransaction.transaction_date) > 0) {
// Meaning it
// consumed an
// expired output
......@@ -768,6 +770,9 @@ class WalletUtils {
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) => {
let allocatedFunds = 0;
const amount = _.sum(_.map(outputList, o => o.amount)) + _.sum(_.map(feeOutputList, o => o.amount));
......@@ -803,7 +808,7 @@ class WalletUtils {
}))
.then((signatureList) => peer.getNodeAddress()
.then(() => signatureList))
.then(signatureList => this.isConsumingExpiredOutputs(inputList, transactionDate).then(isConsumingExpiredOutputs => [
.then(signatureList => this.isConsumingExpiredOutputs(inputList, maximumOldestDate).then(isConsumingExpiredOutputs => [
signatureList,
isConsumingExpiredOutputs
]))
......
This diff is collapsed.
......@@ -109,4 +109,4 @@ db.initialize()
}
})
.then(() => setTimeout(() => wallet.syncAddresses(), 2000));
//millix v1.10.8-tangled
//millix v1.10.9-tangled
......@@ -774,18 +774,18 @@ class Peer {
});
}
addressTransactionSync(address, updated, ws) {
walletTransactionSync(addressKeyIdentifier, excludeTransactionList, ws) {
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 = {
type : 'address_transaction_sync',
type : 'wallet_transaction_sync',
content: {
address,
updated
address_key_identifier: addressKeyIdentifier,
exclude_transaction_id_list: excludeTransactionList
}
};
......@@ -800,18 +800,6 @@ class Peer {
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) {
......@@ -954,26 +942,20 @@ class Peer {
return;
}
return walletSync.getTransactionUnresolvedData(transactionID)
.then(unresolvedTransaction => {
if (unresolvedTransaction) {
return;
}
let payload = {
type : 'transaction_sync_by_date_response:' + network.nodeID,
content: {transaction_id_list: transactionList}
};
let payload = {
type : 'transaction_sync_by_date_response:' + network.nodeID,
content: {transaction_id_list: transactionList}
};
eventBus.emit('node_event_log', payload);
eventBus.emit('node_event_log', payload);
let data = JSON.stringify(payload);
try {
ws.nodeConnectionReady && ws.send(data);
}
catch (e) {
console.log('[WARN]: try to send data over a closed connection.');
}
});
let data = JSON.stringify(payload);
try {
ws.nodeConnectionReady && ws.send(data);
}
catch (e) {
console.log('[WARN]: try to send data over a closed connection.');
}
}
transactionSyncByDate(beginTimestamp, endTimestamp, excludeTransactionList, ws) {
......@@ -982,7 +964,7 @@ class Peer {
let start = Date.now();
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 = {
type : 'transaction_sync_by_date',
content: {
......
......@@ -96,7 +96,7 @@ CREATE TABLE `transaction`
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')),
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 INDEX idx_transaction_status_is_stable_transaction_date ON `transaction` (status, is_stable, transaction_date);
......@@ -174,7 +174,7 @@ CREATE TABLE transaction_output
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
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'),
PRIMARY KEY (transaction_id, output_position),
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