Compare commits

..

32 Commits
v2.4.0 ... main

Author SHA1 Message Date
Hayden Young
2aab9667c4 chore: Bump Helia version. 2025-03-07 17:32:54 +01:00
Hayden Young
a66c4e01bb chore: Name min ver test. 2025-03-07 17:27:08 +01:00
Hayden Young
da1a0873fd chore: Node min ver test. 2025-03-07 17:23:32 +01:00
Hayden Young
b5926cb972 fix: Deploy pages. 2025-02-22 14:52:08 +01:00
Hayden Young
11c11ffe61 chore: Fix upload pages for api docs. 2025-02-22 14:42:51 +01:00
Hayden Young
494dfdb1ef chore: Fix upload pages for api docs. 2025-02-22 14:36:40 +01:00
Hayden Young
1b470fdb68 chore: Iterate version. 2025-02-22 14:25:51 +01:00
Haad
35bf38d8d8
Merge pull request #1223 from julienmalard/patch-3
Remove disconnected peers
2025-02-21 15:02:25 +02:00
Julien Malard-Adam
c5898dd58a
Remove semicolons 2025-02-21 12:19:51 +01:00
Julien Malard-Adam
8ff138de46
Remove disconnected peers 2025-02-21 09:40:56 +01:00
Hayden Young
3d41ab5d99
Merge pull request #1216 from julienmalard/patch-1
Use `.name` instead of `.code` for errors
2025-02-12 19:29:31 +08:00
Julien Malard-Adam
d504e0f7ba
Update sync.js
Remove console.error, since the error is already caught and reported by events.emit('error') afterwards
2025-02-12 11:15:08 +01:00
Julien Malard-Adam
28b3e807de
Update error name 2025-02-04 12:12:09 -05:00
Julien Malard-Adam
41f015cb13
Use .name instead of .code for errors
Fix for the change in libp2p here: https://github.com/libp2p/js-libp2p/pull/2655
2025-02-04 12:09:11 -05:00
Hayden Young
d290032ebf
Merge pull request #1213 from Alulx/fix/docs-Getting-Started
Updated GETTING_STARTED.md with new instructions
2025-01-28 00:24:48 +08:00
alex
9612a61c6f Updated GETTING_STARTED.md with new instructions 2025-01-25 12:27:57 +01:00
Hayden Young
4fccfda975
Merge pull request #1206 from PradaJoaquin/main
fix: Update relay example to use default reservation ttl setting
2024-11-26 06:28:31 +08:00
Joaquin Prada
adb8d77aa2 fix: Revert default relay settings, keep updated ttl 2024-11-25 19:12:35 -03:00
Joaquin Prada
ed12f2b2cf fix: Update relay example to use default reservation settings 2024-11-25 18:32:14 -03:00
Hayden Young
c3be1d2fac chore: Iterate version. 2024-11-01 12:30:30 +00:00
Hayden Young
af79cb8235
Merge pull request #1202 from orbitdb/fix/duplicate-put
fix: Remove duplicate put.
2024-11-01 20:28:30 +08:00
Hayden Young
0f062cb38d fix: Remove duplicate put. 2024-11-01 11:23:07 +00:00
Hayden Young
497cf43cc7 Merge remote-tracking branch 'refs/remotes/origin/main' 2024-10-31 22:54:11 +00:00
Hayden Young
ff8b736ad9 chore: Iterate version. 2024-10-31 22:53:56 +00:00
Hayden Young
90dc85077c
Merge pull request #1201 from orbitdb/fix/manifest-store
Test
2024-11-01 06:52:28 +08:00
Hayden Young
4a5822c4a1 fix: Remove console output. 2024-10-31 22:48:11 +00:00
Hayden Young
bef35b013c Merge remote-tracking branch 'origin' into fix/manifest-store 2024-10-31 22:45:40 +00:00
haad
89ff328325 Test 2024-10-30 10:42:15 +01:00
Hayden Young
d1ddc2ec98 chore: funding.json 2024-10-29 20:42:35 +00:00
Hayden Young
830902ed3d
Merge pull request #1200 from orbitdb/fix/helia-modules-upgrade
fix: Use Helia defaults for gossipsub and circuit relay. Update circu…
2024-10-30 02:02:19 +08:00
Hayden Young
a9dcdfdc5c fix: Remove unused packages. 2024-10-29 16:38:06 +00:00
Hayden Young
2f7a6270a8 fix: Use Helia defaults for gossipsub and circuit relay. Update circuit relay with up-to-date configuration. 2024-10-29 16:03:26 +00:00
12 changed files with 3689 additions and 5096 deletions

View File

@ -25,7 +25,7 @@ jobs:
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build:docs
- uses: actions/upload-pages-artifact@v2
- uses: actions/upload-pages-artifact@v3
with:
path: ./docs/api/
@ -37,5 +37,5 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action
uses: actions/deploy-pages@v4 # or the latest "vX.X.X" version tag for this action

View File

@ -0,0 +1,36 @@
---
name: Run Tests (Node Minimum Version)
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test:ci
test-browser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run a webrtc relay in the background
run: npm run webrtc:background
- name: Run browser tests
run: npm run test:browser

View File

@ -0,0 +1 @@
https://orbitdb.org/funding.json

View File

@ -2,4 +2,10 @@
For now, please refer to our Git commit history for a list of changes.
https://github.com/orbitdb/orbitdb/commits/v2.4.0
https://github.com/orbitdb/orbitdb/compare/v2.4.3...v2.5.0
You can also use the following git command to generate a log of changes:
```
git log v2.4.3..v2.5.0 --oneline
```

View File

@ -206,6 +206,7 @@ import { createHelia } from 'helia'
import { createOrbitDB, IPFSAccessController } from '@orbitdb/core'
import { LevelBlockstore } from 'blockstore-level'
import { Libp2pOptions } from './config/libp2p.js'
import { multiaddr } from '@multiformats/multiaddr'
const main = async () => {
// create a random directory to avoid OrbitDB conflicts.
@ -219,7 +220,9 @@ const main = async () => {
let db
if (process.argv[2]) {
if (process.argv[2] && process.argv[3]) {
await orbitdb.ipfs.libp2p.dial(multiaddr(process.argv[3]))
console.log('opening db', process.argv[2])
db = await orbitdb.open(process.argv[2])
} else {
// When we open a new database, write access is only available to the
@ -230,6 +233,8 @@ const main = async () => {
// access using grant and revoke.
db = await orbitdb.open('my-db', { AccessController: IPFSAccessController({ write: ['*']}) })
console.log('libp2p address', '(copy one of these addresses then dial into this node from the second node)', orbitdb.ipfs.libp2p.getMultiaddrs())
// Copy this output if you want to connect a peer to another.
console.log('my-db address', '(copy my db address and use when launching peer 2)', db.address)
}
@ -263,27 +268,33 @@ const main = async () => {
main()
```
Open two consoles in your command line terminal.
Launch peer 1 from the terminal:
In terminal 1, run the first peer:
```sh
node index.js
```bash
node test.js
```
When running, you should see the address of the database, for example:
Once launched you will see some output which may look something like this:
```sh
```
libp2p address (copy one of these addresses then dial into this node from the second node) [
Multiaddr(/ip4/127.0.0.1/tcp/36161/p2p/12D3KooWKFWB78Hka2uPVNYYoXfucWp6rDLsQzr5CFiP67NAo7YF),
Multiaddr(/ip4/192.168.1.22/tcp/36161/p2p/12D3KooWKFWB78Hka2uPVNYYoXfucWp6rDLsQzr5CFiP67NAo7YF),
Multiaddr(/ip4/100.64.100.6/tcp/36161/p2p/12D3KooWKFWB78Hka2uPVNYYoXfucWp6rDLsQzr5CFiP67NAo7YF)
]
my-db address (copy my db address and use when launching peer 2) /orbitdb/zdpuB2aYUCnZ7YUBrDkCWpRLQ8ieUbqJEVRZEd5aDhJBDpBqj
```
Copy the database's address from terminal 1 and, in terminal 2, run:
It contains the libp2p address and db address. You will need both of these when connecting from peer 2.
```sh
node index.js /orbitdb/zdpuB2aYUCnZ7YUBrDkCWpRLQ8ieUbqJEVRZEd5aDhJBDpBqj
Open another terminal and launch peer 2. The command takes the form `node test.js <orbitdb-address> <libp2p-address>`
```bash
node test.js /orbitdb/zdpuB2aYUCnZ7YUBrDkCWpRLQ8ieUbqJEVRZEd5aDhJBDpBqj /ip4/127.0.0.1/tcp/36161/p2p/12D3KooWKFWB78Hka2uPVNYYoXfucWp6rDLsQzr5CFiP67NAo7YF
```
Both peers will print new records to the terminal as the log is updated. When you stop each peer using ctrl+c, the final state of the database will be printed to the terminal. They should match.
What is happening is the second peer is dialing the first peer on the /ip4/ address then opens the database.
**PLEASE NOTE:**

View File

@ -1,4 +1,4 @@
## OrbitDB API - v2.4
## OrbitDB API - v2.5
OrbitDB is a serverless, distributed, peer-to-peer database. OrbitDB uses IPFS
as its data storage and Libp2p Pubsub to automatically sync databases with peers. It's an eventually consistent database that uses Merkle-CRDTs for conflict-free database writes and merges making OrbitDB an excellent choice for p2p and decentralized apps, blockchain applications and local first web applications.

8662
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@orbitdb/core",
"version": "2.4.0",
"version": "2.5.0",
"description": "Distributed p2p database on IPFS",
"author": "Haad",
"license": "MIT",
@ -30,19 +30,17 @@
},
"devDependencies": {
"@chainsafe/libp2p-gossipsub": "^14.1.0",
"@chainsafe/libp2p-yamux": "^7.0.1",
"@helia/block-brokers": "^4.0.0",
"@libp2p/circuit-relay-v2": "^2.1.5",
"@libp2p/circuit-relay-v2": "^3.1.0",
"blockstore-level": "^2.0.1",
"c8": "^8.0.1",
"cross-env": "^7.0.3",
"fs-extra": "^11.2.0",
"helia": "^5.0.0",
"helia": "^5.2.1",
"it-all": "^3.0.4",
"jsdoc": "^4.0.2",
"mocha": "^10.2.0",
"path-browserify": "^1.0.1",
"playwright-test": "^14.0.0",
"playwright-test": "^14.1.6",
"rimraf": "^5.0.5",
"standard": "^17.1.0",
"webpack": "^5.89.0",

View File

@ -16,13 +16,17 @@ const ManifestStore = async ({ ipfs, storage } = {}) => {
*/
storage = storage || await ComposedStorage(
await LRUStorage({ size: 1000 }),
await LRUStorage({ size: 100000 }),
await IPFSBlockStorage({ ipfs, pin: true })
)
const get = async (address) => {
const bytes = await storage.get(address)
const { value } = await Block.decode({ bytes, codec, hasher })
if (value) {
// Write to storage to make sure it gets pinned on IPFS
await storage.put(address, bytes)
}
return value
}

View File

@ -194,9 +194,8 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
const stream = await libp2p.dialProtocol(remotePeer, headsSyncAddress, { signal })
await pipe(sendHeads, stream, receiveHeads(peerId))
} catch (e) {
console.error(e)
peers.delete(peerId)
if (e.code === 'ERR_UNSUPPORTED_PROTOCOL') {
if (e.name === 'UnsupportedProtocolError') {
// Skip peer, they don't have this database currently
} else {
events.emit('error', e)
@ -232,6 +231,10 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
}
}
const handlePeerDisconnected = async event => {
peers.delete(event.detail.toString())
}
/**
* Add a log entry to the Sync Protocol to be sent to peers.
* @function add
@ -259,6 +262,7 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
pubsub.removeEventListener('message', handleUpdateMessage)
await libp2p.unhandle(headsSyncAddress)
await pubsub.unsubscribe(address)
libp2p.removeEventListener('peer:disconnect', handlePeerDisconnected)
peers.clear()
}
}
@ -277,6 +281,8 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
pubsub.addEventListener('message', handleUpdateMessage)
// Subscribe to the pubsub channel for this database through which updates are sent
await pubsub.subscribe(address)
// Remove disconnected peers from `peers`, as otherwise they will not resync heads on reconnection
libp2p.addEventListener('peer:disconnect', handlePeerDisconnected)
started = true
}
}

View File

@ -21,10 +21,6 @@ const Libp2pOptions = {
transports: [
webSockets({
filter: all
}),
webRTC(),
circuitRelayTransport({
discoverRelays: 1
})
],
connectionEncrypters: [noise()],
@ -43,16 +39,14 @@ const Libp2pOptions = {
*/
const Libp2pBrowserOptions = {
addresses: {
listen: ['/webrtc']
listen: ['/webrtc', '/p2p-circuit']
},
transports: [
webSockets({
filter: all
}),
webRTC(),
circuitRelayTransport({
discoverRelays: 1
})
circuitRelayTransport()
],
connectionEncrypters: [noise()],
streamMuxers: [yamux()],

View File

@ -32,7 +32,6 @@ const server = await createLibp2p({
relay: circuitRelayServer({
reservations: {
maxReservations: 5000,
reservationTtl: 1000,
defaultDataLimit: BigInt(1024 * 1024 * 1024)
}
})