-
Notifications
You must be signed in to change notification settings - Fork 2
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
feature/broadcast-trees #89
base: master
Are you sure you want to change the base?
Conversation
Sources/UB/Extensions/Array.swift
Outdated
|
||
func closest(to: Addr) -> Addr? { | ||
|
||
var distance = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines should not have trailing semicolons.
We need to ensure that the last node in the tree, or a node without a “parent” sends the message to all its children. AKA we need to remove the exclude. |
|
||
XCTAssertEqual(0, transport.sent.count) | ||
let data = try! packet.serializedData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force tries should be avoided.
origin: Addr(repeating: 3, count: 3), | ||
message: Data(repeating: 0, count: 3) | ||
) | ||
let subscription = try! subscribe.serializedData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force tries should be avoided.
|
||
XCTAssertEqual(2, transport.sent.count) | ||
let data = try! unsubscribe.serializedData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force tries should be avoided.
|
||
node.send(message) | ||
let subscription = try! subscribe.serializedData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force tries should be avoided.
code climate is violent, pr looks good, still need to review it further |
guard let data = try? message.toProto().serializedData() else { | ||
let packet = Packet.new(topic: Data(topic), type: .message, body: data) | ||
guard let data = try? packet.serializedData() else { | ||
// @todo error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please panic or log
Sources/UB/Extensions/Array.swift
Outdated
var distance = 0 | ||
var addr: Addr? | ||
|
||
forEach { peer in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just call min(by:)
https://developer.apple.com/documentation/swift/array/2298201-min
Much more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh true
|
||
extension Array where Element == Addr { | ||
func closest(to: Addr) -> Addr? { | ||
return self.min { a, b in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name should be between 3 and 40 characters long: 'a'
|
||
extension Array where Element == Addr { | ||
func closest(to: Addr) -> Addr? { | ||
return self.min { a, b in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name should be between 3 and 40 characters long: 'b'
Code Climate has analyzed commit 6813cdf and detected 0 issues on this pull request. View more on Code Climate. |
closes #88 #51 #56
This PR is currently in draft.
SUBSCRIBE
,UNSUBSCRIBE
and regularMESSAGES
What we solve here is how to construct the tree, however we do not solve how messages would be distributed as we can't always directly contact the root.
Also note: Do we need to drop messages that come from a parent who we do not recognize as our parent? Or better said, do we drop messages from peers who are neither our children or parent?
We also need IDs, the current way the Addr works using the Bluetooth Mac will not work. We need the device to have the same ID for all it’s peers.
Another note, when trying to find a parent for a specific node we need to then check if self is closer than parent, if it is self is the parent.