Skip to content

Switch to using state channels for packets #95

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

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
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
112 changes: 15 additions & 97 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ serde = "1"
serde_derive = "1"
serde_json = "1"
http-serde = "1"
tokio = { version = "1", default-features=false, features=["macros", "signal", "rt", "process"] }
tokio-stream = "0"
tokio = { version = "1", default-features=false, features=["fs", "macros", "signal", "rt", "process"] }
tokio-stream = {version = "0", features = ["fs"] }
futures = "*"
triggered = "0.1"
slog = "2"
Expand All @@ -47,9 +47,7 @@ bytes = "*"
xxhash-c = "0.8"
xorf = "0.7"
sha2 = "0"
chrono = "0"
angry-purple-tiger = "0"
rusqlite = {version = "0", features = ["bundled", "chrono"]}
lorawan = { package = "lorawan", path = "lorawan" }
semtech-udp = { version = ">=0.7,<1", default-features=false, features=["server"] }
helium-proto = { git = "https://github.com/helium/proto", branch="master", features=["services"]}
Expand Down
1 change: 1 addition & 0 deletions config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ command = "/etc/helium_gateway/install_update"

[cache]
store = "/etc/helium_gateway/cache"
max_packets = 20

# A list of gateway service keys and urls (note https is not supported
[[gateways]]
Expand Down
32 changes: 28 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub enum Error {
StateChannel(#[from] StateChannelError),
#[error("semtech udp error")]
Semtech(#[from] semtech_udp::server_runtime::Error),
#[error("storage error")]
Store(#[from] rusqlite::Error),
#[error("time error")]
Time(#[from] std::time::SystemTimeError),
}

#[derive(Error, Debug)]
Expand Down Expand Up @@ -65,14 +65,22 @@ pub enum ServiceError {

#[derive(Error, Debug)]
pub enum StateChannelError {
#[error("no state channel")]
NotFound,
#[error("inactive state channel")]
Inactive,
#[error("invalid owner for state channel")]
InvalidOwner,
#[error("state channel summary error")]
Summary(#[from] StateChannelSummaryError),
#[error("state channel not found")]
NotFound,
#[error("state channel causal conflict")]
CausalConflict,
#[error("state channel overpaid")]
Overpaid,
#[error("state channel underpaid for a packet")]
Underpaid,
#[error("state channel low balance too low")]
LowBalance,
}

#[derive(Error, Debug)]
Expand Down Expand Up @@ -135,6 +143,22 @@ impl StateChannelError {
pub fn not_found() -> Error {
Error::StateChannel(Self::NotFound)
}

pub fn causal_conflict() -> Error {
Error::StateChannel(Self::CausalConflict)
}

pub fn overpaid() -> Error {
Error::StateChannel(Self::Overpaid)
}

pub fn underpaid() -> Error {
Error::StateChannel(Self::Underpaid)
}

pub fn low_balance() -> Error {
Error::StateChannel(Self::LowBalance)
}
}

impl Error {
Expand Down
Loading