Coder Social home page Coder Social logo

ultralight-beam / ub.swift Goto Github PK

View Code? Open in Web Editor NEW
7.0 6.0 2.0 2.44 MB

Swift implementation of the ultralight beam protocol.

Home Page: https://swift.ultralightbeam.io

License: Apache License 2.0

Swift 90.91% Makefile 4.39% Ruby 4.70%
manet bluetooth wifi-direct ethereum

ub.swift's Introduction

UB.swift

Build Status License Maintainability Pod GitHub release (latest SemVer)

UB.swift is the swift implementation of the Ultralight Beam protocol, its primary focus is to provide an SDK for iOS and OSX devices.

Requirements

  • iOS 9 or later
  • OSX 10.13 or later
  • Swift 5.0 or later

Installation

dependencies: [
  .package(url: "https://github.com/ultralight-beam/UB.swift.git", from("0.1.0")),
],
targets: [
  .target(
    name: "Target",
    dependencies: ["UB"]
  ),
]
pod 'UB'

Usage

Using the UB within your own project is kept simple. Initialize a Node, and assign delegate which will then be notified of received messages. Various transports can be added to a Node enabling sending and receiving messages through them.

import UB

let node = Node()
node.delegate = self

node.add(transport: CoreBluetoothTransport())

node.send(...)

License

UB.swift is licensed under the Apache License

ub.swift's People

Contributors

decanus avatar tueric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

addressxception

ub.swift's Issues

CoreBluetooth Optimization

Problem

The current Bluetooth implementation created with #52 is not power efficient as it continuously scans for peripherals to connect with.

Currently all nodes are also peered with, this should also be thought about.

Acceptance Criteria

The bluetooth transport features two running modes, one lightweight and one less lightweight. The former will be more energy conservative to run efficiently on resource restricted devices. This means it does not perpetually scan for peripherals and disconnects after sending messages. Depending on how much a node talks to a given peer connections are kept open.

Notes

Remove `Message` in favour of `Packet`

Problem

We currently have 2 methods of representing a message that gets sent around within UB. One is the Message type and the other is the Packet protocol buffer. The main differences are the fact that the Message type is "more" type safe and has the last sender of a message.

Acceptance Criteria

We remove message from our codebase and pass around (last_sender, packet) as a tuple where necessary. Functions that are responsible for sending a message take the input parameters as UB specific types and later cast them to those required for the protobuf internally.

Better message routing

Problem

Right now message routing is pretty random, or better said non-existant at all. We need a method which allows users to more effectively route messages within the networks themselves.

Possible solution

After reading the scribe paper (notes), I believe I have found a possible solution.

Ideally we can build a pubsub network over our transports using multicast trees similarly to how scribe does.

This means that a peer knows what topic they want to subscribe to, they find their surrounding peer with the closest address using some distance metric. Let's say for example:

distance(topic, node) = topic XOR node

Now what we do is on the closest node we register that we want to subscribe to a given topic. If that node is also subscribe it adds us to its list, if not, it recursively registers on the next node. Until a root is hit.

To make the trees fault tolerant, if a disconnect is detected, the node registers at the next closest.

Consider turning the listen callback into a delegate function

Problem

Currently there is a transport.listen function which takes in a callback, this does not seem like it fits into the rest of the design of Ultralight Beam which often uses delegates.

Acceptance Criteria

Look at trade offs of leaving it a callback vs a delegate function and consider changing it if need be.

Rename `proto` to `service`

Problem

We currently use proto in the code base to describe ultralight beam services, this clashes with swifts protocol type.

Solution

The proto field is renamed to service everywhere.

Node.send should not take `Message`

Problem

The node.send function currently takes an argument of the type Message this isn't optimal as we cannot expect endusers to know all those fields.

Acceptance Criteria

There are 3 functions, each for sending a message.

Sending to an address:

send(to: UBID, message: Data)

Sending to a service:

send(service: UBID, message: Data)

Sending to an address and service, this function is called by the above functions.

send(to: UBID, service: UBID, message: Data)

Gemfile

Create a gemfile to handle our ruby dependencies such as xcpretty and jazzy.

Cleanup documentation comments

Problem

Sometimes certain terms are annotated like this or like this.

Acceptance Criteria

All terms are annotated in the same way.

Peer Discovery

Objective

Implement a peer discovery mechanism, similar to flood sub.

Github actions

Use github actions for both lint and test. Then we can remove travis and code climate.

Move Service handling from Relayer into UB

Problem

Services are a Relayer specific thing right now, this means that they can not be easily reused and added directly to a UB node.

Acceptance Criteria

There is message handling that is able to differentiate between a service specific and node specific messages, these messages are then handled accordingly. If they cannot be handled they are retransmitted.

Protocol Buffers

Problem

Currently there is no proper message serialization.

Acceptance Criteria

Use protocol buffers to have a common message serialization across implementations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.