@@ -105,8 +105,8 @@ export default class TransactionsService {
105105 return base
106106 }
107107 if ( type === SearchType . Address ) {
108- const lockHash = await LockUtils . addressToLockHash ( value )
109- return [ 'input.lockHash = :lockHash OR output.lockHash = :lockHash ' , { lockHash } ]
108+ const lockHashes : string [ ] = await LockUtils . addressToAllLockHashes ( value )
109+ return [ 'input.lockHash IN (:...lockHashes) OR output.lockHash IN (:...lockHashes) ' , { lockHashes } ]
110110 }
111111 if ( type === SearchType . TxHash ) {
112112 return [ `${ base [ 0 ] } AND tx.hash = :hash` , { lockHashes : params . lockHashes , hash : value } ]
@@ -225,12 +225,7 @@ export default class TransactionsService {
225225 params : TransactionsByAddressesParam ,
226226 searchValue : string = ''
227227 ) : Promise < PaginationResult < Transaction > > => {
228- const lockHashes : string [ ] = await Promise . all (
229- params . addresses . map ( async addr => {
230- const lockHash : string = await LockUtils . addressToLockHash ( addr )
231- return lockHash
232- } )
233- )
228+ const lockHashes : string [ ] = await LockUtils . addressesToAllLockHashes ( params . addresses )
234229
235230 return TransactionsService . getAll (
236231 {
@@ -246,13 +241,12 @@ export default class TransactionsService {
246241 params : TransactionsByPubkeysParams ,
247242 searchValue : string = ''
248243 ) : Promise < PaginationResult < Transaction > > => {
249- const lockHashes : string [ ] = await Promise . all (
250- params . pubkeys . map ( async pubkey => {
251- const addr = core . utils . pubkeyToAddress ( pubkey )
252- const lockHash = await LockUtils . addressToLockHash ( addr )
253- return lockHash
254- } )
255- )
244+ const addresses : string [ ] = params . pubkeys . map ( pubkey => {
245+ const addr = core . utils . pubkeyToAddress ( pubkey )
246+ return addr
247+ } )
248+
249+ const lockHashes = await LockUtils . addressesToAllLockHashes ( addresses )
256250
257251 return TransactionsService . getAll (
258252 {
@@ -580,27 +574,30 @@ export default class TransactionsService {
580574 }
581575
582576 // tx count with one lockHash and status
583- public static getCountByLockHashAndStatus = async (
584- lockHash : string ,
577+ public static getCountByLockHashesAndStatus = async (
578+ lockHashes : string [ ] ,
585579 status : TransactionStatus [ ]
586580 ) : Promise < number > => {
587581 const count : number = await getConnection ( )
588582 . getRepository ( TransactionEntity )
589583 . createQueryBuilder ( 'tx' )
590584 . leftJoinAndSelect ( 'tx.inputs' , 'input' )
591585 . leftJoinAndSelect ( 'tx.outputs' , 'output' )
592- . where ( `(input.lockHash = :lockHash OR output.lockHash = :lockHash) AND tx.status IN (:...status)` , {
593- lockHash,
594- status,
595- } )
586+ . where (
587+ `(input.lockHash IN (:...lockHashes) OR output.lockHash IN (:...lockHashes)) AND tx.status IN (:...status)` ,
588+ {
589+ lockHashes,
590+ status,
591+ }
592+ )
596593 . getCount ( )
597594
598595 return count
599596 }
600597
601598 public static getCountByAddressAndStatus = async ( address : string , status : TransactionStatus [ ] ) : Promise < number > => {
602- const lockHash : string = await LockUtils . addressToLockHash ( address )
603- return TransactionsService . getCountByLockHashAndStatus ( lockHash , status )
599+ const lockHashes : string [ ] = await LockUtils . addressToAllLockHashes ( address )
600+ return TransactionsService . getCountByLockHashesAndStatus ( lockHashes , status )
604601 }
605602
606603 public static pendings = async ( ) : Promise < TransactionEntity [ ] > => {
0 commit comments