Skip to content

Commit

Permalink
feat(repo): Added blocks rest endpoint (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xterminator authored Feb 21, 2025
1 parent bbddcb0 commit 32d087d
Show file tree
Hide file tree
Showing 13 changed files with 590 additions and 25 deletions.
48 changes: 48 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sha2 = "0.10"
sqlx = { version = "0.8.3", default-features = false, features = [
"chrono",
"macros",
"postgres",
"runtime-tokio",
Expand Down
4 changes: 4 additions & 0 deletions crates/domains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ version.workspace = true

[dependencies]
async-trait.workspace = true
chrono.workspace = true
fuel-core.workspace = true
fuel-core-types.workspace = true
fuel-streams-store.workspace = true
Expand All @@ -20,6 +21,7 @@ fuel-streams-types.workspace = true
fuel-tx.workspace = true
fuel-vm.workspace = true
rayon.workspace = true
sea-query = "0.32.2"
serde.workspace = true
serde_json.workspace = true
sqlx.workspace = true
Expand All @@ -31,6 +33,8 @@ tokio.workspace = true
netlink-proto = { version = "=0.11.3", optional = true }

[dev-dependencies]
pretty_assertions.workspace = true
serde_urlencoded = "0.7.1"
test-case.workspace = true

[features]
Expand Down
3 changes: 3 additions & 0 deletions crates/domains/src/blocks/db_item.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::cmp::Ordering;

use chrono::{DateTime, Utc};
use fuel_streams_store::{
db::{DbError, DbItem},
record::{
Expand All @@ -23,6 +24,7 @@ pub struct BlockDbItem {
pub value: Vec<u8>,
pub block_height: i64,
pub producer_address: String,
pub timestamp: DateTime<Utc>,
}

impl DataEncoder for BlockDbItem {
Expand Down Expand Up @@ -62,6 +64,7 @@ impl TryFrom<&RecordPacket> for BlockDbItem {
value: packet.value.to_owned(),
block_height: subject.height.unwrap().into(),
producer_address: subject.producer.unwrap().to_string(),
timestamp: Utc::now(),
}),
_ => Err(RecordPacketError::SubjectMismatch),
}
Expand Down
1 change: 1 addition & 0 deletions crates/domains/src/blocks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod db_item;
mod packets;
pub mod queryable;
mod record_impl;
pub mod subjects;
pub mod types;
Expand Down
Loading

0 comments on commit 32d087d

Please sign in to comment.