我怎么知道,Hyperledger Fabric中的事务进行了哪个Peer?

I am working on getting a transaction id info, which will give the peer details for the transaction. Currently, I am able to retrieve the History for a key, which gives me the list of transaction committed to that key.

MyCode:

historyRes, err := stub.GetHistoryForKey(userNameIndexKey)

if err != nil {
    return shim.Error(fmt.Sprintf("Unable to get History key from the ledger: %v", err))
}

for historyRes.HasNext() {

    history, errIt := historyRes.Next()

    if errIt != nil {
        return shim.Error(fmt.Sprintf("Unable to retrieve history in the ledger: %v", errIt))
    }

    deleted := history.GetIsDelete()

    ds := strconv.FormatBool(deleted)

    fmt.Println("History TxId = "+history.GetTxId()+" --  Delete = "+ds)
 }

Output

History TxId = 78c8d17c668d7a9df8373fd85df4fc398388976a1c642753bbf73abc5c648dd8 -- Deleted = false

History TxId = 102bbb64a7ca93367334a8c98f1f7be17e6a8d5277f0167c73da47072d302fa3 -- Deleted = true

But I don't know, which peer did this transaction. Is there any API available in fabric-sdk-go to retrieve peer info for a transaction id.

please suggest me some solution.

The call stub.GetHistoryForKey(userNameIndexKey) will query the state database and not the ledger (channel). The information about the identity who made the transaction is stored in the block.

I have implemented the same thing with NodeJS SDK. However, Go SDK too contains similar API calls. The following steps worked for me:

  1. Using your SDK, get the transactionId
  2. Use the SDK function for querying block by transactionId. References here.
  3. At this step, you'll get the block. Now the identity of the submitter is located within this block. Hints: Payload -> Header -> Signature Header -> Creater -> IdBytes.
  4. These identity bytes are the X509 certs of the submitter. You can read the certificate info to find out which member did submit this transaction. The subject and OUs will indicate the Organization of the peer that did the transaction.