OSDN Git Service

Opz code format
authorYahtoo Ma <yahtoo.ma@gmail.com>
Thu, 30 Aug 2018 02:32:42 +0000 (10:32 +0800)
committerYahtoo Ma <yahtoo.ma@gmail.com>
Thu, 30 Aug 2018 02:33:18 +0000 (10:33 +0800)
api/api.go
api/query.go
netsync/handle.go

index d823186..09a5cc6 100644 (file)
@@ -248,8 +248,6 @@ func (a *API) buildHandler() {
        m.Handle("/submit-transaction", jsonHandler(a.submit))
        m.Handle("/estimate-transaction-gas", jsonHandler(a.estimateTxGas))
 
-       //m.Handle("/get-unconfirmed-transaction", jsonHandler(a.getUnconfirmedTx))
-       //m.Handle("/list-unconfirmed-transactions", jsonHandler(a.listUnconfirmedTxs))
        m.Handle("/decode-raw-transaction", jsonHandler(a.decodeRawTransaction))
 
        m.Handle("/get-block", jsonHandler(a.getBlock))
index 86c66fd..fb7cae1 100644 (file)
@@ -146,61 +146,11 @@ func (a *API) listTransactions(ctx context.Context, filter struct {
        return NewSuccessResponse(transactions[start:end])
 }
 
-// POST /get-unconfirmed-transaction
-//func (a *API) getUnconfirmedTx(ctx context.Context, filter struct {
-//     TxID chainjson.HexBytes `json:"tx_id"`
-//}) Response {
-//     var tmpTxID [32]byte
-//     copy(tmpTxID[:], filter.TxID[:])
-//
-//     txHash := bc.NewHash(tmpTxID)
-//     txPool := a.chain.GetTxPool()
-//     txDesc, err := txPool.GetTransaction(&txHash)
-//     if err != nil {
-//             return NewErrorResponse(err)
-//     }
-//
-//     tx := &BlockTx{
-//             ID:         txDesc.Tx.ID,
-//             Version:    txDesc.Tx.Version,
-//             Size:       txDesc.Tx.SerializedSize,
-//             TimeRange:  txDesc.Tx.TimeRange,
-//             Inputs:     []*query.AnnotatedInput{},
-//             Outputs:    []*query.AnnotatedOutput{},
-//             StatusFail: false,
-//     }
-//
-//     for i := range txDesc.Tx.Inputs {
-//             tx.Inputs = append(tx.Inputs, a.wallet.BuildAnnotatedInput(txDesc.Tx, uint32(i)))
-//     }
-//     for i := range txDesc.Tx.Outputs {
-//             tx.Outputs = append(tx.Outputs, a.wallet.BuildAnnotatedOutput(txDesc.Tx, i))
-//     }
-//
-//     return NewSuccessResponse(tx)
-//}
-
 type unconfirmedTxsResp struct {
        Total uint64    `json:"total"`
        TxIDs []bc.Hash `json:"tx_ids"`
 }
 
-// POST /list-unconfirmed-transactions
-//func (a *API) listUnconfirmedTxs(ctx context.Context) Response {
-//     txIDs := []bc.Hash{}
-//
-//     txPool := a.chain.GetTxPool()
-//     txs := txPool.GetTransactions()
-//     for _, txDesc := range txs {
-//             txIDs = append(txIDs, bc.Hash(txDesc.Tx.ID))
-//     }
-//
-//     return NewSuccessResponse(&unconfirmedTxsResp{
-//             Total: uint64(len(txIDs)),
-//             TxIDs: txIDs,
-//     })
-//}
-
 // RawTx is the tx struct for getRawTransaction
 type RawTx struct {
        ID        bc.Hash                  `json:"tx_id"`
index c35b42b..b568fde 100644 (file)
@@ -8,6 +8,7 @@ import (
        "reflect"
        "strconv"
        "strings"
+       "sync"
 
        log "github.com/sirupsen/logrus"
        "github.com/tendermint/go-crypto"
@@ -22,7 +23,6 @@ import (
        "github.com/bytom/protocol/bc/types"
        "github.com/bytom/version"
        "github.com/bytom/wallet"
-       "sync"
 )
 
 const (