hypercore-storage 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/index.js +18 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -47,12 +47,12 @@ class Atom {
47
47
  }
48
48
 
49
49
  class HypercoreStorage {
50
- constructor (store, db, core, view, atomic) {
50
+ constructor (store, db, core, view, atom) {
51
51
  this.store = store
52
52
  this.db = db
53
53
  this.core = core
54
54
  this.view = view
55
- this.atomic = atomic
55
+ this.atom = atom
56
56
 
57
57
  this.view.readStart()
58
58
  }
@@ -95,15 +95,15 @@ class HypercoreStorage {
95
95
  }
96
96
 
97
97
  snapshot () {
98
- return new HypercoreStorage(this.store, this.db.snapshot(), this.core, this.view.snapshot(), this.atomic)
98
+ return new HypercoreStorage(this.store, this.db.snapshot(), this.core, this.view.snapshot(), this.atom)
99
99
  }
100
100
 
101
101
  atomize (atom) {
102
- return new HypercoreStorage(this.store, this.db.session(), this.core, atom.view, true)
102
+ return new HypercoreStorage(this.store, this.db.session(), this.core, atom.view, atom)
103
103
  }
104
104
 
105
- atom () {
106
- return this.store.atom()
105
+ createAtom () {
106
+ return this.store.createAtom()
107
107
  }
108
108
 
109
109
  createBlockStream (opts) {
@@ -149,11 +149,11 @@ class HypercoreStorage {
149
149
  const dependency = await dependencyPromise
150
150
  if (dependency) core.dependencies = this._addDependency(dependency)
151
151
 
152
- return new HypercoreStorage(this.store, this.db.session(), core, this.atomic ? this.view : new View(), this.atomic)
152
+ return new HypercoreStorage(this.store, this.db.session(), core, this.atom ? this.view : new View(), this.atom)
153
153
  }
154
154
 
155
- async createSession (name, head, atom) {
156
- const rx = this.read(atom)
155
+ async createSession (name, head) {
156
+ const rx = this.read()
157
157
 
158
158
  const existingSessionsPromise = rx.getSessions()
159
159
  const existingHeadPromise = rx.getHead()
@@ -174,7 +174,7 @@ class HypercoreStorage {
174
174
  session.dataPointer = await this.store._allocData()
175
175
  }
176
176
 
177
- const tx = this.write(atom)
177
+ const tx = this.write()
178
178
 
179
179
  tx.setSessions(sessions)
180
180
 
@@ -193,7 +193,7 @@ class HypercoreStorage {
193
193
 
194
194
  await tx.flush()
195
195
 
196
- return new HypercoreStorage(this.store, this.db.session(), core, atom ? atom.view : this.atomic ? this.view : new View(), !!atom || this.atomic)
196
+ return new HypercoreStorage(this.store, this.db.session(), core, this.atom ? this.view : new View(), this.atom)
197
197
  }
198
198
 
199
199
  async createAtomicSession (atom, head) {
@@ -233,12 +233,12 @@ class HypercoreStorage {
233
233
  return deps
234
234
  }
235
235
 
236
- read (atom) {
237
- return new CoreRX(this.core, this.db, atom ? atom.view : this.view)
236
+ read () {
237
+ return new CoreRX(this.core, this.db, this.view)
238
238
  }
239
239
 
240
- write (atom) {
241
- return new CoreTX(this.core, this.db, atom ? atom.view : this.atomic ? this.view : null, [])
240
+ write () {
241
+ return new CoreTX(this.core, this.db, this.atom ? this.view : null, [])
242
242
  }
243
243
 
244
244
  close () {
@@ -429,7 +429,7 @@ class CorestoreStorage {
429
429
  return head === null ? initStoreHead() : head
430
430
  }
431
431
 
432
- atom () {
432
+ createAtom () {
433
433
  return new Atom(this.db)
434
434
  }
435
435
 
@@ -585,7 +585,7 @@ class CorestoreStorage {
585
585
  dataPointer = dependency.dataPointer
586
586
  }
587
587
 
588
- const result = new HypercoreStorage(this, this.db.session(), core, EMPTY, false)
588
+ const result = new HypercoreStorage(this, this.db.session(), core, EMPTY, null)
589
589
 
590
590
  if (result.core.version === 0) await this._migrateCore(result, discoveryKey, create)
591
591
  return result
@@ -635,7 +635,7 @@ class CorestoreStorage {
635
635
 
636
636
  tx.apply()
637
637
 
638
- return new HypercoreStorage(this, this.db.session(), ptr, EMPTY, false)
638
+ return new HypercoreStorage(this, this.db.session(), ptr, EMPTY, null)
639
639
  }
640
640
 
641
641
  async create (data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",