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

Update architecture diagram. #60

Merged
merged 1 commit into from
Oct 9, 2019
Merged
Changes from all commits
Commits
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
150 changes: 75 additions & 75 deletions design/peers.txt
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
───────────────────────────────────────────────┐
│Peer: one or more futures │
│ ┌────────────┐ incoming messages │
│ │ TcpStream │ are sent to the │
│ └────────────┘ PeerClient, to
check if they are
responses, or else
to the PeerServer,
to check if they │
│ ┌────────────┐ are requests
Framed
Messages │─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│─ ─ ─
└────────────┘ last-seen timestamp channel │
║ mpsc channel or Service?
╠════════════════════════╗
│ ┌──────────────────┐ ──────────────────┐ │
PeerClient │ PeerServer
│ │sends reqs to peer│ │sends reqs to core│ │
│ │sends rsps to core│ │sends rsps to peer│ │
│ └──────────────────┘ └──────────────────┘ │
▲ │ │
└───────────┼────────────────────────┼──────────┘
│ │ │
┌───────────┼────────────────────────┼──────────┐
│ │ PeerSet: two Services │ │ │
plus bookkeeping ▼ │
│ ┌────────────────── ──────────────────┐ │ │
Client Server │ │ ┌─────────────────────────────┐
│ │ PeerConnector Service
load-balances │ routes inbound │ │ req: SocketAddr
│ │outbound reqs over│ │PeerServer reqs to│ │ │rsp: (PeerClient, PeerServer)│
│ │ available │ │internal Services │ │────────▶│ │
│ │ PeerClients │ │ performs handshakes,
│ │ drives peerset │ │ │ constructs peer futures │
│ │ drives peerset │ │ contraction via │ │ │ └─────────────────────────────┘
│ │ expansion via backpressure │ │
│ │ backpressure │ │ │ │ │
│ └──────────────────┘ └──────────────────┘ │
└───────────┼────────────────────────┼──────────┘
┌─────────────────────────────┐
│ PeerAddress Service
req: ()
│ │ │ rsp: SocketAddr
└────────────────────────┼────────────────────│
│ │returns the next addr to try
│ to connect to or asks
│existing peers for more addrs
└─────────────────────────────┘
│ ┌─────────────────────────────┐
│ AddressBook
└ ─▶│
per-addr last-seen info
─────────────────────────────┘
┌─────────────────────────────┐
AddressGossip Service
│ │ req: ()
└───────────────────▶│ rsp: Vec<MetaAddr>
│ │
│ truncates timestamps
└─────────────────────────────┘
──────▶ Channel
Legend:
━━━━━━▶ Service call

┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ PeerServer │ │ PeerServer │ │ PeerServer │ │ PeerServer
│ ┌───────┐ │ ┌───────┐ │ ┌───────┐ │ │ ┌───────┐
│ │┌─────┐│ │ │┌─────┐│ │ │┌─────┐│ │ │ │┌─────┐│
│ ││ Tcp ││ │ ││ Tcp ││ │ ││ Tcp ││ │ │ ││ Tcp ││
│ │└─────┘│───┼┐ │ │└─────┘│───┼┐ │ │└─────┘│───┼┐ │ │└─────┘│───┼┐
│ │Framed │ ││ │ │Framed │ ││ │ │Framed │ ││ │ │Framed │ │
│ │Stream│││Stream │ ││ │ │Stream │ ││ │ │Stream │
│ └───────┘│ │ └───────┘ ││ │ └───────┘ ││ │ └───────┘ ││
┏▶ ┃ ││ ┏▶│ ┃ ││ ┏▶│ ┃ ││ ┏▶│ ┃ │
││ ┃ │ ││ ┃ │ ││ ┃ │ ┃ │
││ ┃ │ ││ ┃ │ ▼ ││ ┃ │ ▼ │
┃ │ ┌───────┐ ││ ┃ │ ┌───────┐ ││ ┃ │ ┌───────┐ ││ ┃ │ ┌───────┐ │
┃ │ │ Tower │ ││ ┃ │ │ Tower │ ││ ┃ │ │ Tower │ ││ ┃ │ │ Tower
┃ │ │Buffer │ ││ ┃ │ │Buffer │ ││ ┃ │ │Buffer │ ││ ┃ │ │Buffer │
┃ │ └───────┘ ││ ┃ │ └─────── ││ ┃ │ └───────┘ ││ ┃ │ └───────┘ │
││ ┃ │ ┃ ││ ┃ │ ┃ ││ ┃ │ ┃ │
┃ └─────╋───────┘│ ┃ └─────╋───────┘│ ┃ └─────╋───────┘│ ┃ └─────╋───────┘
┃ └─╋───────╋────────┴─╋───────╋────────┴─╋───────╋────────┴─┐
┃ ┃ ┃ ┃ ┃ ┃ ┃
┗━━━━━━━━━━╋━━━━━━━┻━━━━━━━━━━╋━━━━━━━┻━━━━━━━━━━╋━━━━━━━┻━━━━━━━━━━╋━┓
┃ ┃ ┃ │ ┃
┗━━━━━━━━┓ ┗━━━━━━━━┓ ┗━━━━━━━━┓ ┗━━━━━━━━┓
┌───────╋──────────────────╋──────────────────╋──────────────────╋───────┐ │ ┃
│ ┃ ┃ ┃ ┃ │ │ ┃
│┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐│ │ ┃
││ PeerClient │ │ PeerClient │ PeerClient │ │ PeerClient ││ │ ┃
│└─────────────┘ └─────────────┘ ─────────────┘ └─────────────┘│ │ ┃
│ │ ┃
PeerSet │ │ ┃
req: Request, rsp: Response │ │ ┃
routes all outgoing requests, adds peers to handle load │ │ ┃
─────────────────────────────────────────────────────────┬──────────────┘ │ ┃
│ ┃
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ │ ┃
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━╋━┛
┃ ┌────────────────────────────────┐ ┌────────────────────────────┐
┃ │ Router │ PeerDiscover │
req: Request, rsp: Response│Discover<Service=PeerClient>│
│ routes all incoming requests, │
removes peers to shed load │ connects to a remote peer,
│ constructs client/server │ │
│ │ └────────────────────────────┘
└────────────────────────────────┘ └─────┐
┃ │
┌───────────────┐
│ PeerListener │
req: ? │
│rsp: PeerClient│ │
└───────────────┘
┌───────────────┐
│ PeerConnector │
┗━━━━▶│req: SocketAddr│ │
│rsp: PeerClient│ │
└───────────────┘
───────────────┐ │
┌───────────────┐ NextAddress │ │
┗━━━━━━━━━━━━━━━━━━━━━╋━━━━━│ AddrCrawler │─────────▶│ req: ()
└───────────────┘ │rsp: SocketAddr│
└───────────────┘
▲ │
┌───────────────┐ ┌───────────────┐
│ AddrService │ │ AddressBook │
┗━━━━▶│ req: GetPeers │◀─────────│ our per-peer │◀─┘
│ rsp: Peers │last-seen info
└───────────────┘ └───────────────┘