OSDN Git Service

get-block response transaction add source_id
authoroysheng <oysheng@bytom.io>
Wed, 23 May 2018 08:38:24 +0000 (16:38 +0800)
committeroysheng <oysheng@bytom.io>
Wed, 23 May 2018 08:38:24 +0000 (16:38 +0800)
api/block_retrieve.go

index bf0c772..192e579 100644 (file)
@@ -31,6 +31,7 @@ type BlockTx struct {
        Inputs     []*query.AnnotatedInput  `json:"inputs"`
        Outputs    []*query.AnnotatedOutput `json:"outputs"`
        StatusFail bool                     `json:"status_fail"`
+       SourceID   bc.Hash                  `json:"source_id"`
 }
 
 // BlockReq is used to handle getBlock req
@@ -107,6 +108,15 @@ func (a *API) getBlock(ins BlockReq) Response {
                        NewSuccessResponse(resp)
                }
 
+               for id, e := range orig.Entries {
+                       switch e.(type) {
+                       case *bc.Mux:
+                               tx.SourceID = id
+                       default:
+                               continue
+                       }
+               }
+
                for i := range orig.Inputs {
                        tx.Inputs = append(tx.Inputs, a.wallet.BuildAnnotatedInput(orig, uint32(i)))
                }