Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tangled
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eriksson monteiro
tangled
Commits
ecfd2524
Commit
ecfd2524
authored
Apr 06, 2022
by
Eriksson Monteiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update millix-node: fix wallet sync
parent
2f255289
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
34 deletions
+36
-34
millix_node/README.md
millix_node/README.md
+1
-1
millix_node/core/config/config.js
millix_node/core/config/config.js
+2
-2
millix_node/core/wallet/wallet-sync.js
millix_node/core/wallet/wallet-sync.js
+2
-2
millix_node/core/wallet/wallet-transaction-consensus.js
millix_node/core/wallet/wallet-transaction-consensus.js
+2
-2
millix_node/core/wallet/wallet.js
millix_node/core/wallet/wallet.js
+20
-26
millix_node/database/repositories/transaction.js
millix_node/database/repositories/transaction.js
+8
-0
millix_node/index.js
millix_node/index.js
+1
-1
No files found.
millix_node/README.md
View file @
ecfd2524
...
...
@@ -2,7 +2,7 @@
<br>
<a
href=
"#"
><img
src=
"https://github.com/millix/millix-wallet/blob/master/app/icon.png?raw=true"
alt=
"millix node"
width=
"200"
></a>
<br>
millix node
<small>
v1.17.
0
</small>
millix node
<small>
v1.17.
2
</small>
<br>
</h1>
...
...
millix_node/core/config/config.js
View file @
ecfd2524
...
...
@@ -779,8 +779,8 @@ export const NETWORK_SHORT_TIME_WAIT_MAX = 1500;
export
const
DATABASE_ENGINE
=
'
sqlite
'
;
export
const
DATABASE_CONNECTION
=
{};
export
const
MILLIX_CIRCULATION
=
9
e15
;
export
const
NODE_MILLIX_BUILD_DATE
=
1649
083382
;
export
const
NODE_MILLIX_VERSION
=
'
1.17.
0
-tangled
'
;
export
const
NODE_MILLIX_BUILD_DATE
=
1649
203461
;
export
const
NODE_MILLIX_VERSION
=
'
1.17.
2
-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
;
...
...
millix_node/core/wallet/wallet-sync.js
View file @
ecfd2524
...
...
@@ -309,7 +309,7 @@ export class WalletSync {
}).
then
(()
=>
this
.
updateSyncTransactionSpend
());
}
syncTransactionSpendingOutputs
(
transaction
)
{
syncTransactionSpendingOutputs
(
transaction
,
isModeFullSync
)
{
const
walletKeyIdentifierSet
=
new
Set
([
wallet
.
getKeyIdentifier
(),
...
config
.
EXTERNAL_WALLET_KEY_IDENTIFIER
...
...
@@ -321,7 +321,7 @@ export class WalletSync {
transaction_output_id
:
`
${
transaction
.
transaction_id
}
_
${
transaction
.
shard_id
}
_
${
transactionOutput
.
output_position
}
`
});
}
else
{
else
if
(
isModeFullSync
)
{
this
.
transactionSpendQueue
.
push
({
transaction_output_id
:
`
${
transaction
.
transaction_id
}
_
${
transaction
.
shard_id
}
_
${
transactionOutput
.
output_position
}
`
});
...
...
millix_node/core/wallet/wallet-transaction-consensus.js
View file @
ecfd2524
...
...
@@ -806,9 +806,9 @@ export class WalletTransactionConsensus {
const
transactionRepository
=
database
.
getRepository
(
'
transaction
'
,
shardID
);
transactionRepository
.
getTransactionObject
(
data
.
transaction_id_fail
)
.
then
(
transaction
=>
transaction
?
resolve
(
transactionRepository
.
normalizeTransactionObject
(
transaction
))
:
reject
());
})
.
then
(
transaction
=>
peer
.
transactionSendToNode
(
transaction
,
ws
))
;
});
}).
then
(
transaction
=>
{
if
(
!
transaction
)
{
if
(
!
transaction
&&
config
.
MODE_NODE_SYNC_FULL
)
{
peer
.
transactionSyncRequest
(
data
.
transaction_id_fail
,
{
dispatch_request
:
true
}).
then
(
_
=>
_
).
catch
(
_
=>
_
);
return
;
}
...
...
millix_node/core/wallet/wallet.js
View file @
ecfd2524
...
...
@@ -842,9 +842,7 @@ class Wallet {
_onNewTransaction
(
data
,
ws
,
isRequestedBySync
)
{
let
node
=
ws
.
node
;
let
connectionID
=
ws
.
connectionID
;
let
node
=
ws
.
node
;
let
transaction
=
_
.
cloneDeep
(
data
.
transaction
);
if
(
data
.
routing
&&
data
.
routing_request_node_id
!==
network
.
nodeID
)
{
...
...
@@ -965,9 +963,9 @@ class Wallet {
walletSync
.
clearTransactionSync
(
transaction
.
transaction_id
);
if
(
config
.
MODE_NODE_SYNC_FULL
||
hasKeyIdentifier
)
{
walletSync
.
syncTransactionSpendingOutputs
(
transaction
,
config
.
MODE_NODE_SYNC_FULL
);
if
(
config
.
MODE_NODE_SYNC_FULL
)
{
this
.
transactionSpendRequest
(
transaction
.
transaction_id
,
syncPriority
).
then
(
_
=>
_
).
catch
(
_
=>
_
);
walletSync
.
syncTransactionSpendingOutputs
(
transaction
);
if
(
transaction
.
transaction_id
!==
genesisConfig
.
genesis_transaction
)
{
_
.
each
(
transaction
.
transaction_input_list
,
inputTransaction
=>
{
...
...
@@ -996,28 +994,24 @@ class Wallet {
});
}
});
_
.
each
(
transaction
.
transaction_parent_list
,
parentTransactionID
=>
{
if
(
!
this
.
_transactionReceivedFromNetwork
[
parentTransactionID
])
{
database
.
firstShards
((
shardID
)
=>
{
const
transactionRepository
=
database
.
getRepository
(
'
transaction
'
,
shardID
);
return
new
Promise
((
resolve
,
reject
)
=>
transactionRepository
.
hasTransaction
(
parentTransactionID
)
.
then
(
hasTransaction
=>
hasTransaction
?
resolve
(
hasTransaction
)
:
reject
()));
}).
then
(
hasTransaction
=>
{
if
(
!
hasTransaction
)
{
console
.
log
(
'
[Wallet] request sync parent transaction
'
,
parentTransactionID
);
this
.
_transactionRequested
[
parentTransactionID
]
=
Date
.
now
();
peer
.
transactionSyncRequest
(
parentTransactionID
,
{
priority
:
syncPriority
})
.
catch
(
_
=>
_
);
}
});
}
});
}
}
if
(
!
isRequestedBySync
||
hasKeyIdentifier
)
{
let
ws
=
network
.
getWebSocketByID
(
connectionID
);
peer
.
transactionSend
(
data
.
transaction
,
ws
);
_
.
each
(
transaction
.
transaction_parent_list
,
parentTransactionID
=>
{
if
(
!
this
.
_transactionReceivedFromNetwork
[
parentTransactionID
])
{
database
.
firstShards
((
shardID
)
=>
{
const
transactionRepository
=
database
.
getRepository
(
'
transaction
'
,
shardID
);
return
new
Promise
((
resolve
,
reject
)
=>
transactionRepository
.
hasTransaction
(
parentTransactionID
)
.
then
(
hasTransaction
=>
hasTransaction
?
resolve
(
hasTransaction
)
:
reject
()));
}).
then
(
hasTransaction
=>
{
if
(
!
hasTransaction
)
{
console
.
log
(
'
[Wallet] request sync parent transaction
'
,
parentTransactionID
);
this
.
_transactionRequested
[
parentTransactionID
]
=
Date
.
now
();
peer
.
transactionSyncRequest
(
parentTransactionID
,
{
priority
:
syncPriority
})
.
catch
(
_
=>
_
);
}
});
}
});
}
if
(
hasKeyIdentifier
)
{
...
...
@@ -1116,7 +1110,7 @@ class Wallet {
},
ws
);
}
}
else
{
else
if
(
config
.
MODE_NODE_SYNC_FULL
)
{
console
.
log
(
`[wallet] sending transaction
${
data
.
transaction_id
}
not found to node
${
ws
.
nodeID
}
(response time:
${
Date
.
now
()
-
startTimestamp
}
ms)`
);
peer
.
transactionSyncResponse
({
transaction
:
{
transaction_id
:
data
.
transaction_id
},
...
...
millix_node/database/repositories/transaction.js
View file @
ecfd2524
...
...
@@ -1334,6 +1334,11 @@ export default class Transaction {
and o2.is_double_spend = 0
)
where transaction_id in (select output_transaction_id from transaction_input where transaction_id = "
${
transactionID
}
");
update 'transaction'
set status = 3,
is_stable = 1,
stable_date = CAST(strftime('%s', 'now') AS INTEGER)
where transaction_id in (select output_transaction_id from transaction_input where transaction_id = "
${
transactionID
}
");
`
;
this
.
database
.
exec
(
sql
,
(
err
)
=>
{
if
(
err
)
{
...
...
@@ -2220,6 +2225,9 @@ export default class Transaction {
and o2.is_double_spend = 0
)
WHERE transaction_id IN (SELECT output_transaction_id FROM transaction_input WHERE transaction_id = "
${
transactionID
}
");
UPDATE 'transaction' AS t
SET is_stable = 1, stable_date = CAST (strftime('%s', 'now') AS INTEGER)
WHERE transaction_id IN (SELECT output_transaction_id FROM transaction_input WHERE transaction_id = "
${
transactionID
}
");
`
,
(
err
)
=>
{
if
(
err
)
{
return
reject
(
err
);
...
...
millix_node/index.js
View file @
ecfd2524
...
...
@@ -125,7 +125,7 @@ db.initialize()
});
}
});
//millix v1.17.
0
-tangled
//millix v1.17.
2
-tangled
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment