Skip to content

Commit 9b3a9a7

Browse files
committed
feat: add peerinfopb
1 parent 8cf8035 commit 9b3a9a7

9 files changed

Lines changed: 67 additions & 33 deletions

File tree

Cargo.lock

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

crates/charon/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ license.workspace = true
77
publish.workspace = true
88

99
[dependencies]
10+
prost.workspace = true
11+
prost-types.workspace = true
12+
13+
[build-dependencies]
14+
charon-build-proto.workspace = true
1015

1116
[lints]
1217
workspace = true

crates/charon/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//! # Charon Peerinfo Build Script
2+
//!
3+
//! This build script compiles the protobuf files.
4+
5+
use std::io::Result;
6+
7+
fn main() -> Result<()> {
8+
charon_build_proto::compile_protos("src/peerinfo/peerinfopb/v1")
9+
}

crates/charon/src/lib.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,5 @@
44
//! coordination for Ethereum 2.0 validators. This crate serves as the primary
55
//! entry point for the Charon distributed validator node implementation.
66
7-
/// Adds two numbers together.
8-
///
9-
/// # Arguments
10-
///
11-
/// * `left` - The first number to add
12-
/// * `right` - The second number to add
13-
///
14-
/// # Returns
15-
///
16-
/// The sum of the two numbers
17-
///
18-
/// # Examples
19-
///
20-
/// ```
21-
/// use charon::add;
22-
///
23-
/// let result = add(2, 2);
24-
/// assert_eq!(result, 4);
25-
/// ```
26-
pub fn add(left: u64, right: u64) -> u64 {
27-
left.wrapping_add(right)
28-
}
29-
30-
#[cfg(test)]
31-
mod tests {
32-
use super::*;
33-
34-
#[test]
35-
fn it_works() {
36-
let result = add(2, 2);
37-
assert_eq!(result, 4);
38-
}
39-
}
7+
/// Peerinfo.
8+
pub mod peerinfo;

crates/charon/src/peerinfo/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// Peerinfo protobuf definitions.
2+
pub mod peerinfopb;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// V1
2+
pub mod v1;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// Peerinfo protobuf definitions.
2+
pub mod peerinfo;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package peerinfo;
4+
5+
import "google/protobuf/timestamp.proto";
6+
7+
message PeerInfo {
8+
string charon_version = 1;
9+
bytes lock_hash = 2;
10+
optional google.protobuf.Timestamp sent_at = 3;
11+
string git_hash = 4;
12+
optional google.protobuf.Timestamp started_at = 5;
13+
bool builder_api_enabled = 6;
14+
string nickname = 7;
15+
16+
// NOTE: Always populate timestamps when sending, then make them required after subsequent release.
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This file is @generated by prost-build.
2+
#![allow(dead_code)]
3+
#![allow(missing_docs)]
4+
#![allow(clippy::all)]
5+
#![allow(rustdoc::all)]
6+
7+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
8+
pub struct PeerInfo {
9+
#[prost(string, tag = "1")]
10+
pub charon_version: ::prost::alloc::string::String,
11+
#[prost(bytes = "bytes", tag = "2")]
12+
pub lock_hash: ::prost::bytes::Bytes,
13+
#[prost(message, optional, tag = "3")]
14+
pub sent_at: ::core::option::Option<::prost_types::Timestamp>,
15+
#[prost(string, tag = "4")]
16+
pub git_hash: ::prost::alloc::string::String,
17+
#[prost(message, optional, tag = "5")]
18+
pub started_at: ::core::option::Option<::prost_types::Timestamp>,
19+
#[prost(bool, tag = "6")]
20+
pub builder_api_enabled: bool,
21+
#[prost(string, tag = "7")]
22+
pub nickname: ::prost::alloc::string::String,
23+
}

0 commit comments

Comments
 (0)