Class: Fabric::Envelope
- Inherits:
-
Object
- Object
- Fabric::Envelope
- Defined in:
- lib/fabric/entities/envelope.rb
Overview
Encapsulates an Envelop protobuf message
Instance Attribute Summary collapse
-
#envelope ⇒ Common::Envelope
readonly
Transaction envelope.
Instance Method Summary collapse
-
#channel_header ⇒ Common::ChannelHeader
Returns the deserialized transaction channel header.
-
#channel_name ⇒ String
Grabs the channel_name frmo the depths of the envelope.
-
#header ⇒ Common::Header
Returns the envelope payload header.
-
#initialize(envelope) ⇒ Envelope
constructor
Creates a new Envelope instance.
-
#payload ⇒ Common::Payload
Returns the deserialized payload.
-
#payload_bytes ⇒ String
The protobuffer serialized form of the envelope payload.
-
#payload_digest ⇒ String
The digest of the payload.
-
#result ⇒ Payload
Returns the results from the transaction result payload.
-
#signature=(signature) ⇒ void
Sets the envelope signature.
-
#signed? ⇒ Boolean
Checks if the envelope has been signed.
-
#transaction ⇒ Protos::Transaction
Returns the deserialized transaction.
Constructor Details
#initialize(envelope) ⇒ Envelope
Creates a new Envelope instance.
16 17 18 |
# File 'lib/fabric/entities/envelope.rb', line 16 def initialize(envelope) @envelope = envelope end |
Instance Attribute Details
#envelope ⇒ Common::Envelope (readonly)
Returns transaction envelope.
9 10 11 |
# File 'lib/fabric/entities/envelope.rb', line 9 def envelope @envelope end |
Instance Method Details
#channel_header ⇒ Common::ChannelHeader
Returns the deserialized transaction channel header
Envelope => Payload => Header => ChannelHeader
96 97 98 |
# File 'lib/fabric/entities/envelope.rb', line 96 def channel_header @channel_header ||= Common::ChannelHeader.decode(header.channel_header) end |
#channel_name ⇒ String
Grabs the channel_name frmo the depths of the envelope.
105 106 107 |
# File 'lib/fabric/entities/envelope.rb', line 105 def channel_name channel_header.channel_id end |
#header ⇒ Common::Header
Returns the envelope payload header.
Envelope => Payload => Header
83 84 85 86 87 |
# File 'lib/fabric/entities/envelope.rb', line 83 def header raise Fabric::Error, 'Missing header' if payload.header.nil? @header ||= payload.header end |
#payload ⇒ Common::Payload
Returns the deserialized payload.
72 73 74 |
# File 'lib/fabric/entities/envelope.rb', line 72 def payload @payload ||= Common::Payload.decode(envelope.payload) end |
#payload_bytes ⇒ String
The protobuffer serialized form of the envelope payload.
34 35 36 |
# File 'lib/fabric/entities/envelope.rb', line 34 def payload_bytes envelope.payload end |
#payload_digest ⇒ String
The digest of the payload.
43 44 45 |
# File 'lib/fabric/entities/envelope.rb', line 43 def payload_digest Fabric.crypto_suite.digest(envelope.payload) end |
#result ⇒ Payload
Returns the results from the transaction result payload.
63 64 65 |
# File 'lib/fabric/entities/envelope.rb', line 63 def result @result ||= parse_result_from_payload end |
#signature=(signature) ⇒ void
This method returns an undefined value.
Sets the envelope signature.
54 55 56 |
# File 'lib/fabric/entities/envelope.rb', line 54 def signature=(signature) envelope.signature = signature end |
#signed? ⇒ Boolean
Checks if the envelope has been signed.
25 26 27 |
# File 'lib/fabric/entities/envelope.rb', line 25 def signed? !envelope.signature.empty? end |
#transaction ⇒ Protos::Transaction
Returns the deserialized transaction
114 115 116 |
# File 'lib/fabric/entities/envelope.rb', line 114 def transaction @transaction ||= Protos::Transaction.decode(payload.data) end |