@bsv/overlay 2.0.2 → 2.0.3
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/README.md +106 -226
- package/dist/cjs/package.json +2 -2
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/docs/API.md +580 -72
- package/docs/examples/README.md +2 -2
- package/docs/examples/gs-wip.md +76 -68
- package/package.json +2 -2
package/docs/examples/README.md
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Here, you will find documentation for common example usages of the Overlay Services Engine.
|
|
7
|
+
Here, you will find documentation for common example usages of the Overlay Services Engine. These examples focus on direct `@bsv/overlay` integration. For a ready-to-run HTTP overlay node, use [`@bsv/overlay-express`](https://github.com/bsv-blockchain/overlay-express) and [`overlay-express-examples`](https://github.com/bsv-blockchain/overlay-express-examples).
|
|
8
8
|
|
|
9
9
|
## Available Examples
|
|
10
10
|
|
|
11
|
-
- [Getting Started
|
|
11
|
+
- [Getting Started](./gs-wip.md) — Introduction and low-level engine setup guide
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
package/docs/examples/gs-wip.md
CHANGED
|
@@ -6,106 +6,114 @@
|
|
|
6
6
|
|
|
7
7
|
## Introduction to BSV Overlay Services Engine
|
|
8
8
|
|
|
9
|
-
The BSV Overlay Services Engine is
|
|
9
|
+
The BSV Overlay Services Engine is the low-level runtime for topic managers and lookup services. It validates candidate outputs, stores admitted UTXOs, tracks spends, answers lookup questions, and coordinates synchronization between overlay nodes.
|
|
10
|
+
|
|
11
|
+
If you want to run an HTTP overlay node, start with [`@bsv/overlay-express`](https://github.com/bsv-blockchain/overlay-express). If you want a local or cloud application runtime, use LARS or CARS with the BRC-102 `deployment-info.json` structure. Use `@bsv/overlay` directly when you are building custom infrastructure around the engine.
|
|
10
12
|
|
|
11
13
|
### Components of the System
|
|
12
14
|
|
|
13
|
-
1. **Topic Managers
|
|
14
|
-
2. **Lookup Services
|
|
15
|
-
3. **Storage
|
|
16
|
-
4. **Chain Tracker
|
|
15
|
+
1. **Topic Managers** decide which transaction outputs are admitted for a topic.
|
|
16
|
+
2. **Lookup Services** index admitted and spent outputs and answer domain-specific lookup questions.
|
|
17
|
+
3. **Storage** persists admitted outputs, spend state, history, sync state, and interaction timestamps.
|
|
18
|
+
4. **Chain Tracker** verifies SPV data for transactions unless the engine is configured for script-only validation.
|
|
19
|
+
5. **Broadcaster** submits accepted transactions to the network.
|
|
20
|
+
6. **Advertiser** publishes SHIP and SLAP availability records when peer discovery is enabled.
|
|
17
21
|
|
|
18
22
|
### Setting Up the Engine
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import { Engine, KnexStorage } from "@bsv/overlay";
|
|
24
|
-
import { HelloTopicManager, HelloLookupService } from 'hello-services';
|
|
25
|
-
import { WoChain } from "@bsv/sdk";
|
|
26
|
-
|
|
27
|
-
// Initialize components
|
|
28
|
-
const managers = {
|
|
29
|
-
"exampleTopic": new HelloTopicManager()
|
|
30
|
-
};
|
|
24
|
+
Install the current packages:
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
```bash
|
|
27
|
+
npm i @bsv/overlay @bsv/sdk knex
|
|
28
|
+
```
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
const chainTracker = new WoChain();
|
|
30
|
+
Create the engine with your concrete implementations:
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
```ts
|
|
33
|
+
import { Engine, KnexStorage } from '@bsv/overlay'
|
|
34
|
+
import { WhatsOnChain, NodejsHttpClient, ARC } from '@bsv/sdk'
|
|
35
|
+
import knexFactory from 'knex'
|
|
36
|
+
|
|
37
|
+
import { ExampleLookupService } from './services/ExampleLookupService.js'
|
|
38
|
+
import { ExampleTopicManager } from './services/ExampleTopicManager.js'
|
|
39
|
+
|
|
40
|
+
const knex = knexFactory({
|
|
41
|
+
client: 'mysql2',
|
|
42
|
+
connection: process.env.KNEX_URL
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const engine = new Engine(
|
|
46
|
+
{
|
|
47
|
+
tm_example: new ExampleTopicManager()
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
ls_example: new ExampleLookupService()
|
|
51
|
+
},
|
|
52
|
+
new KnexStorage(knex),
|
|
53
|
+
new WhatsOnChain('test', { httpClient: new NodejsHttpClient() }),
|
|
54
|
+
process.env.HOSTING_URL,
|
|
55
|
+
process.env.SHIP_TRACKERS?.split(',') ?? [],
|
|
56
|
+
process.env.SLAP_TRACKERS?.split(',') ?? [],
|
|
57
|
+
new ARC(process.env.ARC_URL ?? 'https://arc.taal.com', {
|
|
58
|
+
apiKey: process.env.ARC_API_KEY
|
|
59
|
+
}),
|
|
60
|
+
undefined,
|
|
61
|
+
{
|
|
62
|
+
tm_example: 'SHIP'
|
|
63
|
+
}
|
|
64
|
+
)
|
|
41
65
|
```
|
|
42
66
|
|
|
67
|
+
Use the string `'scripts only'` for the chain tracker only when the service intentionally skips SPV validation and relies only on script-level checks.
|
|
68
|
+
|
|
43
69
|
### Submitting a Transaction
|
|
44
70
|
|
|
45
|
-
|
|
71
|
+
Submit tagged BEEF bytes with the topics that should evaluate the transaction:
|
|
46
72
|
|
|
47
73
|
```ts
|
|
48
74
|
import { Transaction } from '@bsv/sdk'
|
|
49
75
|
|
|
50
|
-
const tx = new Transaction(/* ... */)
|
|
76
|
+
const tx = new Transaction(/* ... */)
|
|
51
77
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
78
|
+
const steak = await engine.submit({
|
|
79
|
+
beef: tx.toBEEF(),
|
|
80
|
+
topics: ['tm_example']
|
|
81
|
+
})
|
|
56
82
|
|
|
57
|
-
|
|
58
|
-
engine.submit(transaction).then(steak => {
|
|
59
|
-
console.log("Transaction processed:", steak);
|
|
60
|
-
}).catch(error => {
|
|
61
|
-
console.error("Error processing transaction:", error);
|
|
62
|
-
});
|
|
83
|
+
console.log('Transaction processed:', steak)
|
|
63
84
|
```
|
|
64
85
|
|
|
65
86
|
### Lookup Queries
|
|
66
87
|
|
|
67
|
-
|
|
88
|
+
Ask a lookup service a domain-specific question:
|
|
68
89
|
|
|
69
90
|
```ts
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
engine.lookup(question).then(answer => {
|
|
79
|
-
console.log("Lookup result:", answer);
|
|
80
|
-
}).catch(error => {
|
|
81
|
-
console.error("Error performing lookup:", error);
|
|
82
|
-
});
|
|
91
|
+
const answer = await engine.lookup({
|
|
92
|
+
service: 'ls_example',
|
|
93
|
+
query: {
|
|
94
|
+
identityKey: '03...'
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
console.log('Lookup result:', answer)
|
|
83
99
|
```
|
|
84
100
|
|
|
85
|
-
###
|
|
101
|
+
### Service Documentation
|
|
86
102
|
|
|
87
|
-
|
|
103
|
+
Overlay clients and dashboards can retrieve service documentation and metadata directly from the engine:
|
|
88
104
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
```ts
|
|
106
|
+
const topicDocs = await engine.getDocumentationForTopicManger('tm_example')
|
|
107
|
+
const lookupDocs = await engine.getDocumentationForLookupServiceProvider('ls_example')
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
const topics = await engine.listTopicManagers()
|
|
110
|
+
const lookupServices = await engine.listLookupServiceProviders()
|
|
111
|
+
```
|
|
94
112
|
|
|
95
|
-
|
|
113
|
+
### Deployment Path
|
|
96
114
|
|
|
97
|
-
|
|
98
|
-
// For a topic manager
|
|
99
|
-
engine.getDocumentationForTopicManger("exampleTopic").then(doc => {
|
|
100
|
-
console.log("Documentation for Topic Manager:", doc);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// For a lookup service
|
|
104
|
-
engine.getDocumentationForLookupServiceProvider("exampleLookup").then(doc => {
|
|
105
|
-
console.log("Documentation for Lookup Service:", doc);
|
|
106
|
-
});
|
|
107
|
-
```
|
|
115
|
+
For a public overlay node, wire the engine into HTTP routes using `@bsv/overlay-express` instead of hand-rolling routes. Overlay Express already exposes the standard submit, lookup, sync, health, documentation, and admin surfaces expected by the rest of the BSV overlay ecosystem.
|
|
108
116
|
|
|
109
117
|
### Conclusion
|
|
110
118
|
|
|
111
|
-
The BSV Overlay Services Engine
|
|
119
|
+
The BSV Overlay Services Engine is the shared core for overlay validation, indexing, lookup, and synchronization. Keep direct engine usage focused on infrastructure-level integrations, and use Overlay Express, LARS, and CARS for the standard application path.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/overlay",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "BSV Blockchain Overlay Services Engine",
|
|
6
6
|
"main": "dist/cjs/mod.js",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@bsv/gasp": "^1.2.2",
|
|
77
|
-
"@bsv/sdk": "^2.0.
|
|
77
|
+
"@bsv/sdk": "^2.0.14",
|
|
78
78
|
"knex": "^3.1.0"
|
|
79
79
|
}
|
|
80
80
|
}
|