bsv-wallet-postgres 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d007064fafd9853cdc8696661ef969ddef47c0eeb9a1c0451acc7793a67fd1f1
|
|
4
|
+
data.tar.gz: 21335a50ff36fbaf390ddfe558e5efbb67514ae4da5189f0b6b9c0a2a4b7c2e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd2578b3303a8b2a1407c51366aa9a30e78d28e38875fb5f229d5408a76f02a6ecbcaddfa3e1a01d770257e0c3e3f18ea15a257097cd5c5cc5444b4d4501d382
|
|
7
|
+
data.tar.gz: e296a4026b3bddedd41cd572ad627c279ee9aaf16ca4d7ee061c11718a1b81e27cb76e9583dda0012bf55cdfaf7c28a34791c28306951802879c76463efd7157
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to the `bsv-wallet-postgres` gem are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
6
|
and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 0.3.1 — 2026-04-12
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- `update_action_status` now scopes to a single row by primary key, preventing unintended multi-row updates when duplicate txids exist
|
|
12
|
+
- Added migration 005: unique index on `wallet_actions.txid` enforcing one action per transaction
|
|
13
|
+
|
|
8
14
|
## 0.3.0 — 2026-04-12
|
|
9
15
|
|
|
10
16
|
### Added
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Add a unique index on wallet_actions.txid.
|
|
4
|
+
#
|
|
5
|
+
# Within a single wallet there should be at most one action per transaction.
|
|
6
|
+
# Without this constraint, concurrent inserts or retries could create duplicate
|
|
7
|
+
# rows sharing the same txid, causing +update_action_status+ to update multiple
|
|
8
|
+
# rows unintentionally.
|
|
9
|
+
#
|
|
10
|
+
# The index also accelerates the +where(txid:)+ lookups performed by
|
|
11
|
+
# +update_action_status+ and +delete_action+.
|
|
12
|
+
#
|
|
13
|
+
# === Backward compatibility
|
|
14
|
+
#
|
|
15
|
+
# The migration will fail if duplicate txids already exist in the table. Clean
|
|
16
|
+
# up any duplicates before running this migration:
|
|
17
|
+
#
|
|
18
|
+
# DELETE FROM wallet_actions a
|
|
19
|
+
# USING wallet_actions b
|
|
20
|
+
# WHERE a.id > b.id AND a.txid = b.txid;
|
|
21
|
+
Sequel.migration do
|
|
22
|
+
change do
|
|
23
|
+
alter_table(:wallet_actions) do
|
|
24
|
+
add_index :txid, unique: true, name: :wallet_actions_txid_unique
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -103,16 +103,20 @@ module BSV
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def update_action_status(txid, new_status)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
# Fetch by txid first, then update by primary key so only exactly one
|
|
107
|
+
# row is targeted. The unique index on txid makes this unambiguous, but
|
|
108
|
+
# scoping to the id column makes the intent explicit and is safe even
|
|
109
|
+
# on databases where the migration has not yet been applied.
|
|
110
|
+
row = @db[:wallet_actions].where(txid: txid).first
|
|
111
|
+
raise WalletError, "Action not found: #{txid}" unless row
|
|
112
|
+
|
|
113
|
+
@db[:wallet_actions].where(id: row[:id]).update(
|
|
110
114
|
data: Sequel.lit(
|
|
111
115
|
"data || jsonb_build_object('status', ?)",
|
|
112
116
|
new_status
|
|
113
117
|
)
|
|
114
118
|
)
|
|
115
|
-
symbolise_keys(
|
|
119
|
+
symbolise_keys(@db[:wallet_actions].where(id: row[:id]).first[:data])
|
|
116
120
|
end
|
|
117
121
|
|
|
118
122
|
def delete_action(txid)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bsv-wallet-postgres
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Simon Bettison
|
|
@@ -71,6 +71,7 @@ files:
|
|
|
71
71
|
- lib/bsv/wallet_postgres/migrations/002_add_output_state.rb
|
|
72
72
|
- lib/bsv/wallet_postgres/migrations/003_add_wallet_settings.rb
|
|
73
73
|
- lib/bsv/wallet_postgres/migrations/004_add_pending_metadata.rb
|
|
74
|
+
- lib/bsv/wallet_postgres/migrations/005_add_txid_unique_index.rb
|
|
74
75
|
- lib/bsv/wallet_postgres/postgres_store.rb
|
|
75
76
|
- lib/bsv/wallet_postgres/version.rb
|
|
76
77
|
homepage: https://github.com/sgbett/bsv-ruby-sdk
|