Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate sync and project invites #362

Merged
merged 76 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d687f1d
WIP initial work
gmaclennan Oct 26, 2023
74a77e2
rename Rpc to LocalPeers
gmaclennan Oct 26, 2023
e301c85
Handle deviceInfo internally, id -> deviceId
gmaclennan Oct 26, 2023
ae371fd
Tests for stream error handling
gmaclennan Oct 26, 2023
ccdf39f
remove unnecessary constructor
gmaclennan Oct 26, 2023
a52254b
return replication stream
gmaclennan Oct 26, 2023
50698e6
Attach protomux instance to peer info
gmaclennan Oct 26, 2023
ae35e9c
rename and re-organize
gmaclennan Oct 26, 2023
be64a3d
revert changes outside scope of PR
gmaclennan Oct 26, 2023
ee2020e
WIP initial work
gmaclennan Oct 26, 2023
0cd25da
Tie everything together
gmaclennan Oct 26, 2023
395345d
rename getProjectInstance
gmaclennan Oct 27, 2023
7963a3e
feat: client.listLocalPeers() & `local-peers` evt
gmaclennan Oct 27, 2023
9bff9ac
feat: add $sync API methods
gmaclennan Oct 27, 2023
1c0dc6b
feat: Add project.$waitForInitialSync() method
gmaclennan Oct 27, 2023
1f4fad2
Wait for initial sync within addProject()
gmaclennan Oct 27, 2023
d00bf10
fix: don't add core bitfield until core is ready
gmaclennan Oct 28, 2023
989b429
feat: expose deviceId on coreManager
gmaclennan Oct 28, 2023
bbda3f0
fix: wait for project.ready() in waitForInitialSync
gmaclennan Oct 28, 2023
0a32989
fix: skip waitForSync in tests
gmaclennan Oct 28, 2023
dc7a7c3
don't enable/disable namespace if not needed
gmaclennan Oct 30, 2023
1895679
start core download when created via sparse: false
gmaclennan Oct 30, 2023
763b57b
Add debug logging
gmaclennan Oct 30, 2023
2fb1072
fix timeout
gmaclennan Oct 30, 2023
b5f1a00
fix: Add new cores to the indexer (!!!)
gmaclennan Oct 30, 2023
d3fb8ad
remove unnecessary log stmt
gmaclennan Oct 30, 2023
32c4d32
get capabilities.getMany() to include creator
gmaclennan Oct 30, 2023
fe01caa
fix invite test
gmaclennan Oct 30, 2023
5a47b56
keep blob cores sparse
gmaclennan Oct 30, 2023
9921f66
optional param for LocalPeers
gmaclennan Nov 7, 2023
6dfa0d6
Merge branch 'main' into feat/initial-download
gmaclennan Nov 9, 2023
68455be
re-org sync and replication
gmaclennan Nov 10, 2023
7513788
update package-lock
gmaclennan Nov 10, 2023
f58bbaf
Merge branch 'main' into feat/initial-download
gmaclennan Nov 10, 2023
8c6a081
chore: Add debug logging
gmaclennan Nov 10, 2023
3bad62a
Merge branch 'chore/add-logging' into feat/initial-download
gmaclennan Nov 10, 2023
8a63746
Add new logger to discovery + dnssd
gmaclennan Nov 10, 2023
ed69a78
Get invite test working
gmaclennan Nov 10, 2023
7300da3
fix manager logger
gmaclennan Nov 11, 2023
b2eda92
cleanup invite test (and make it fail :(
gmaclennan Nov 11, 2023
2224f2b
fix: handle duplicate connections to LocalPeers
gmaclennan Nov 14, 2023
97df1c0
Merge branch 'main' into fix/local-peers
gmaclennan Nov 14, 2023
bc5e8d6
fix stream close before channel open
gmaclennan Nov 14, 2023
c1b473c
send invite to non-existent peer
gmaclennan Nov 14, 2023
07cac79
fixed fake timers implementation for tests
gmaclennan Nov 14, 2023
3407e0c
new tests for duplicate connections
gmaclennan Nov 14, 2023
6174ce0
Merge branch 'fix/local-peers' into feat/initial-download
gmaclennan Nov 14, 2023
8387f84
cleanup and small fix
gmaclennan Nov 14, 2023
6a886b8
Better state debug logging
gmaclennan Nov 14, 2023
d50fcea
chain of invites test
gmaclennan Nov 14, 2023
5bf1941
fix max listeners and add skipped test
gmaclennan Nov 14, 2023
34d2d34
fix: only request a core key from one peer
gmaclennan Nov 16, 2023
158ac7c
cleanup members tests with new helprs
gmaclennan Nov 16, 2023
687b9bc
wait for project ready when adding
gmaclennan Nov 16, 2023
e6225fe
only create 4 clients for chain of invites test
gmaclennan Nov 16, 2023
a912ede
add e2e sync tests
gmaclennan Nov 17, 2023
bbfe301
add published @mapeo/mock-data
gmaclennan Nov 20, 2023
ea442a3
fix: don't open cores in sparse mode
gmaclennan Nov 20, 2023
72f0dff
fix: option to skip auto download for tests
gmaclennan Nov 20, 2023
a07c278
e2e test for stop-start sync
gmaclennan Nov 20, 2023
800d136
fix coreManager unit tests
gmaclennan Nov 20, 2023
3afafbb
fix blob store tests
gmaclennan Nov 20, 2023
ca60188
Merge branch 'main' into feat/initial-download
gmaclennan Nov 20, 2023
420e21a
fix discovery-key event
gmaclennan Nov 20, 2023
5cd349d
add coreCount to sync state
gmaclennan Nov 20, 2023
04520f6
test sync with blocked peer & fix bugs
gmaclennan Nov 20, 2023
53e388e
fix datatype unit tests
gmaclennan Nov 20, 2023
41895a7
fix blobs server unit tests
gmaclennan Nov 20, 2023
7df2c73
remote peer-sync-controller unit test
gmaclennan Nov 20, 2023
1133e75
fix type issues caused by bad lockfile
achou11 Nov 20, 2023
5d7c251
ignore debug type errors
gmaclennan Nov 21, 2023
a2f8a1b
fixes for review comments
gmaclennan Nov 21, 2023
cd89ec4
move utils-new into utils
gmaclennan Nov 21, 2023
1f67ba8
Merge branch 'main' into feat/initial-download
gmaclennan Nov 23, 2023
83ffe92
Add debug info to test that sometimes fails
gmaclennan Nov 23, 2023
4b0c71b
Update package-lock.json version
gmaclennan Nov 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 145 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"devDependencies": {
"@bufbuild/buf": "^1.26.1",
"@hyperswarm/testnet": "^3.1.2",
"@mapeo/mock-data": "^1.0.1",
"@sinonjs/fake-timers": "^10.0.2",
"@types/b4a": "^1.6.0",
"@types/debug": "^4.1.8",
Expand All @@ -92,6 +93,7 @@
"prettier": "^2.8.8",
"random-access-file": "^4.0.4",
"random-access-memory": "^6.2.0",
"random-bytes-readable-stream": "^3.0.0",
"rimraf": "^5.0.1",
"streamx": "^2.15.1",
"tempy": "^3.1.0",
Expand Down
10 changes: 8 additions & 2 deletions src/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export class Capabilities {
#projectCreatorAuthCoreId
#ownDeviceId

static NO_ROLE_CAPABILITIES = NO_ROLE_CAPABILITIES

/**
*
* @param {object} opts
Expand Down Expand Up @@ -209,17 +211,21 @@ export class Capabilities {
*/
async getAll() {
const roles = await this.#dataType.getMany()
/** @type {Record<string, Capability>} */
const capabilities = {}
let projectCreatorDeviceId
try {
projectCreatorDeviceId = await this.#coreOwnership.getOwner(
this.#projectCreatorAuthCoreId
)
// Default to creator capabilities, but can be overwritten if a different
// role is set below
capabilities[projectCreatorDeviceId] = CREATOR_CAPABILITIES
} catch (e) {
// Not found, we don't know who the project creator is so we can't include
// them in the returned map
}
/** @type {Record<string, Capability>} */
const capabilities = {}

for (const role of roles) {
const deviceId = role.docId
if (!isKnownRoleId(role.roleId)) continue
Expand Down
Loading
Loading