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

Rust server #3

Merged
merged 34 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d3199f7
init
p-shahi Mar 21, 2023
f1ce94a
add kad
p-shahi Mar 21, 2023
f62e4a5
add kad behaviour
p-shahi Mar 21, 2023
d806f67
feat: add ability to connect to multiaddr
2color Mar 21, 2023
093ddee
Update rust-server/Cargo.toml
2color Mar 21, 2023
ada67ba
add ping and keep alive
p-shahi Mar 21, 2023
159836b
ValidationMode permissive
p-shahi Mar 21, 2023
98aa57e
refactored to use dialProtocol + added ping
maschad Mar 22, 2023
6cadfaf
disable creating topic
p-shahi Mar 22, 2023
59f4c35
Apply suggestions from code review
2color Mar 22, 2023
bb43fcd
chore: update packages
2color Mar 22, 2023
592cb52
log full p2p address and fixes from pair with max
2color Mar 22, 2023
df59c56
.
p-shahi Mar 22, 2023
d1af50e
fix merge conflicts
p-shahi Mar 22, 2023
2c6f8f0
enable ping and increase idle timeout
2color Mar 22, 2023
03dcb3d
updates to frontend and js-libp2p
2color Mar 22, 2023
f9995a8
Update rust-server/Cargo.toml
p-shahi Mar 22, 2023
446db90
add dockerfile
2color Mar 22, 2023
390d557
deploy to fly
2color Mar 22, 2023
d96f54c
add fly config
2color Mar 22, 2023
680c8bd
listen and bind on port 5888
2color Mar 22, 2023
38bb908
enable manual deployment
2color Mar 22, 2023
bf1be77
enable logging
2color Mar 22, 2023
1531929
integrated explicit peer adding for gossipsub + added recurring messa…
maschad Mar 22, 2023
6f251c9
remove fly from pipeline
2color Mar 23, 2023
074b376
publish at even intervals
p-shahi Mar 24, 2023
0780b58
fix toml
p-shahi Mar 24, 2023
a7a0384
add message id function
p-shahi Mar 24, 2023
f40128c
forcefully add mesh peers to subscribers in js-gossipsub
maschad Mar 24, 2023
a8c18c8
reenable webtransport
p-shahi Mar 27, 2023
1faaaa5
revert custom js-libp2p-gossipsub branch
p-shahi Mar 27, 2023
4756648
Fix missing SUBSCRIBE and refactor
mxinden Mar 29, 2023
357f08e
Merge pull request #6 from mxinden/rust-server
p-shahi Mar 29, 2023
a40fa93
Merge branch 'main' into rust-server
p-shahi Mar 29, 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
249 changes: 124 additions & 125 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "next lint"
},
"dependencies": {
"@chainsafe/libp2p-gossipsub": "^6.2.0",
"@chainsafe/libp2p-gossipsub": "github:maschad/js-libp2p-gossipsub#fix/add-mesh-peers-to-sub",
"@chainsafe/libp2p-noise": "^11.0.0",
"@chainsafe/libp2p-yamux": "^3.0.5",
"@headlessui/react": "^1.7.13",
Expand Down
12 changes: 8 additions & 4 deletions packages/frontend/src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function ChatContainer() {
// Effect hook to subscribe to pubsub events and update the message state hook
useEffect(() => {
const messageCB = (message: CustomEvent<Message>) => {
console.log("gossipsub console log", message)
const { topic, data } = message.detail
const msg = new TextDecoder().decode(data)
console.log(`${topic}: ${msg}`)
Expand All @@ -35,10 +36,14 @@ export default function ChatContainer() {
const sendMessage = useCallback(async () => {
if (input === '') return

console.log('peers in gossip:', libp2p.pubsub.getSubscribers(CHAT_TOPIC).toString())

const res = await libp2p.pubsub.publish(
CHAT_TOPIC,
new TextEncoder().encode(input),
)
console.log('sent message to: ', res.recipients.map((peerId) => peerId.toString()))

setMessages([...messages, { msg: input, from: 'me' }])
setInput('')
}, [input, messages, setInput, libp2p])
Expand Down Expand Up @@ -74,7 +79,7 @@ export default function ChatContainer() {
<div className="lg:col-span-3 lg:block">
<div className="w-full">
<div className="relative flex items-center p-3 border-b border-gray-300">
{/* disable
{/* disable
<img
className="object-cover w-10 h-10 rounded-full"
src="https://github.com/achingbrain.png"
Expand All @@ -92,9 +97,8 @@ export default function ChatContainer() {
{messages.map(({ msg, from }, idx) => (
<li
key={idx}
className={`flex ${
from === 'me' ? 'justify-end' : 'justify-start'
}`}
className={`flex ${from === 'me' ? 'justify-end' : 'justify-start'
}`}
>
<div className="relative max-w-xl px-4 py-2 text-gray-700 rounded shadow">
<span className="block">{msg}</span>
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CHAT_TOPIC = 'universal-connectivity'
export const CHAT_TOPIC = "universal-connectivity"

// export const DEFAULT_APP_PEER = '12D3KooWBdmLJjhpgJ9KZgLM3f894ff9xyBfPvPjFNn7MKJpyrC2'
export const DEFAULT_APP_PEER = '12D3KooWRBy97UB99e3J6hiPesre1MZeuNQvfan4gBziswrRJsNK'
Loading