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

feature/broadcast-trees #89

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 26 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
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ identifier_name:
excluded:
- id
- to
- i
disabled_rules:
- trailing_comma
106 changes: 106 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.1)
activesupport (4.2.11.1)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
algoliasearch (1.27.1)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.0.3)
cocoapods (1.8.4)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.8.4)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.2.2, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.4.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.6.6)
nap (~> 1.0)
ruby-macho (~> 1.4)
xcodeproj (>= 1.11.1, < 2.0)
cocoapods-core (1.8.4)
activesupport (>= 4.0.2, < 6)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.2.2)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.1.0)
cocoapods-trunk (1.4.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.1.6)
escape (0.0.4)
ffi (1.12.2)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
jazzy (0.11.1)
cocoapods (~> 1.5)
mustache (~> 1.1)
open4
redcarpet (~> 3.4)
rouge (>= 2.0.6, < 4.0)
sassc (~> 2.1)
sqlite3 (~> 1.3)
xcinvoke (~> 0.3.0)
json (2.2.0)
liferaft (0.0.6)
minitest (5.14.0)
molinillo (0.6.6)
mustache (1.1.0)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.11.0)
open4 (1.3.4)
redcarpet (3.5.0)
rouge (2.0.7)
ruby-macho (1.4.0)
sassc (2.2.1)
ffi (~> 1.9)
sqlite3 (1.4.1)
thread_safe (0.3.6)
tzinfo (1.2.6)
thread_safe (~> 0.1)
xcinvoke (0.3.0)
liferaft (~> 0.0.6)
xcodeproj (1.12.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.6)
xcpretty (0.3.0)
rouge (~> 2.0.7)

PLATFORMS
ruby

DEPENDENCIES
jazzy (= 0.11.1)
xcpretty

BUNDLED WITH
2.1.4
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: docs format test lint xcode linuxmain autocorrect clean test build
.PHONY: docs format test lint xcode linuxmain autocorrect clean test build protobuf

APP="UB"

Expand Down Expand Up @@ -48,3 +48,6 @@ linuxmain:

format:
swiftformat .

protobuf:
protoc --swift_out=Sources/UB/Protobuf/ --proto_path=../protobufs/ Packet.proto
18 changes: 18 additions & 0 deletions Sources/UB/Extensions/Array.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation

extension Array where Element == Addr {
func closest(to: Addr) -> Addr? {
var distance = 0
var addr: Addr?

forEach { peer in
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh true

let dist = peer.distance(to: to)
if distance > dist {
distance = dist
addr = peer
}
}

return addr
}
}
11 changes: 11 additions & 0 deletions Sources/UB/Extensions/Packet.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Foundation

extension Packet {
static func new(topic: Data, type: TypeEnum, body: Data) -> Packet {
return Packet.with {
$0.topic = topic
$0.type = type
$0.body = body
}
}
}
61 changes: 0 additions & 61 deletions Sources/UB/Message.swift

This file was deleted.

Loading