Skip to content

Commit

Permalink
timestamp -> block_timestamp, always return error
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx committed Feb 14, 2024
1 parent 6fab2a0 commit 81b7ebb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub enum ResolverError<M: Middleware> {
Middleware(String),
#[error("Block {0} containing Registry event not found")]
MissingBlock(U64),
#[error(transparent)]
Time(#[from] ethers::core::types::TimeError),
#[error("Block {0} timestamp out of range")]
TimestampOutOfRange(U64),
}
Expand Down
10 changes: 5 additions & 5 deletions lib/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<M> From<DIDRegistry<M>> for Resolver<M> {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EventContext {
/// the timestamp in nanoseconds in which the block from the document was built.
pub timestamp: i64,
pub block_timestamp: i64,
}

impl EventContext {
Expand All @@ -44,14 +44,14 @@ impl EventContext {
.get_block(meta.block_number)
.await
.map_err(|e| ResolverError::Middleware(e.to_string()))?;
let timestamp = block

let block_timestamp = block
.ok_or(ResolverError::MissingBlock(meta.block_number))?
.time()
.unwrap_or_default()
.time()?
.timestamp_nanos_opt()
.ok_or(ResolverError::TimestampOutOfRange(meta.block_number))?;

Ok(Self { timestamp })
Ok(Self { block_timestamp })
}
}

Expand Down

0 comments on commit 81b7ebb

Please sign in to comment.