Reputation: 618
If i have a business network with 4 peers joined to one channel, how to determine which peer have accepted transaction proposal, which peer have endorsed transaction and which peer have committed transaction payload to state database?
Upvotes: 0
Views: 322
Reputation: 5140
All peers either accept or reject the transaction once they process it. You can know if it was accepted by subscribing to the events and receiving updates of the status of the transaction.
The peers that endorse a transaction, put their SerializedIdentity inside the endorsement. So, to know which peers endorsed a given transaction you need to dig into the transaction with code similar to:
var block common.Block
data := block.Data.Data
env, err := utils.GetEnvelopeFromBlock(envBytes)
payload, err := utils.GetPayload(env)
tx, err := utils.GetTransaction(payload.Data)
ccActionPayload, err := utils.GetChaincodeActionPayload(tx.Actions[0].Payload)
endorsements := ccActionPayload.Action.Endorsements
var endorsers []*peer.Endorser
for _, e := range endorsements {
endorsers = append(endorsers, e.Endorser)
}
Upvotes: 1