File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -135,13 +135,19 @@ BlockStream.prototype._getTransactions = function (txids, cb) {
135135 hash : u . toHash ( txid )
136136 } )
137137 } )
138- var message = this . peers . messages . GetData ( inventory )
139- var transactions = [ ]
138+ var peer = this . _getPeer ( )
139+ var message = peer . messages . GetData ( inventory )
140+ var remaining = txids . length
141+ var transactions = new Array ( txids . length )
140142 function onTx ( res ) {
141- var index = txids . indexOf ( res . transaction . id )
142- if ( index === - 1 ) return
143- txids . splice ( index , 1 )
144- if ( txids . length === 0 ) {
143+ var txid = u . toHash ( res . transaction . id )
144+ for ( var i = 0 ; i < txids . length ; i ++ ) {
145+ if ( txids [ i ] . compare ( txid ) === 0 ) break
146+ }
147+ if ( i === txids . length ) return
148+ transactions [ i ] = res . transaction
149+ remaining --
150+ if ( remaining === 0 ) {
145151 self . removeListener ( 'tx' , onTx )
146152 cb ( null , transactions )
147153 }
You can’t perform that action at this time.
0 commit comments