Golang implemented sidechain for Bytom
Revision | c68c98d1d4801d350552bbbc9f8cc1a1e7cd1685 (tree) |
---|---|
Time | 2019-06-26 19:50:32 |
Author | HAOYUatHZ <haoyu@prot...> |
Commiter | HAOYUatHZ |
add address filter
@@ -91,6 +91,7 @@ Optional: | ||
91 | 91 | + Optional |
92 | 92 | * `String` - *status*, transactions status, which can be `pending` or `completed`. |
93 | 93 | * `String` - *source_chain_name*, transactions source chain, which can be `bytom` or `vapor`. |
94 | + * `String` - *address*, filter cross-chain requests by address. The address can be either a mainchain or a sidechain one. Note that other requests in such a transaction will also be filtered. | |
94 | 95 | * `String` - *source_tx_hash*, souce transaction hash string. |
95 | 96 | * `String` - *dest_tx_hash*, destination transaction hash string. |
96 | 97 | - `Object` - *sort*, transactions sorter. |
@@ -41,6 +41,14 @@ func (s *Server) ListCrosschainTxs(c *gin.Context, listTxsReq *listCrosschainTxs | ||
41 | 41 | if sourceChainName, err := listTxsReq.GetFilterString("source_chain_name"); err == nil && sourceChainName != "" { |
42 | 42 | txQuery = txQuery.Joins("join chains on chains.id = cross_transactions.chain_id").Where("chains.name = ?", sourceChainName) |
43 | 43 | } |
44 | + | |
45 | + // filter address | |
46 | + if address, err := listTxsReq.GetFilterString("address"); err == nil && address != "" { | |
47 | + txQuery = txQuery.Joins("join cross_transaction_reqs on cross_transaction_reqs.cross_transaction_id = cross_transactions.id"). | |
48 | + Where("cross_transaction_reqs.from_address = ? or cross_transaction_reqs.to_address = ?", address, address) | |
49 | + } | |
50 | + | |
51 | + // sorter order | |
44 | 52 | txQuery = txQuery.Order(fmt.Sprintf("cross_transactions.source_block_height %s", listTxsReq.Sorter.Order)) |
45 | 53 | txQuery = txQuery.Order(fmt.Sprintf("cross_transactions.source_tx_index %s", listTxsReq.Sorter.Order)) |
46 | 54 | if err := txQuery.Offset(query.Start).Limit(query.Limit).Find(&ormTxs).Error; err != nil { |