Skip to content
Open
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2244bb9
WIP
victorb May 17, 2018
463a3ac
Expire peers +_protect namespace if already exists when creating
victorb May 17, 2018
2a93a8b
Store to handle global namespace
victorb May 17, 2018
8573cff
WIP
victorb May 19, 2018
935f925
Make the store tests pass
victorb May 21, 2018
2556b06
feat: New state-based system
mkg20001 May 19, 2018
b5f2197
Fixes for state system
mkg20001 May 19, 2018
be3ab16
Fix a race cond in dial
mkg20001 May 19, 2018
56a6549
Add discover function
mkg20001 May 19, 2018
840a3a6
misc: lint
mkg20001 May 19, 2018
6fe96e1
test: Fix browser tests
mkg20001 May 19, 2018
6e4df35
chore: upgrade deps
mkg20001 Jun 8, 2018
050c78a
Add clearEmptyNamespaces function to store
mkg20001 Jun 8, 2018
8815ae0
Split utils in store
mkg20001 Jun 8, 2018
ddbe9aa
Begin rewriting server
mkg20001 Jun 8, 2018
8540852
Add missing handlers for discover/unregister
mkg20001 Jun 8, 2018
5325c92
Tweaks
mkg20001 Jun 8, 2018
55eae94
Finish register
mkg20001 Jun 8, 2018
dc5d317
Tweaks
mkg20001 Jun 8, 2018
baa64b2
Rm duplicate code
mkg20001 Jun 8, 2018
152d91a
Finish discover on server
mkg20001 Jun 9, 2018
f7ea0e0
WIP client rewrite
mkg20001 Jun 9, 2018
d97dca5
WIP
mkg20001 Jun 9, 2018
aa0ca21
fix
mkg20001 Jun 9, 2018
118c6cd
Client sync function
mkg20001 Jun 9, 2018
1d3f6d5
Clean
mkg20001 Jun 9, 2018
c3586f3
Work on tests
mkg20001 Jun 9, 2018
6c5b371
Clean
mkg20001 Jun 9, 2018
9c4a7f4
More work on tests
mkg20001 Jun 9, 2018
ca335b2
Rename files
mkg20001 Jun 9, 2018
8bf0ca8
Work on tests
mkg20001 Jun 9, 2018
0c3b76b
More work on tests
mkg20001 Jun 9, 2018
e14743a
fix
mkg20001 Jun 9, 2018
b754102
WIP
mkg20001 Jun 10, 2018
91e2e9a
WIP tests
mkg20001 Jun 11, 2018
d05c234
More fix
mkg20001 Jun 11, 2018
056db10
Fix tests
mkg20001 Jun 11, 2018
4981c54
Cleanup
mkg20001 Jun 11, 2018
ed735ed
Rm yarn.lock
mkg20001 Jun 11, 2018
f78da18
More cleanup
mkg20001 Jun 11, 2018
9482c06
Cleanup
mkg20001 Jun 11, 2018
0c23e11
More fixes - Libp2p discover interface
mkg20001 Jun 11, 2018
055b0f0
Better cookie
mkg20001 Jun 11, 2018
bd70e66
Sync on disconnect
mkg20001 Jun 11, 2018
5590e63
Tiny fix
mkg20001 Jun 11, 2018
9985dbb
Enable circuit - Dial test
mkg20001 Jun 12, 2018
10f6880
Merge branch 'master' into feat/improve-and-cleanup
jacobheun Feb 1, 2019
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
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
mkg20001 committed Jun 9, 2018
commit d97dca597cc462c8cc19735d2583e3dd44056a5e
15 changes: 15 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ class Client {

dial (peer) {
const id = peer.id.toB58String()

// check if we need to dial
if (this._failedCache[id]) return log('not dialing %s because dial previously failed', id)
if (this._dialLock[id]) return log('not dialing %s because dial is already in progress', id)
if (Sync.getPoint(this.store, id)) return log('not dialing %s because peer is already connected', id)

this._dialLock[id] = true // prevent race
log('dialing %s', id)

Expand All @@ -35,6 +38,7 @@ class Client {
log('dialing %s succeeded')
}

// do the actual dialing
this.swarm.dialProtocol(peer, '/p2p/rendezvous/1.0.0', (err, conn) => {
if (err) return cb(err)

Expand All @@ -50,9 +54,20 @@ class Client {
)

this.store = Sync.addPoint(this.store, id, rpc.rpc)
cb()
})
})
}

sync () {
if (this._syncLock) {
this._needResync = true
return
}
this._syncLock = true
log('syncing')
this.store = Sync.clearPoints(this.store)
}
}

module.exports = Client