Skip to content

Commit cdc79a7

Browse files
authored
Merge pull request helium#95 from helium/madninja/state_channels
Switch to using state channels for packets
2 parents 9e527cb + 8535e2d commit cdc79a7

20 files changed

+1041
-526
lines changed

Cargo.lock

Lines changed: 15 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ serde = "1"
2525
serde_derive = "1"
2626
serde_json = "1"
2727
http-serde = "1"
28-
tokio = { version = "1", default-features=false, features=["macros", "signal", "rt", "process"] }
29-
tokio-stream = "0"
28+
tokio = { version = "1", default-features=false, features=["fs", "macros", "signal", "rt", "process"] }
29+
tokio-stream = {version = "0", features = ["fs"] }
3030
futures = "*"
3131
triggered = "0.1"
3232
slog = "2"
@@ -47,9 +47,7 @@ bytes = "*"
4747
xxhash-c = "0.8"
4848
xorf = "0.7"
4949
sha2 = "0"
50-
chrono = "0"
5150
angry-purple-tiger = "0"
52-
rusqlite = {version = "0", features = ["bundled", "chrono"]}
5351
lorawan = { package = "lorawan", path = "lorawan" }
5452
semtech-udp = { version = ">=0.7,<1", default-features=false, features=["server"] }
5553
helium-proto = { git = "https://github.com/helium/proto", branch="master", features=["services"]}

config/default.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ command = "/etc/helium_gateway/install_update"
3131

3232
[cache]
3333
store = "/etc/helium_gateway/cache"
34+
max_packets = 20
3435

3536
# A list of gateway service keys and urls (note https is not supported
3637
[[gateways]]

src/error.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pub enum Error {
2323
StateChannel(#[from] StateChannelError),
2424
#[error("semtech udp error")]
2525
Semtech(#[from] semtech_udp::server_runtime::Error),
26-
#[error("storage error")]
27-
Store(#[from] rusqlite::Error),
26+
#[error("time error")]
27+
Time(#[from] std::time::SystemTimeError),
2828
}
2929

3030
#[derive(Error, Debug)]
@@ -65,14 +65,22 @@ pub enum ServiceError {
6565

6666
#[derive(Error, Debug)]
6767
pub enum StateChannelError {
68-
#[error("no state channel")]
69-
NotFound,
7068
#[error("inactive state channel")]
7169
Inactive,
7270
#[error("invalid owner for state channel")]
7371
InvalidOwner,
7472
#[error("state channel summary error")]
7573
Summary(#[from] StateChannelSummaryError),
74+
#[error("state channel not found")]
75+
NotFound,
76+
#[error("state channel causal conflict")]
77+
CausalConflict,
78+
#[error("state channel overpaid")]
79+
Overpaid,
80+
#[error("state channel underpaid for a packet")]
81+
Underpaid,
82+
#[error("state channel low balance too low")]
83+
LowBalance,
7684
}
7785

7886
#[derive(Error, Debug)]
@@ -135,6 +143,22 @@ impl StateChannelError {
135143
pub fn not_found() -> Error {
136144
Error::StateChannel(Self::NotFound)
137145
}
146+
147+
pub fn causal_conflict() -> Error {
148+
Error::StateChannel(Self::CausalConflict)
149+
}
150+
151+
pub fn overpaid() -> Error {
152+
Error::StateChannel(Self::Overpaid)
153+
}
154+
155+
pub fn underpaid() -> Error {
156+
Error::StateChannel(Self::Underpaid)
157+
}
158+
159+
pub fn low_balance() -> Error {
160+
Error::StateChannel(Self::LowBalance)
161+
}
138162
}
139163

140164
impl Error {

0 commit comments

Comments
 (0)