@bsv/overlay 0.5.4 → 0.6.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.
- package/dist/cjs/package.json +3 -3
- package/dist/cjs/src/Engine.js +9 -7
- package/dist/cjs/src/Engine.js.map +1 -1
- package/dist/cjs/src/GASP/OverlayGASPStorage.js +89 -44
- package/dist/cjs/src/GASP/OverlayGASPStorage.js.map +1 -1
- package/dist/cjs/src/storage/knex/KnexStorage.js +23 -18
- package/dist/cjs/src/storage/knex/KnexStorage.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/Engine.js +9 -7
- package/dist/esm/src/Engine.js.map +1 -1
- package/dist/esm/src/GASP/OverlayGASPStorage.js +89 -44
- package/dist/esm/src/GASP/OverlayGASPStorage.js.map +1 -1
- package/dist/esm/src/storage/knex/KnexStorage.js +23 -18
- package/dist/esm/src/storage/knex/KnexStorage.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/Engine.d.ts +1 -1
- package/dist/types/src/Engine.d.ts.map +1 -1
- package/dist/types/src/GASP/OverlayGASPStorage.d.ts +10 -0
- package/dist/types/src/GASP/OverlayGASPStorage.d.ts.map +1 -1
- package/dist/types/src/TopicManager.d.ts +1 -1
- package/dist/types/src/TopicManager.d.ts.map +1 -1
- package/dist/types/src/storage/knex/KnexStorage.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/docs/API.md +16 -503
- package/docs/README.md +9 -3
- package/docs/Synchronization.md +203 -0
- package/docs/concepts/00-overview.md +85 -0
- package/docs/concepts/01-best-practices.md +202 -0
- package/docs/concepts/02-query-performance.md +345 -0
- package/docs/concepts/03-database-monitoring.md +211 -0
- package/docs/concepts/04-pagination-example.md +186 -0
- package/docs/concepts/05-recommendations-summary.md +158 -0
- package/docs/concepts/README.md +16 -0
- package/docs/examples/README.md +11 -1
- package/docs/examples/gs-wip.md +7 -1
- package/docs/internal/README.md +8 -1
- package/package.json +3 -3
- package/src/Engine.ts +10 -7
- package/src/GASP/OverlayGASPStorage.ts +105 -49
- package/src/TopicManager.ts +6 -1
- package/src/__tests/Engine.test.ts +6 -2
- package/src/storage/knex/KnexStorage.ts +25 -20
package/src/TopicManager.ts
CHANGED
|
@@ -9,7 +9,12 @@ export interface TopicManager {
|
|
|
9
9
|
* Accepts the transaction in BEEF format and an array of those input indices which spend previously-admitted outputs from the same topic.
|
|
10
10
|
* The transaction's BEEF structure will always contain the transactions associated with previous coins for reference (if any), regardless of whether the current transaction was directly proven.
|
|
11
11
|
*/
|
|
12
|
-
identifyAdmissibleOutputs: (
|
|
12
|
+
identifyAdmissibleOutputs: (
|
|
13
|
+
beef: number[],
|
|
14
|
+
previousCoins: number[],
|
|
15
|
+
offChainValues?: number[],
|
|
16
|
+
mode?: 'historical-tx' | 'current-tx' | 'historical-tx-no-spv'
|
|
17
|
+
) => Promise<AdmittanceInstructions>
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* Identifies and returns the inputs needed to anchor any topical outputs from this transaction to their associated previous history.
|
|
@@ -528,12 +528,16 @@ describe('BSV Overlay Services Engine', () => {
|
|
|
528
528
|
mockChainTracker
|
|
529
529
|
)
|
|
530
530
|
|
|
531
|
-
// Submit the utxo
|
|
532
531
|
await engine.submit({
|
|
533
532
|
beef: exampleBeef,
|
|
534
533
|
topics: ['Hello']
|
|
535
534
|
})
|
|
536
|
-
expect(engine.managers.Hello.identifyAdmissibleOutputs).toHaveBeenCalledWith(
|
|
535
|
+
expect(engine.managers.Hello.identifyAdmissibleOutputs).toHaveBeenCalledWith(
|
|
536
|
+
exampleBeef,
|
|
537
|
+
[0],
|
|
538
|
+
undefined,
|
|
539
|
+
'current-tx'
|
|
540
|
+
)
|
|
537
541
|
})
|
|
538
542
|
describe('When previous UTXOs were retained by the topic manager', () => {
|
|
539
543
|
it('Notifies all lookup services about the output being spent (not deleted, see the comment about this in deleteUTXODeep)', async () => {
|
|
@@ -170,28 +170,33 @@ export class KnexStorage implements Storage {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
async insertOutput (output: Output): Promise<void> {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
outputIndex: Number(output.outputIndex),
|
|
176
|
-
outputScript: Buffer.from(output.outputScript),
|
|
177
|
-
topic: output.topic,
|
|
178
|
-
satoshis: Number(output.satoshis),
|
|
179
|
-
outputsConsumed: JSON.stringify(output.outputsConsumed),
|
|
180
|
-
consumedBy: JSON.stringify(output.consumedBy),
|
|
181
|
-
spent: output.spent,
|
|
182
|
-
score: output.score
|
|
183
|
-
})]
|
|
184
|
-
|
|
185
|
-
if (output.beef !== undefined) {
|
|
186
|
-
const insertTransactionPromise = this.knex('transactions').insert({
|
|
173
|
+
await this.knex.transaction(async trx => {
|
|
174
|
+
const existing = await trx('outputs').where({
|
|
187
175
|
txid: output.txid,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
176
|
+
outputIndex: Number(output.outputIndex),
|
|
177
|
+
topic: output.topic
|
|
178
|
+
}).first()
|
|
179
|
+
|
|
180
|
+
if (existing === undefined || existing === null) {
|
|
181
|
+
await trx('outputs').insert({
|
|
182
|
+
txid: output.txid,
|
|
183
|
+
outputIndex: Number(output.outputIndex),
|
|
184
|
+
outputScript: Buffer.from(output.outputScript),
|
|
185
|
+
topic: output.topic,
|
|
186
|
+
satoshis: Number(output.satoshis),
|
|
187
|
+
outputsConsumed: JSON.stringify(output.outputsConsumed),
|
|
188
|
+
consumedBy: JSON.stringify(output.consumedBy),
|
|
189
|
+
spent: output.spent,
|
|
190
|
+
score: output.score
|
|
191
|
+
})
|
|
192
|
+
}
|
|
192
193
|
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
if (output.beef !== undefined) {
|
|
195
|
+
await trx('transactions').insert({
|
|
196
|
+
txid: output.txid,
|
|
197
|
+
beef: Buffer.from(output.beef)
|
|
198
|
+
}).onConflict('txid').ignore()
|
|
199
|
+
}
|
|
195
200
|
})
|
|
196
201
|
}
|
|
197
202
|
|