Class: Fabric::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/fabric/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity, request = {}) ⇒ Transaction

Returns a new instance of Transaction.



7
8
9
10
# File 'lib/fabric/transaction.rb', line 7

def initialize(identity, request = {})
  @identity = identity
  @request = request
end

Instance Attribute Details

#identityObject (readonly)

Returns the value of attribute identity.



5
6
7
# File 'lib/fabric/transaction.rb', line 5

def identity
  @identity
end

#requestObject (readonly)

Returns the value of attribute request.



5
6
7
# File 'lib/fabric/transaction.rb', line 5

def request
  @request
end

Instance Method Details

#chaincode_actionObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fabric/transaction.rb', line 38

def chaincode_action
  action =
    Protos::ChaincodeEndorsedAction.new proposal_response_payload: responses.first.payload,
                                        endorsements: endorsements

  payload = Protos::ChaincodeProposalPayload.decode proposal.proposal.payload
  payload_no_trans = Protos::ChaincodeProposalPayload.new input: payload.input

  Protos::ChaincodeActionPayload.new action: action,
                                     chaincode_proposal_payload: payload_no_trans.to_proto
end

#endorsementsObject



24
25
26
# File 'lib/fabric/transaction.rb', line 24

def endorsements
  responses.map(&:endorsement)
end

#headerObject



28
29
30
# File 'lib/fabric/transaction.rb', line 28

def header
  proposal.header
end

#proposalObject



16
17
18
# File 'lib/fabric/transaction.rb', line 16

def proposal
  request[:proposal]
end

#responsesObject



20
21
22
# File 'lib/fabric/transaction.rb', line 20

def responses
  request[:responses]
end

#transactionObject



32
33
34
35
36
# File 'lib/fabric/transaction.rb', line 32

def transaction
  transaction_action = Protos::TransactionAction.new header: proposal.signature_header.to_proto,
                                                     payload: chaincode_action.to_proto
  Protos::Transaction.new actions: [transaction_action]
end

#tx_idObject



12
13
14
# File 'lib/fabric/transaction.rb', line 12

def tx_id
  proposal.tx_id
end