lib/graphdb/model/tx_in.rb in bitcoin2graphdb-0.1.0 vs lib/graphdb/model/tx_in.rb in bitcoin2graphdb-0.1.1
- old
+ new
@@ -8,13 +8,16 @@
property :script_sig_hex
property :coinbase
property :sequence
has_one :out, :transaction, type: :transaction, model_class: Transaction
+ has_one :in, :out_point, origin: :out_point, model_class: TxOut
validates :sequence, :presence => true
+ after_create :add_out_point_rel
+
def self.create_from_hash(hash)
tx_in = new
tx_in.txid = hash['txid']
tx_in.vout = hash['vout']
if hash['scriptSig']
@@ -23,9 +26,18 @@
end
tx_in.coinbase = hash['coinbase']
tx_in.sequence = hash['sequence']
tx_in.save!
tx_in
+ end
+
+ private
+ def add_out_point_rel
+ tx_out = Graphdb::Model::TxOut.find_by_outpoint(self.txid, self.vout)
+ if tx_out
+ self.out_point = tx_out
+ save!
+ end
end
end
end
end
\ No newline at end of file