Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Crown
bitcore-wallet-service-crown
Commits
b4afcd7a
Commit
b4afcd7a
authored
8 years ago
by
Matias Alejo Garcia
Committed by
GitHub
8 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #617 from isocolsky/ref/history
Optimize tx decoration using tx proposals in tx history
parents
5d5f887e
82e02e2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/server.js
+30
-9
lib/server.js
test/integration/server.js
+4
-4
test/integration/server.js
with
34 additions
and
13 deletions
+34
-13
lib/server.js
View file @
b4afcd7a
...
...
@@ -2778,26 +2778,47 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
var
from
=
opts
.
skip
||
0
;
var
to
=
from
+
opts
.
limit
;
async.parallel([
async
.
waterfall
([
function
(
next
)
{
getNormalizedTxs
(
addresses
,
from
,
to
,
next
);
},
function(next) {
self.storage.fetchTxs(self.walletId, {}, next);
},
function(next) {
self.storage.fetchTxNotes(self.walletId, {}, next);
function
(
txs
,
next
)
{
// Fetch all proposals in [t - 7 days, t + 1 day]
var
minTs
=
_
.
min
(
txs
.
items
,
'
time
'
).
time
-
7
*
24
*
3600
;
var
maxTs
=
_
.
max
(
txs
.
items
,
'
time
'
).
time
+
1
*
24
*
3600
;
async
.
parallel
([
function
(
done
)
{
self
.
storage
.
fetchTxs
(
self
.
walletId
,
{
minTs
:
minTs
,
maxTs
:
maxTs
},
done
);
},
function
(
done
)
{
self
.
storage
.
fetchTxNotes
(
self
.
walletId
,
{
minTs
:
minTs
},
done
);
},
],
function
(
err
,
res
)
{
return
next
(
err
,
{
txs
:
txs
,
txps
:
res
[
0
],
notes
:
res
[
1
]
});
});
},
],
function
(
err
,
res
)
{
if
(
err
)
return
cb
(
err
);
var finalTxs = decorate(res
[0]
.items, addresses, res
[1], res[2]
);
var
finalTxs
=
decorate
(
res
.
txs
.
items
,
addresses
,
res
.
txps
,
res
.
notes
);
if (res
[0]
.fromCache)
if
(
res
.
txs
.
fromCache
)
log
.
debug
(
"
History from cache for:
"
,
self
.
walletId
,
from
,
to
);
return cb(null, finalTxs, !!res
[0]
.fromCache);
return
cb
(
null
,
finalTxs
,
!!
res
.
txs
.
fromCache
);
});
});
};
...
...
This diff is collapsed.
Click to expand it.
test/integration/server.js
View file @
b4afcd7a
...
...
@@ -5619,7 +5619,7 @@ describe('Wallet service', function() {
txid: '1',
confirmations: 1,
fees: 100,
time: 1,
time: 1
2345
,
inputs: [{
address: mainAddresses[0].address,
amount: 500,
...
...
@@ -5638,7 +5638,7 @@ describe('Wallet service', function() {
tx.action.should.equal('sent');
tx.amount.should.equal(400);
tx.fees.should.equal(100);
tx.time.should.equal(1);
tx.time.should.equal(1
2345
);
done();
});
});
...
...
@@ -5648,7 +5648,7 @@ describe('Wallet service', function() {
txid: '1',
confirmations: 1,
fees: 100,
time:
1
,
time:
Date.now() / 1000
,
inputs: [{
address: mainAddresses[0].address,
amount: 500,
...
...
@@ -5715,7 +5715,7 @@ describe('Wallet service', function() {
txid: txp.txid,
confirmations: 1,
fees: 5460,
time:
1
,
time:
Date.now() / 1000
,
inputs: [{
address: tx.inputs[0].address,
amount: utxos[0].satoshis,
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help