Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update bitcoin vout binding status #2104

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions app/controllers/api/v2/bitcoin_vouts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@ def verify
bitcoin_vouts = BitcoinVout.includes(:bitcoin_transaction).
where(bitcoin_transactions: { txid: previous_vout["txid"] },
bitcoin_vouts: { index: previous_vout["index"], op_return: false })
bitcoin_vouts.each do |vout|
next if vout.unbound? || vout.normal?
next unless vout.cell_output

status =
if vout.cell_output.dead?
"normal"
elsif vout.cell_output == cell_output
"binding"
else
"unbound"
end
vout.update(consumed_by:, status:)
related_cell_outputs = bitcoin_vouts.map(&:cell_output).compact
if related_cell_outputs.all?(&:live?)
bitcoin_vouts.update_all(status: "binding")
else
bitcoin_vouts.each do |vout|
next unless vout.cell_output
next if vout.normal? || vout.unbound?

status = vout.cell_output.dead? ? "normal" : "unbound"
vout.update(consumed_by:, status:)
end
end

head :no_content
Expand Down
Loading