Skip to content

Commit 7622ece

Browse files
authored
Merge pull request #170 from fluree/task/remove-deprecations
Remove deprecations & replace db with ledger everywhere appropriate
2 parents 1eae7e2 + 2a612c6 commit 7622ece

25 files changed

+316
-309
lines changed

docs/fluree.db.api.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
- :doc - Optional doc string about this db.
158158
- :fork - If forking an existing db, ref to db (actual identity, not db-ident). Must exist in network db.
159159
- :forkBlock - If fork is provided, optionally provide the block to fork at. Defaults to latest known.
160-
- :persistResp - Respond immediately once persisted with the dbid, don't wait for transaction to be finished
160+
- :persistResp - Respond immediately once persisted with the ledger-id, don't wait for transaction to be finished
161161
</pre></div></div><div class="public anchor" id="var-new-ledger-async"><h3>new-ledger-async</h3><div class="usage"><code>(new-ledger-async conn ledger)</code><code>(new-ledger-async conn ledger opts)</code></div><div class="doc"><pre class="plaintext">Attempts to create new ledger with the given ledger name (ex. `fluree/example` or `:fluree/example`).
162162

163163
A successful result will kick off a process on the ledger server(s) to bootstrap.
@@ -172,7 +172,7 @@
172172
- :doc - Optional doc string about this db.
173173
- :fork - If forking an existing db, ref to db (actual identity, not db-ident). Must exist in network db.
174174
- :forkBlock - If fork is provided, optionally provide the block to fork at. Defaults to latest known.
175-
- :persistResp - Respond immediately once persisted with the dbid, don't wait for transaction to be finished
175+
- :persistResp - Respond immediately once persisted with the ledger-id, don't wait for transaction to be finished
176176
</pre></div></div><div class="public anchor" id="var-new-private-key"><h3>new-private-key</h3><h4 class="deprecated">deprecated</h4><div class="usage"><code>(new-private-key)</code></div><div class="doc"><pre class="plaintext">DEPRECATED: use fluree.db.api.auth/new-private-key instead.
177177
</pre></div></div><div class="public anchor" id="var-predicate-id"><h3>predicate-id</h3><div class="usage"><code>(predicate-id db predicate)</code></div><div class="doc"><pre class="plaintext">Returns promise containing predicate id given a predicate name, or predicate id.
178178
If predicate doesn't exist, returns nil.</pre></div></div><div class="public anchor" id="var-predicate-name"><h3>predicate-name</h3><div class="usage"><code>(predicate-name db predicate-name)</code></div><div class="doc"><pre class="plaintext">Returns promise containing predicate name given predicate id.
@@ -219,8 +219,8 @@
219219
- testnet/$testledger - look for a ledger with id testledger on network testnet (skip alias lookup).</pre></div></div><div class="public anchor" id="var-search"><h3>search</h3><div class="usage"><code>(search db flake-parts)</code></div><div class="doc"><pre class="plaintext">Returns a promise containing search results of flake parts (fparts).
220220
</pre></div></div><div class="public anchor" id="var-search-async"><h3>search-async</h3><div class="usage"><code>(search-async db flake-parts)</code></div><div class="doc"><pre class="plaintext">Performs a search for matching flakes, returns a core async promise channel.
221221
</pre></div></div><div class="public anchor" id="var-session"><h3>session</h3><div class="usage"><code>(session conn ledger)</code></div><div class="doc"><pre class="plaintext">Returns actual session object for a given ledger.
222-
</pre></div></div><div class="public anchor" id="var-set-default-key"><h3>set-default-key</h3><h4 class="deprecated">deprecated</h4><div class="usage"><code>(set-default-key conn private-key)</code><code>(set-default-key conn network private-key)</code><code>(set-default-key conn network dbid private-key)</code><code>(set-default-key conn network dbid private-key opts)</code></div><div class="doc"><pre class="plaintext">DEPRECATED: use fluree.db.api.auth/set-default-key instead.
223-
</pre></div></div><div class="public anchor" id="var-set-default-key-async"><h3>set-default-key-async</h3><h4 class="deprecated">deprecated</h4><div class="usage"><code>(set-default-key-async conn private-key)</code><code>(set-default-key-async conn network private-key)</code><code>(set-default-key-async conn network dbid private-key)</code><code>(set-default-key-async conn network dbid private-key opts)</code></div><div class="doc"><pre class="plaintext">DEPRECATED: use fluree.db.api.auth/set-default-key-async instead.
222+
</pre></div></div><div class="public anchor" id="var-set-default-key"><h3>set-default-key</h3><h4 class="deprecated">deprecated</h4><div class="usage"><code>(set-default-key conn private-key)</code><code>(set-default-key conn network private-key)</code><code>(set-default-key conn network ledger-id private-key)</code><code>(set-default-key conn network ledger-id private-key opts)</code></div><div class="doc"><pre class="plaintext">DEPRECATED: use fluree.db.api.auth/set-default-key instead.
223+
</pre></div></div><div class="public anchor" id="var-set-default-key-async"><h3>set-default-key-async</h3><h4 class="deprecated">deprecated</h4><div class="usage"><code>(set-default-key-async conn private-key)</code><code>(set-default-key-async conn network private-key)</code><code>(set-default-key-async conn network ledger-id private-key)</code><code>(set-default-key-async conn network ledger-id private-key opts)</code></div><div class="doc"><pre class="plaintext">DEPRECATED: use fluree.db.api.auth/set-default-key-async instead.
224224
</pre></div></div><div class="public anchor" id="var-sign"><h3>sign</h3><h4 class="deprecated">deprecated</h4><div class="usage"><code>(sign message private-key)</code></div><div class="doc"><pre class="plaintext">DEPRECATED: use fluree.db.api.auth/sign instead.
225225
</pre></div></div><div class="public anchor" id="var-sparql"><h3>sparql</h3><div class="usage"><code>(sparql db sparql-str)</code><code>(sparql db sparql-str opts)</code></div><div class="doc"><pre class="plaintext">Execute an sparql query against a specified database. Returns a promise of the query results.
226226
</pre></div></div><div class="public anchor" id="var-sparql-async"><h3>sparql-async</h3><div class="usage"><code>(sparql-async db sparql-str)</code><code>(sparql-async db sparql-str opts)</code></div><div class="doc"><pre class="plaintext">Exceute a sparql query against a specified database. Returns a core async channel,
@@ -261,7 +261,7 @@
261261
Note new ledgers are issued as a command, and auth/signature should have proper authority on ledger servers.
262262
{:type new-ledger - command type is required on all commands
263263
:ledger testnet/myledger - ledger name - as network/ledger
264-
:fork testnet/forkdb - optional name of db to fork, if forking. Use testnet/$forkdb to peg to a dbid
264+
:fork testnet/forkdb - optional name of db to fork, if forking. Use testnet/$forkdb to peg to a ledger-id
265265
:forkBlock 42 - if forking a db, optionally provides a block to fork at, else will default to current block
266266
:auth ABC12345676 - only required if using an authority's signature
267267
:fuel 10000 - max fuel to spend, only required if enforcing fuel limits. tx will fail if auth doesn't have this much fuel avail. Will fail if all fuel is consumed. Unused fuel will not be debited.

js-packages/nodejs/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"name" : "@fluree/flureenjs",
66
"preferGlobal" : false,
77
"keywords" : [ "fluree", "nodejs" ],
8-
"types" : "flureenjs.d.ts",
98
"author" : "Fluree PBC (https://flur.ee)",
109
"requires" : true,
1110
"version" : "2.0.0-alpha1",
@@ -21,4 +20,4 @@
2120
"utf-8-validate" : "^5.0.9",
2221
"@cljs-oss/module-deps" : "^1.1.1"
2322
}
24-
}
23+
}

src-cljs/flureedb.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
- :doc - Optional doc string about this db.
249249
- :fork - If forking an existing db, ref to db (actual identity, not db-ident). Must exist in network db.
250250
- :forkBlock - If fork is provided, optionally provide the block to fork at. Defaults to latest known.
251-
- :persistResp - Respond immediately once persisted with the dbid, don't wait for transaction to be finished
251+
- :persistResp - Respond immediately once persisted with the ledger-id, don't wait for transaction to be finished
252252
- :jwt - token for Fluree On-Demand access
253253
"
254254
([conn ledger] (new-ledger conn ledger nil))

src-nodejs/flureenjs.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@
377377
["_auth/id" (-> (conn-handler/validate-token conn jwt)
378378
:sub)]))
379379
perm-db (-> (<? (ledger/db conn ledger (assoc opts :auth auth')))
380-
(assoc :conn conn :network network :dbid ledger-id))]
380+
(assoc :conn conn :network network :ledger-id ledger-id))]
381381
(async/put! pc perm-db))
382382
(catch :default e
383383
(log/error e)
@@ -566,7 +566,7 @@
566566
- :doc - Optional doc string about this db.
567567
- :fork - If forking an existing db, ref to db (actual identity, not db-ident). Must exist in network db.
568568
- :forkBlock - If fork is provided, optionally provide the block to fork at. Defaults to latest known.
569-
- :persistResp - Respond immediately once persisted with the dbid, don't wait for transaction to be finished
569+
- :persistResp - Respond immediately once persisted with the ledger-id, don't wait for transaction to be finished
570570
"
571571
([conn ledger] (newLedger conn ledger nil))
572572
([conn ledger opts]

src/fluree/db/api.clj

+10-10
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@
7272
"DEPRECATED: use fluree.db.api.auth/set-default-key-async instead."
7373
([conn private-key] (set-default-key-async conn nil nil private-key nil))
7474
([conn network private-key] (set-default-key-async conn network nil private-key nil))
75-
([conn network dbid private-key] (set-default-key-async conn network dbid private-key nil))
76-
([conn network dbid private-key opts]
75+
([conn network ledger-id private-key] (set-default-key-async conn network ledger-id private-key nil))
76+
([conn network ledger-id private-key opts]
7777
(log/warn "set-default-key-async DEPRECATED - use fluree.db.api.auth/set-default-key-async instead")
78-
(auth-api/set-default-key-async conn network dbid private-key opts)))
78+
(auth-api/set-default-key-async conn network ledger-id private-key opts)))
7979

8080
(defn ^:deprecated set-default-key
8181
"DEPRECATED: use fluree.db.api.auth/set-default-key instead."
8282
([conn private-key] (set-default-key-async conn nil nil private-key nil))
8383
([conn network private-key] (set-default-key-async conn network nil private-key nil))
84-
([conn network dbid private-key] (set-default-key-async conn network dbid private-key nil))
85-
([conn network dbid private-key opts]
84+
([conn network ledger-id private-key] (set-default-key-async conn network ledger-id private-key nil))
85+
([conn network ledger-id private-key opts]
8686
(log/warn "set-default-key DEPRECATED - use fluree.db.api.auth/set-default-key instead")
87-
(auth-api/set-default-key conn network dbid private-key opts)))
87+
(auth-api/set-default-key conn network ledger-id private-key opts)))
8888

8989
(defn account-id
9090
"INTERNAL USE ONLY
@@ -226,7 +226,7 @@
226226
Note new ledgers are issued as a command, and auth/signature should have proper authority on ledger servers.
227227
{:type new-ledger - command type is required on all commands
228228
:ledger testnet/myledger - ledger name - as network/ledger
229-
:fork testnet/forkdb - optional name of db to fork, if forking. Use testnet/$forkdb to peg to a dbid
229+
:fork testnet/forkdb - optional name of db to fork, if forking. Use testnet/$forkdb to peg to a ledger-id
230230
:forkBlock 42 - if forking a db, optionally provides a block to fork at, else will default to current block
231231
:auth ABC12345676 - only required if using an authority's signature
232232
:fuel 10000 - max fuel to spend, only required if enforcing fuel limits. tx will fail if auth doesn't have this much fuel avail. Will fail if all fuel is consumed. Unused fuel will not be debited.
@@ -256,7 +256,7 @@
256256
- :doc - Optional doc string about this db.
257257
- :fork - If forking an existing db, ref to db (actual identity, not db-ident). Must exist in network db.
258258
- :forkBlock - If fork is provided, optionally provide the block to fork at. Defaults to latest known.
259-
- :persistResp - Respond immediately once persisted with the dbid, don't wait for transaction to be finished
259+
- :persistResp - Respond immediately once persisted with the ledger-id, don't wait for transaction to be finished
260260
"
261261
([conn ledger] (new-ledger-async conn ledger nil))
262262
([conn ledger opts]
@@ -316,7 +316,7 @@
316316
- :doc - Optional doc string about this db.
317317
- :fork - If forking an existing db, ref to db (actual identity, not db-ident). Must exist in network db.
318318
- :forkBlock - If fork is provided, optionally provide the block to fork at. Defaults to latest known.
319-
- :persistResp - Respond immediately once persisted with the dbid, don't wait for transaction to be finished
319+
- :persistResp - Respond immediately once persisted with the ledger-id, don't wait for transaction to be finished
320320
"
321321
([conn ledger] (new-ledger conn ledger nil))
322322
([conn ledger opts]
@@ -634,7 +634,7 @@
634634
auth-id (:auth opts)
635635
db-chan (->
636636
(<? (db conn ledger {:auth (when auth-id ["_auth/id" auth-id])}))
637-
(assoc :conn conn :network network :dbid ledger-id))
637+
(assoc :conn conn :network network :ledger-id ledger-id))
638638
db-blocks (<? (query-block/block-range db-chan start end opts))
639639
result (query-range/block-with-tx-data db-blocks)]
640640
result)))

src/fluree/db/api/ledger.cljc

+7-7
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,19 @@
100100
101101
resp-port is the async port on which any successful response will be placed."
102102
[db syncTo listen-id resp-port]
103-
(let [{:keys [conn network dbid]} db
103+
(let [{:keys [conn network ledger-id]} db
104104
newer-block? (fn [block] (>= block syncTo))
105105
event-fn (fn [evt data]
106106
(when (and (= :local-ledger-update evt) (newer-block? (:block data)))
107-
(conn/remove-listener conn network dbid listen-id)
107+
(conn/remove-listener conn network ledger-id listen-id)
108108
(async/go ;; note: avoided async/pipe as I don't believe promise-chan from session/db technically 'closes'
109-
(async/put! resp-port (async/<! (session/db conn (str network "/" dbid) nil))))))]
109+
(async/put! resp-port (async/<! (session/db conn (str network "/" ledger-id) nil))))))]
110110

111111
;; listener will monitor all blocks, add updated db to resp-port once > syncTo, and close listener
112-
(conn/add-listener conn network dbid listen-id event-fn)
112+
(conn/add-listener conn network ledger-id listen-id event-fn)
113113
;; a preemptive check if newer version of db already exists (db passed in could be old)
114114
(async/go
115-
(let [latest-db (async/<! (session/db conn (str network "/" dbid) nil))] ;; possible while setting up listener the block has come through, check again
115+
(let [latest-db (async/<! (session/db conn (str network "/" ledger-id) nil))] ;; possible while setting up listener the block has come through, check again
116116
(when (newer-block? (:block latest-db))
117117
(async/put! resp-port latest-db))))))
118118

@@ -121,7 +121,7 @@
121121
[db syncTo syncTimeout]
122122
(assert (pos-int? syncTo) (str "syncTo must be a block number (positive integer), provided: " syncTo))
123123
(let [pc (async/promise-chan) ;; final response channel - has db or timeout error
124-
{:keys [conn network dbid]} db
124+
{:keys [conn network ledger-id]} db
125125
listen-id (random-uuid)
126126
timeout (if (pos-int? syncTimeout)
127127
(min syncTimeout 120000) ;; max 2 minutes
@@ -139,7 +139,7 @@
139139
(let [timeout-ch (async/timeout timeout)
140140
updated-db (async/alt! timeout-ch :timeout
141141
res-port ([db] db))]
142-
(conn/remove-listener conn network dbid listen-id) ;; close listener to clean up
142+
(conn/remove-listener conn network ledger-id listen-id) ;; close listener to clean up
143143
(if (= :timeout updated-db)
144144
(async/put! pc (ex-info (str "Timeout waiting for block: " syncTo)
145145
{:status 400 :error :db/timeout}))

src/fluree/db/api/query.cljc

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666

6767

6868
(defn- isolate-ledger-id
69-
[dbid]
70-
(re-find #"[a-z0-9]+/[a-z0-9]+" dbid))
69+
[ledger-id]
70+
(re-find #"[a-z0-9]+/[a-z0-9]+" ledger-id))
7171

7272

7373
(defn db
@@ -494,6 +494,6 @@
494494
:standard (query-async source flureeQL)
495495
:history (history-query-async source flureeQL)
496496
:block (let [conn (:conn source)
497-
ledger (keyword (:network source) (:dbid source))]
497+
ledger (keyword (:network source) (:ledger-id source))]
498498
(block-query-async conn ledger flureeQL))
499499
:multi (multi-query-async source flureeQL))))

src/fluree/db/api_js.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
_ (conn-handler/check-connection conn opts)
3838
[network ledger-id] (session/resolve-ledger conn ledger)
3939
root-db (-> (<? (session/db conn ledger opts))
40-
(assoc :conn conn :network network :dbid ledger-id))
40+
(assoc :conn conn :network network :ledger-id ledger-id))
4141
dbt (if block
4242
(<? (time-travel/as-of-block root-db block))
4343
root-db)]
@@ -54,8 +54,8 @@
5454
(= (-> source (str/split #"/") count) 2))
5555

5656
(defn- isolate-ledger-id
57-
[dbid]
58-
(re-find #"[a-z0-9]+/[a-z0-9]+" dbid))
57+
[ledger-id]
58+
(re-find #"[a-z0-9]+/[a-z0-9]+" ledger-id))
5959

6060
(defn- get-sources
6161
"Validates & returns the query sources.

0 commit comments

Comments
 (0)