Skip to content

Commit 2705995

Browse files
committed
better ordering of txs
1 parent d987571 commit 2705995

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/controllers/addresses.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ exports.multitxs = function(req, res, next) {
143143
if (to > nbTxs) to = nbTxs;
144144

145145
txs.sort(function(a, b) {
146-
return (b.firstSeenTs || b.ts) - (a.firstSeenTs || a.ts);
146+
var b = (b.firstSeenTs || b.ts)+ b.txid;
147+
var a = (a.firstSeenTs || a.ts)+ a.txid;
148+
if (a > b) return -1;
149+
if (a < b) return 1;
150+
return 0;
147151
});
148152
txs = txs.slice(from, to);
149153

@@ -164,7 +168,7 @@ exports.multitxs = function(req, res, next) {
164168
tx.info.firstSeenTs = tx2.firstSeenTs;
165169

166170
txIndex[tx.txid].info = tx.info;
167-
} else {
171+
} else {
168172
// TX no longer available
169173
txIndex[tx2.txid].info = {
170174
txid: tx2.txid,
@@ -180,7 +184,7 @@ exports.multitxs = function(req, res, next) {
180184

181185
// It could be that a txid is stored at an address but it is
182186
// no longer at bitcoind (for example a double spend)
183-
187+
184188
var transactions = _.compact(_.pluck(txs, 'info'));
185189
transactions = {
186190
totalItems: nbTxs,

0 commit comments

Comments
 (0)