Skip to content

Commit 0b5486f

Browse files
committed
listerner setup + cli + rust workflow
1 parent c896cc6 commit 0b5486f

File tree

6 files changed

+68
-6
lines changed

6 files changed

+68
-6
lines changed

.github/workflows/rust.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
rustfmt:
14+
name: Rustfmt
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
- name: Check formatting
20+
run: cargo fmt --all --check
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Build
26+
run: cargo build --verbose
27+
- name: Run tests
28+
run: cargo test --verbose
29+
clippy:
30+
name: Clippy
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v3
35+
- name: Run clippy
36+
run: cargo clippy --all-targets --all-features -- -D warnings
37+
test:
38+
name: Test
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v3
43+
- name: Run tests
44+
run: cargo test --verbose

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Blockchain Node
2+
3+
# Tasks
4+
5+
- [ ] Consensus Algorithm
6+
- [ ] Networking
7+
- [ ] Temp Storage

src/comms/message.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[derive(Debug)]
2+
pub enum Message {
3+
RememeberMe,
4+
}

src/comms/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod message;

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod cli;
2+
pub mod comms;
23

34
pub mod tracing {
45
use tracing_subscriber::{EnvFilter, layer::SubscriberExt as _};

src/main.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::net::{Ipv4Addr, SocketAddrV4, TcpListener};
1+
use std::{
2+
io::Read,
3+
net::{Ipv4Addr, SocketAddrV4, TcpListener},
4+
};
25

36
use clap::Parser as _;
47
use peer_node::cli::Args;
@@ -14,10 +17,12 @@ async fn main() -> Result<(), std::io::Error> {
1417
tracing::info!("Node address: {}", address);
1518
tracing::info!("A {}", args.role);
1619

17-
for _incoming_stream in listerner.incoming().flatten() {
18-
// incoming_stream
19-
}
20+
loop {
21+
for mut incoming_stream in listerner.incoming().flatten() {
22+
let mut msg = [0; 16];
23+
let _byte_count = incoming_stream.read(&mut msg)?;
2024

21-
// loop {}
22-
Ok(())
25+
tracing::info!("Message received: {:?}", msg);
26+
}
27+
}
2328
}

0 commit comments

Comments
 (0)