- `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.
`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.
},
"data":[
{
- "from_chain":"bytom",
+ "source_chain_name":"bytom",
"source_block_height":174,
"source_block_hash":"569a3a5a43910ea634a947fd092bb3085359db451235ae59c20daab4e4b0d274",
"source_tx_index":1,
`id` int(11) NOT NULL AUTO_INCREMENT,
`chain_id` tinyint(1) NOT NULL,
`source_block_height` int(11) NOT NULL,
+ `source_block_timestamp` int(11) NOT NULL,
`source_block_hash` char(64) NOT NULL,
`source_tx_index` int(11) NOT NULL,
`source_mux_id` char(64) NOT NULL,
`source_tx_hash` char(64) NOT NULL,
`source_raw_transaction` mediumtext NOT NULL,
`dest_block_height` int(11) DEFAULT NULL,
+ `dest_block_timestamp` int(11) DEFAULT NULL,
`dest_block_hash` char(64) DEFAULT NULL,
`dest_tx_index` int(11) DEFAULT NULL,
`dest_tx_hash` char(64) DEFAULT NULL,
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))
ID uint64 `gorm:"primary_key"`
ChainID uint64
SourceBlockHeight uint64
+ SourceBlockTimestamp uint64
SourceBlockHash string
SourceTxIndex uint64
SourceMuxID string
SourceTxHash string
SourceRawTransaction string
DestBlockHeight sql.NullInt64 `sql:"default:null"`
+ DestBlockTimestamp sql.NullInt64 `sql:"default:null"`
DestBlockHash sql.NullString `sql:"default:null"`
DestTxIndex sql.NullInt64 `sql:"default:null"`
DestTxHash sql.NullString `sql:"default:null"`
}
return json.Marshal(&struct {
- FromChain string `json:"from_chain"`
- SourceBlockHeight uint64 `json:"source_block_height"`
- SourceBlockHash string `json:"source_block_hash"`
- SourceTxIndex uint64 `json:"source_tx_index"`
- SourceTxHash string `json:"source_tx_hash"`
- DestBlockHeight uint64 `json:"dest_block_height"`
- DestBlockHash string `json:"dest_block_hash"`
- DestTxIndex uint64 `json:"dest_tx_index"`
- DestTxHash string `json:"dest_tx_hash"`
- Status string `json:"status"`
- Reqs []*CrossTransactionReq `json:"crosschain_requests"`
+ SourceChainName string `json:"source_chain_name"`
+ SourceBlockHeight uint64 `json:"source_block_height"`
+ SourceBlockTimestamp uint64 `json:"source_block_timestamp"`
+ SourceBlockHash string `json:"source_block_hash"`
+ SourceTxIndex uint64 `json:"source_tx_index"`
+ SourceTxHash string `json:"source_tx_hash"`
+ DestBlockHeight uint64 `json:"dest_block_height"`
+ DestBlockTimestamp uint64 `json:"dest_block_timestamp"`
+ DestBlockHash string `json:"dest_block_hash"`
+ DestTxIndex uint64 `json:"dest_tx_index"`
+ DestTxHash string `json:"dest_tx_hash"`
+ Status string `json:"status"`
+ Reqs []*CrossTransactionReq `json:"crosschain_requests"`
}{
- FromChain: c.Chain.Name,
- SourceBlockHeight: c.SourceBlockHeight,
- SourceBlockHash: c.SourceBlockHash,
- SourceTxIndex: c.SourceTxIndex,
- SourceTxHash: c.SourceTxHash,
- DestBlockHeight: uint64(c.DestBlockHeight.Int64),
- DestBlockHash: c.DestBlockHash.String,
- DestTxIndex: uint64(c.DestTxIndex.Int64),
- DestTxHash: c.DestTxHash.String,
- Status: status,
- Reqs: c.Reqs,
+ SourceChainName: c.Chain.Name,
+ SourceBlockHeight: c.SourceBlockHeight,
+ SourceBlockTimestamp: c.SourceBlockTimestamp,
+ SourceBlockHash: c.SourceBlockHash,
+ SourceTxIndex: c.SourceTxIndex,
+ SourceTxHash: c.SourceTxHash,
+ DestBlockHeight: uint64(c.DestBlockHeight.Int64),
+ DestBlockTimestamp: uint64(c.DestBlockTimestamp.Int64),
+ DestBlockHash: c.DestBlockHash.String,
+ DestTxIndex: uint64(c.DestTxIndex.Int64),
+ DestTxHash: c.DestTxHash.String,
+ Status: status,
+ Reqs: c.Reqs,
})
}
AssetID uint64 `json:"-"`
AssetAmount uint64 `json:"amount"`
Script string `json:"-"`
+ FromAddress string `json:"from_address"`
+ ToAddress string `json:"to_address"`
CreatedAt types.Timestamp `json:"-"`
UpdatedAt types.Timestamp `json:"-"`
ormTx := &orm.CrossTransaction{
ChainID: chain.ID,
SourceBlockHeight: block.Height,
+ SourceBlockTimestamp: block.Timestamp,
SourceBlockHash: blockHash.String(),
SourceTxIndex: txIndex,
SourceMuxID: muxID.String(),
SourceTxHash: tx.ID.String(),
SourceRawTransaction: string(rawTx),
DestBlockHeight: sql.NullInt64{Valid: false},
+ DestBlockTimestamp: sql.NullInt64{Valid: false},
DestBlockHash: sql.NullString{Valid: false},
DestTxIndex: sql.NullInt64{Valid: false},
DestTxHash: sql.NullString{Valid: false},
DestTxHash: sql.NullString{tx.ID.String(), true},
Status: common.CrossTxPendingStatus,
}).UpdateColumn(&orm.CrossTransaction{
- DestBlockHeight: sql.NullInt64{int64(block.Height), true},
- DestBlockHash: sql.NullString{blockHash.String(), true},
- DestTxIndex: sql.NullInt64{int64(txIndex), true},
- Status: common.CrossTxCompletedStatus,
+ DestBlockHeight: sql.NullInt64{int64(block.Height), true},
+ DestBlockTimestamp: sql.NullInt64{int64(block.Timestamp), true},
+ DestBlockHash: sql.NullString{blockHash.String(), true},
+ DestTxIndex: sql.NullInt64{int64(txIndex), true},
+ Status: common.CrossTxCompletedStatus,
})
if stmt.Error != nil {
return stmt.Error
DestTxHash: sql.NullString{tx.ID.String(), true},
Status: common.CrossTxPendingStatus,
}).UpdateColumn(&orm.CrossTransaction{
- DestBlockHeight: sql.NullInt64{int64(block.Height), true},
- DestBlockHash: sql.NullString{blockHash.String(), true},
- DestTxIndex: sql.NullInt64{int64(txIndex), true},
- Status: common.CrossTxCompletedStatus,
+ DestBlockHeight: sql.NullInt64{int64(block.Height), true},
+ DestBlockTimestamp: sql.NullInt64{int64(block.Timestamp), true},
+ DestBlockHash: sql.NullString{blockHash.String(), true},
+ DestTxIndex: sql.NullInt64{int64(txIndex), true},
+ Status: common.CrossTxCompletedStatus,
})
if stmt.Error != nil {
return stmt.Error
ormTx := &orm.CrossTransaction{
ChainID: chain.ID,
SourceBlockHeight: block.Height,
+ SourceBlockTimestamp: block.Timestamp,
SourceBlockHash: blockHash.String(),
SourceTxIndex: txIndex,
SourceMuxID: muxID.String(),
SourceTxHash: tx.ID.String(),
SourceRawTransaction: string(rawTx),
DestBlockHeight: sql.NullInt64{Valid: false},
+ DestBlockTimestamp: sql.NullInt64{Valid: false},
DestBlockHash: sql.NullString{Valid: false},
DestTxIndex: sql.NullInt64{Valid: false},
DestTxHash: sql.NullString{Valid: false},