@@ -529,32 +529,32 @@ func buildTransactionQuery(tf idb.TransactionFilter) (query string, whereArgs []
529529 whereArgs = append (whereArgs , addrBase64 )
530530 partNumber ++
531531 }
532- if tf .AddressRole & idb .AddressRoleReceiver != 0 && tf . TypeEnum == idb . TypeEnumPay {
532+ if tf .AddressRole & idb .AddressRoleReceiver != 0 {
533533 roleparts = append (roleparts , fmt .Sprintf ("t.txn -> 'txn' ->> 'rcv' = $%d" , partNumber ))
534534 whereArgs = append (whereArgs , addrBase64 )
535535 partNumber ++
536536 }
537- if tf .AddressRole & idb .AddressRoleCloseRemainderTo != 0 && tf . TypeEnum == idb . TypeEnumPay {
537+ if tf .AddressRole & idb .AddressRoleCloseRemainderTo != 0 {
538538 roleparts = append (roleparts , fmt .Sprintf ("t.txn -> 'txn' ->> 'close' = $%d" , partNumber ))
539539 whereArgs = append (whereArgs , addrBase64 )
540540 partNumber ++
541541 }
542- if tf .AddressRole & idb .AddressRoleAssetSender != 0 && tf . TypeEnum == idb . TypeEnumAssetTransfer {
542+ if tf .AddressRole & idb .AddressRoleAssetSender != 0 {
543543 roleparts = append (roleparts , fmt .Sprintf ("t.txn -> 'txn' ->> 'asnd' = $%d" , partNumber ))
544544 whereArgs = append (whereArgs , addrBase64 )
545545 partNumber ++
546546 }
547- if tf .AddressRole & idb .AddressRoleAssetReceiver != 0 && tf . TypeEnum == idb . TypeEnumAssetTransfer {
547+ if tf .AddressRole & idb .AddressRoleAssetReceiver != 0 {
548548 roleparts = append (roleparts , fmt .Sprintf ("t.txn -> 'txn' ->> 'arcv' = $%d" , partNumber ))
549549 whereArgs = append (whereArgs , addrBase64 )
550550 partNumber ++
551551 }
552- if tf .AddressRole & idb .AddressRoleAssetCloseTo != 0 && tf . TypeEnum == idb . TypeEnumAssetTransfer {
552+ if tf .AddressRole & idb .AddressRoleAssetCloseTo != 0 {
553553 roleparts = append (roleparts , fmt .Sprintf ("t.txn -> 'txn' ->> 'aclose' = $%d" , partNumber ))
554554 whereArgs = append (whereArgs , addrBase64 )
555555 partNumber ++
556556 }
557- if tf .AddressRole & idb .AddressRoleFreeze != 0 && tf . TypeEnum == idb . TypeEnumAssetFreeze {
557+ if tf .AddressRole & idb .AddressRoleFreeze != 0 {
558558 roleparts = append (roleparts , fmt .Sprintf ("t.txn -> 'txn' ->> 'fadd' = $%d" , partNumber ))
559559 whereArgs = append (whereArgs , addrBase64 )
560560 partNumber ++
@@ -576,25 +576,15 @@ func buildTransactionQuery(tf idb.TransactionFilter) (query string, whereArgs []
576576 }
577577 if ! tf .BeforeTime .IsZero () {
578578 convertedTime := tf .BeforeTime .In (time .UTC )
579- if joinParticipation {
580- whereParts = append (whereParts , fmt .Sprintf ("p.round <= (" +
581- "SELECT round from block_header WHERE realtime < $%d ORDER BY realtime DESC LIMIT 1)" , partNumber ))
582- } else {
583- whereParts = append (whereParts , fmt .Sprintf ("t.round <= (" +
584- "SELECT round from block_header WHERE realtime < $%d ORDER BY realtime DESC LIMIT 1)" , partNumber ))
585- }
579+ whereParts = append (whereParts , fmt .Sprintf ("t.round <= (" +
580+ "SELECT round from block_header WHERE realtime < $%d ORDER BY realtime DESC LIMIT 1)" , partNumber ))
586581 whereArgs = append (whereArgs , convertedTime )
587582 partNumber ++
588583 }
589584 if ! tf .AfterTime .IsZero () {
590585 convertedTime := tf .AfterTime .In (time .UTC )
591- if joinParticipation {
592- whereParts = append (whereParts , fmt .Sprintf ("p.round >= (" +
593- "SELECT round from block_header WHERE realtime > $%d ORDER BY realtime ASC LIMIT 1)" , partNumber ))
594- } else {
595- whereParts = append (whereParts , fmt .Sprintf ("t.round >= (" +
596- "SELECT round from block_header WHERE realtime > $%d ORDER BY realtime ASC LIMIT 1)" , partNumber ))
597- }
586+ whereParts = append (whereParts , fmt .Sprintf ("t.round >= (" +
587+ "SELECT round from block_header WHERE realtime > $%d ORDER BY realtime ASC LIMIT 1)" , partNumber ))
598588 whereArgs = append (whereArgs , convertedTime )
599589 partNumber ++
600590 }
@@ -996,7 +986,6 @@ finish:
996986
997987func buildBlockHeadersQuery (bf idb.BlockHeaderFilter ) (query string , err error ) {
998988
999- participationFilter := false
1000989 // Build the terms for the WHERE clause based on the input parameters
1001990 var whereTerms []string
1002991 {
@@ -1055,7 +1044,6 @@ func buildBlockHeadersQuery(bf idb.BlockHeaderFilter) (query string, err error)
10551044 whereTerms ,
10561045 fmt .Sprintf ("( (bh.header->'prp') IS NOT NULL AND ((bh.header->'prp')::TEXT IN (%s)) )" , strings .Join (ps , "," )),
10571046 )
1058- participationFilter = true
10591047 }
10601048 if len (bf .ExpiredParticipationAccounts ) > 0 {
10611049 var es []string
@@ -1066,7 +1054,6 @@ func buildBlockHeadersQuery(bf idb.BlockHeaderFilter) (query string, err error)
10661054 whereTerms ,
10671055 fmt .Sprintf ("( (bh.header->'partupdrmv') IS NOT NULL AND (bh.header->'partupdrmv') ?| array[%s] )" , strings .Join (es , "," )),
10681056 )
1069- participationFilter = true
10701057 }
10711058 if len (bf .AbsentParticipationAccounts ) > 0 {
10721059 var as []string
@@ -1077,7 +1064,6 @@ func buildBlockHeadersQuery(bf idb.BlockHeaderFilter) (query string, err error)
10771064 whereTerms ,
10781065 fmt .Sprintf ("( (bh.header->'partupdabs') IS NOT NULL AND (bh.header->'partupdabs') ?| array[%s] )" , strings .Join (as , "," )),
10791066 )
1080- participationFilter = true
10811067 }
10821068
10831069 }
@@ -1087,20 +1073,13 @@ func buildBlockHeadersQuery(bf idb.BlockHeaderFilter) (query string, err error)
10871073 if len (whereTerms ) > 0 {
10881074 whereClause = "WHERE " + strings .Join (whereTerms , " AND " )
10891075 }
1090-
1091- orderBy := "bh.round ASC"
1092- if participationFilter {
1093- //Postgres hack to force indexes other than primary
1094- orderBy = "bh.round+0 ASC"
1095- }
1096-
10971076 tmpl := `
10981077 SELECT bh.header
10991078 FROM block_header bh
11001079 %s
1101- ORDER BY %s
1080+ ORDER BY bh.round ASC
11021081 LIMIT %d`
1103- query = fmt .Sprintf (tmpl , whereClause , orderBy , bf .Limit )
1082+ query = fmt .Sprintf (tmpl , whereClause , bf .Limit )
11041083
11051084 return query , nil
11061085}
0 commit comments