Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamp_usecs to transactions #1241

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions json-rpc/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub fn get_account_transaction(

if let Some(tx) = tx {
Ok(Some(TransactionView::try_from_tx_and_events(
db.get_block_timestamp(tx.version).unwrap(),
tx.version,
tx.transaction,
tx.proof.transaction_info,
Expand Down Expand Up @@ -180,6 +181,7 @@ pub fn get_account_transactions(
.ok_or_else(|| format_err!("Can not find transaction for seq {}!", seq))?;

let tx_view = TransactionView::try_from_tx_and_events(
db.get_block_timestamp(tx.version).unwrap(),
tx.version,
tx.transaction,
tx.proof.transaction_info,
Expand Down
5 changes: 4 additions & 1 deletion json-rpc/types/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ impl From<&KeptVMStatus> for VMStatusView {

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct TransactionView {
pub timestamp_usecs: u64,
pub version: u64,
pub transaction: TransactionDataView,
pub hash: HashValue,
Expand All @@ -729,6 +730,7 @@ pub struct TransactionView {

impl TransactionView {
pub fn try_from_tx_and_events(
timestamp_usecs: u64,
version: u64,
tx: Transaction,
tx_info: TransactionInfo,
Expand All @@ -740,6 +742,7 @@ impl TransactionView {
.collect::<Result<Vec<_>>>()?;

Ok(TransactionView {
timestamp_usecs,
version,
hash: tx.hash(),
bytes: BytesView::new(bcs::to_bytes(&tx)?),
Expand Down Expand Up @@ -804,7 +807,7 @@ impl TryFrom<TransactionListWithProof> for TransactionListView {
let tx_list = iter
.map(|(((offset, tx), tx_info), tx_events)| {
let version = start_version + offset as u64;
TransactionView::try_from_tx_and_events(version, tx, tx_info, tx_events)
TransactionView::try_from_tx_and_events(0, version, tx, tx_info, tx_events)
})
.collect::<Result<Vec<_>>>()?;

Expand Down