mirror of
https://github.com/vacp2p/mvds.git
synced 2026-01-09 12:07:55 -05:00
Compare commits
4 Commits
v0.0.18
...
enhancemen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a26faf0145 | ||
|
|
5aa789e474 | ||
|
|
d704571299 | ||
|
|
786cff711a |
10
node/node.go
10
node/node.go
@@ -217,22 +217,26 @@ func (n *Node) onPayload(group state.GroupID, sender state.PeerID, payload proto
|
||||
// Acks, Requests and Offers are all arrays of bytes as protobuf doesn't allow type aliases otherwise arrays of messageIDs would be nicer.
|
||||
n.onAck(group, sender, payload.Acks)
|
||||
n.onRequest(group, sender, payload.Requests)
|
||||
n.onOffer(group, sender, payload.Offers)
|
||||
n.payloads.AddAcks(group, sender, n.onOffer(group, sender, payload.Offers)...)
|
||||
n.payloads.AddAcks(group, sender, n.onMessages(group, sender, payload.Messages)...)
|
||||
}
|
||||
|
||||
func (n *Node) onOffer(group state.GroupID, sender state.PeerID, offers [][]byte) {
|
||||
func (n *Node) onOffer(group state.GroupID, sender state.PeerID, offers [][]byte) [][]byte {
|
||||
acks := make([][]byte, 0)
|
||||
|
||||
for _, raw := range offers {
|
||||
id := toMessageID(raw)
|
||||
log.Printf("[%x] OFFER (%x -> %x): %x received.\n", group[:4], sender[:4], n.ID[:4], id[:4])
|
||||
|
||||
// @todo maybe ack?
|
||||
if n.store.Has(id) {
|
||||
acks = append(acks, raw)
|
||||
continue
|
||||
}
|
||||
|
||||
n.insertSyncState(group, id, sender, state.REQUEST)
|
||||
}
|
||||
|
||||
return acks
|
||||
}
|
||||
|
||||
func (n *Node) onRequest(group state.GroupID, sender state.PeerID, requests [][]byte) {
|
||||
|
||||
Reference in New Issue
Block a user