OSDN Git Service

update req & resp
authorHAOYUatHZ <haoyu@protonmail.com>
Wed, 26 Jun 2019 07:32:22 +0000 (15:32 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Wed, 26 Jun 2019 07:32:22 +0000 (15:32 +0800)
docs/federation/README-en.md
federation/api/handler.go
federation/database/orm/cross_transaction.go

index 907ee83..00eb5ac 100644 (file)
@@ -92,7 +92,7 @@ Optional:
 - `Object` - *filter*, transactions filter.
     + Optional
         * `String` - *status*, transactions status, which can be `pending` or `completed`.
-        * `String` - *from_chain*, transactions source chain, which can be `bytom` or `vapor`.
+        * `String` - *source_chain_name*, transactions source chain, which can be `bytom` or `vapor`.
         * `String` - *source_tx_hash*, souce transaction hash string.
         * `String` - *dest_tx_hash*, destination transaction hash string.
 - `Object` - *sort*, transactions sorter.
@@ -105,7 +105,7 @@ Optional:
 
 `Object`:
 
-- `String` - *from_chain*, source chain name of the cross-chain transaction.
+- `String` - *source_chain_name*, source chain name of the cross-chain transaction.
 - `Integer` - *source_block_height*, block height of the cross-chain transaction on the source chain.
 - `String` - *source_block_hash*, block hash of the cross-chain transaction on the source chain.
 - `Integer` - *source_tx_index*, transaction index in the source block.
@@ -136,7 +136,7 @@ curl -X POST 127.0.0.1:3000/api/v1/federation/list-crosschain-txs -d '{}'
     },
     "data":[
       {
-        "from_chain":"bytom",
+        "source_chain_name":"bytom",
         "source_block_height":174,
         "source_block_hash":"569a3a5a43910ea634a947fd092bb3085359db451235ae59c20daab4e4b0d274",
         "source_tx_index":1,
index afd4bfb..01c9c0d 100644 (file)
@@ -38,8 +38,8 @@ func (s *Server) ListCrosschainTxs(c *gin.Context, listTxsReq *listCrosschainTxs
 
        txQuery := s.db.Preload("Chain").Preload("Reqs").Preload("Reqs.Asset").Where(txFilter)
        // filter direction
-       if fromChainName, err := listTxsReq.GetFilterString("from_chain"); err == nil && fromChainName != "" {
-               txQuery = txQuery.Joins("join chains on chains.id = cross_transactions.chain_id").Where("chains.name = ?", fromChainName)
+       if sourceChainName, err := listTxsReq.GetFilterString("source_chain_name"); err == nil && sourceChainName != "" {
+               txQuery = txQuery.Joins("join chains on chains.id = cross_transactions.chain_id").Where("chains.name = ?", sourceChainName)
        }
        txQuery = txQuery.Order(fmt.Sprintf("cross_transactions.source_block_height %s", listTxsReq.Sorter.Order))
        txQuery = txQuery.Order(fmt.Sprintf("cross_transactions.source_tx_index %s", listTxsReq.Sorter.Order))
index 4a327b8..e1338a2 100644 (file)
@@ -42,7 +42,7 @@ func (c *CrossTransaction) MarshalJSON() ([]byte, error) {
        }
 
        return json.Marshal(&struct {
-               FromChain         string                 `json:"from_chain"`
+               SourceChainName   string                 `json:"source_chain_name"`
                SourceBlockHeight uint64                 `json:"source_block_height"`
                SourceBlockHash   string                 `json:"source_block_hash"`
                SourceTxIndex     uint64                 `json:"source_tx_index"`
@@ -54,7 +54,7 @@ func (c *CrossTransaction) MarshalJSON() ([]byte, error) {
                Status            string                 `json:"status"`
                Reqs              []*CrossTransactionReq `json:"crosschain_requests"`
        }{
-               FromChain:         c.Chain.Name,
+               SourceChainName:   c.Chain.Name,
                SourceBlockHeight: c.SourceBlockHeight,
                SourceBlockHash:   c.SourceBlockHash,
                SourceTxIndex:     c.SourceTxIndex,