Class: Fabric::Status

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

Overview

Status of a transaction that is to be committed to the ledger.

Constant Summary collapse

TRANSACTION_STATUSES =
::Protos::TxValidationCode.constants.map(&::Protos::TxValidationCode.method(:const_get))
                                                 .to_h do |i|
  [::Protos::TxValidationCode.lookup(i), i]
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transaction_id, block_number, code) ⇒ Status

Returns a new instance of Status.



25
26
27
28
29
30
# File 'lib/fabric/entities/status.rb', line 25

def initialize(transaction_id, block_number, code)
  @transaction_id = transaction_id
  @block_number = block_number
  @code = code
  @successful = @code == TRANSACTION_STATUSES[:VALID]
end

Instance Attribute Details

#block_numberInteger (readonly)

Returns Block number in which the transaction committed.

Returns:

  • (Integer)

    Block number in which the transaction committed.



14
15
16
# File 'lib/fabric/entities/status.rb', line 14

def block_number
  @block_number
end

#codeInteger (readonly)

Returns Transaction status.

Returns:

  • (Integer)

    Transaction status



17
18
19
# File 'lib/fabric/entities/status.rb', line 17

def code
  @code
end

#successfulBoolean (readonly)

Returns true if the transaction committed successfully; otherwise false.

Returns:

  • (Boolean)

    true if the transaction committed successfully; otherwise false.



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

def successful
  @successful
end

#transaction_idString (readonly)

Returns The ID of the transaction.

Returns:

  • (String)

    The ID of the transaction.



23
24
25
# File 'lib/fabric/entities/status.rb', line 23

def transaction_id
  @transaction_id
end