tangle_indexer


git clone https://radroots.dev/git/tangle_indexer.git
Log | Files | Refs | Submodules | LICENSE

commit 643040091375a56717dbd0200d8af6b9209640b8
parent 00ea1b68d7e155abf77dd4c55333a6db8063d5ac
Author: triesap <triesap@radroots.dev>
Date:   Mon,  6 Oct 2025 16:36:01 +0100

Add workspace metadata and shared dependency configuration; align indexer crate configuration. Extend event metadata with `kind` and 64-bit timestamps.

Diffstat:
M.gitignore | 48+++++++++++++++---------------------------------
MCargo.lock | 1+
MCargo.toml | 26++++++++++++++++++++++++--
Mcrates/indexer/Cargo.toml | 35++++++++++++++++++-----------------
Mcrates/indexer/src/domain/events/listing.rs | 7++++++-
Mcrates/indexer/src/domain/events/profile.rs | 11++++++++---
Mcrates/indexer/src/domain/resolvers/profile.rs | 4++--
7 files changed, 74 insertions(+), 58 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,57 +1,39 @@ -# Dependencies +/target node_modules -.pnp -.pnp.js + +# Debug +logs/ # Local env files .env -.env.local -.env.development.local -.env.test.local -.env.production.local - -# Testing -coverage - -# Turbo -.turbo - -# Vercel -.vercel - -# Build Outputs -.next/ -out/ -build -dist -.yarn -target/ - -# Debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* +.env.* +!.env.example +!.env.test # OS .DS_Store Thumbs.db -#secrets +# secrets *.pem *.crt *.key +*.pem # local .tmp* -.backup* -.dev* -.local +.archive* +.local* .vscode notes*.txt notes*.md +notes*.json tree*.txt git-diff*.txt prompt*.txt tree*.txt justfile +# dev +*dev*.toml +*dev*.json diff --git a/Cargo.lock b/Cargo.lock @@ -1305,6 +1305,7 @@ dependencies = [ "rust_decimal", "rust_decimal_macros", "serde", + "typeshare", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml @@ -2,4 +2,27 @@ members = [ "crates/*", ] -resolver = "2" -\ No newline at end of file +resolver = "2" + +[workspace.package] +version = "0.1.0" +edition = "2024" +rust-version = "1.86.0" +license = "AGPL-3.0" + +[workspace.dependencies] +radroots-events = { path = "../../crates/crates/events" } +radroots-events-indexed = { path = "../../crates/crates/events-indexed" } + +anyhow = { version = "1" } +clap = { version = "4", features = ["derive"] } +config = { version = "0.15" } +serde = { version = "1", features = ["derive"] } +serde_json = { version = "1" } +thiserror = { version = "1" } +tokio = { version = "1", features = ["full"] } +tracing = { version = "0.1" } +tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] } +tracing-appender = { version = "0.2" } +once_cell = { version = "1" } +regex = { version = "1" } diff --git a/crates/indexer/Cargo.toml b/crates/indexer/Cargo.toml @@ -5,24 +5,25 @@ authors = ["Radroots Authors"] license = "AGPLv3" edition = "2021" +[features] +default = [] +audit = [] + [dependencies] indexer-utils = { path = "../indexer-utils" } -radroots-events = { path = "../../../../../crates/radroots-common/crates/events" } -radroots-events-indexed = { path = "../../../../../crates/radroots-common/crates/events-indexed" } +radroots-events = { workspace = true } +radroots-events-indexed = { workspace = true } -anyhow = "1.0" -clap = { version = "4", features = ["derive"] } -config = "0.15" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -thiserror = "1.0" -tokio = { version = "1", features = ["full"] } -tracing = "0.1" -tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] } -tracing-appender = "0.2" -once_cell = "1" -regex = "1" +anyhow = { workspace = true } +clap = { workspace = true } +config = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } +tracing-appender = { workspace = true } +once_cell = { workspace = true } +regex = { workspace = true } -[features] -default = [] -audit = [] diff --git a/crates/indexer/src/domain/events/listing.rs b/crates/indexer/src/domain/events/listing.rs @@ -17,6 +17,7 @@ fn create_radroots_listing_event_metadata( id: String, author: String, published_at: u32, + kind: u32, content: String, _tags: Vec<Vec<String>>, ) -> Result<RadrootsListingEventMetadata, RadrootsListingEventIndexError> { @@ -25,6 +26,7 @@ fn create_radroots_listing_event_metadata( id, author, published_at, + kind, listing, }) } @@ -39,10 +41,13 @@ impl ToRadrootsListingEventIndex for RelayIndexerEvent { fn to_radroots_listing_event( self, ) -> Result<RadrootsListingEventIndex, RadrootsListingEventIndexError> { + let kind_u32 = self.kind.as_u64() as u32; + let metadata = create_radroots_listing_event_metadata( self.id.clone(), self.author.clone(), self.created_at, + kind_u32, self.content.clone(), self.tags.clone(), )?; @@ -52,7 +57,7 @@ impl ToRadrootsListingEventIndex for RelayIndexerEvent { id: self.id, author: self.author, created_at: self.created_at, - kind: self.kind.as_u64() as u32, + kind: kind_u32, tags: self.tags, content: self.content, sig: self.sig, diff --git a/crates/indexer/src/domain/events/profile.rs b/crates/indexer/src/domain/events/profile.rs @@ -21,7 +21,8 @@ pub enum RadrootsProfileEventIndexError { pub fn create_radroots_profile_event_metadata( id: String, author: String, - published_at: u32, + published_at: u64, + kind: u32, content: String, tags: Vec<Vec<String>>, ) -> Result<RadrootsProfileEventMetadata, RadrootsProfileEventIndexError> { @@ -41,6 +42,7 @@ pub fn create_radroots_profile_event_metadata( id, author, published_at, + kind, profile, }) } @@ -55,10 +57,13 @@ impl ToRadrootsProfileEventIndex for RelayIndexerEvent { fn to_radroots_profile_event( self, ) -> Result<RadrootsProfileEventIndex, RadrootsProfileEventIndexError> { + let kind_u32 = self.kind.as_u64() as u32; + let metadata = create_radroots_profile_event_metadata( self.id.clone(), self.author.clone(), - self.created_at, + self.created_at as u64, + kind_u32, self.content.clone(), self.tags.clone(), )?; @@ -68,7 +73,7 @@ impl ToRadrootsProfileEventIndex for RelayIndexerEvent { id: self.id, author: self.author, created_at: self.created_at, - kind: self.kind.as_u64().try_into().unwrap(), + kind: kind_u32, content: self.content, tags: self.tags, sig: self.sig, diff --git a/crates/indexer/src/domain/resolvers/profile.rs b/crates/indexer/src/domain/resolvers/profile.rs @@ -9,7 +9,7 @@ pub struct ProfileResolver { impl ProfileResolver { pub fn from_metadata(raw_metadata: &[RelayIndexerEvent]) -> Self { - let mut latest: BTreeMap<String, (u32, String)> = BTreeMap::new(); + let mut latest: BTreeMap<String, (u64, String)> = BTreeMap::new(); for raw in raw_metadata { if let Ok(evt) = raw.clone().to_radroots_profile_event() { @@ -20,7 +20,7 @@ impl ProfileResolver { } let author = evt.event.author.to_lowercase(); - let ts = evt.metadata.published_at; + let ts: u64 = evt.metadata.published_at; match latest.get(&author) { Some(&(old_ts, _)) if old_ts >= ts => {} _ => {