Skip to content

Commit

Permalink
Remove proto timestamp type for u64
Browse files Browse the repository at this point in the history
  • Loading branch information
brianp committed Oct 10, 2023
1 parent c8607cc commit 109a9bf
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 137 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

6 changes: 3 additions & 3 deletions applications/minotari_app_grpc/proto/network.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ message Peer {
/// Peer's addresses
repeated Address addresses = 3;
/// Last connection attempt to peer
google.protobuf.Timestamp last_connection = 4;
uint64 last_connection = 4;
/// Flags for the peer.
uint32 flags = 5;
google.protobuf.Timestamp banned_until= 6;
uint64 banned_until= 6;
string banned_reason= 7;
google.protobuf.Timestamp offline_at = 8;
uint64 offline_at = 8;
/// Features supported by the peer
uint32 features = 9;
/// used as information for more efficient protocol negotiation.
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_app_grpc/proto/wallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ message TransactionInfo {
uint64 fee = 7;
bool is_cancelled = 8;
bytes excess_sig = 9;
google.protobuf.Timestamp timestamp = 10;
uint64 timestamp = 10;
string message = 11;
}

Expand Down
12 changes: 8 additions & 4 deletions applications/minotari_app_grpc/src/conversions/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use tari_comms::{connectivity::ConnectivityStatus, net_address::MultiaddrWithStats, peer_manager::Peer};
use tari_utilities::ByteArray;

use crate::{conversions::naive_datetime_to_timestamp, tari_rpc as grpc};
use crate::tari_rpc as grpc;

#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::cast_sign_loss)]
Expand All @@ -32,14 +32,18 @@ impl From<Peer> for grpc::Peer {
let public_key = peer.public_key.to_vec();
let node_id = peer.node_id.to_vec();
let mut addresses = Vec::with_capacity(peer.addresses.len());
let last_connection = peer.addresses.last_seen().map(naive_datetime_to_timestamp);
let last_connection = peer
.addresses
.last_seen()
.map(|f| f.timestamp() as u64)
.unwrap_or_default();
for address in peer.addresses.addresses() {
addresses.push(address.clone().into())
}
let flags = u32::from(peer.flags.bits());
let banned_until = peer.banned_until.map(naive_datetime_to_timestamp);
let banned_until = peer.banned_until.map(|f| f.timestamp() as u64).unwrap_or_default();
let banned_reason = peer.banned_reason.to_string();
let offline_at = peer.offline_at().map(naive_datetime_to_timestamp);
let offline_at = peer.offline_at().map(|f| f.timestamp() as u64).unwrap_or_default();
let features = peer.features.bits();

let supported_protocols = peer.supported_protocols.into_iter().map(|p| p.to_vec()).collect();
Expand Down
111 changes: 54 additions & 57 deletions applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,59 +28,56 @@ use futures::{
SinkExt,
};
use log::*;
use minotari_app_grpc::{
conversions::naive_datetime_to_timestamp,
tari_rpc::{
self,
payment_recipient::PaymentType,
wallet_server,
CheckConnectivityResponse,
ClaimHtlcRefundRequest,
ClaimHtlcRefundResponse,
ClaimShaAtomicSwapRequest,
ClaimShaAtomicSwapResponse,
CoinSplitRequest,
CoinSplitResponse,
CommitmentSignature,
CreateBurnTransactionRequest,
CreateBurnTransactionResponse,
CreateTemplateRegistrationRequest,
CreateTemplateRegistrationResponse,
GetAddressResponse,
GetBalanceRequest,
GetBalanceResponse,
GetCoinbaseRequest,
GetCoinbaseResponse,
GetCompletedTransactionsRequest,
GetCompletedTransactionsResponse,
GetConnectivityRequest,
GetIdentityRequest,
GetIdentityResponse,
GetTransactionInfoRequest,
GetTransactionInfoResponse,
GetUnspentAmountsResponse,
GetVersionRequest,
GetVersionResponse,
ImportUtxosRequest,
ImportUtxosResponse,
RegisterValidatorNodeRequest,
RegisterValidatorNodeResponse,
RevalidateRequest,
RevalidateResponse,
SendShaAtomicSwapRequest,
SendShaAtomicSwapResponse,
SetBaseNodeRequest,
SetBaseNodeResponse,
TransactionDirection,
TransactionEvent,
TransactionEventRequest,
TransactionEventResponse,
TransactionInfo,
TransactionStatus,
TransferRequest,
TransferResponse,
TransferResult,
},
use minotari_app_grpc::tari_rpc::{
self,
payment_recipient::PaymentType,
wallet_server,
CheckConnectivityResponse,
ClaimHtlcRefundRequest,
ClaimHtlcRefundResponse,
ClaimShaAtomicSwapRequest,
ClaimShaAtomicSwapResponse,
CoinSplitRequest,
CoinSplitResponse,
CommitmentSignature,
CreateBurnTransactionRequest,
CreateBurnTransactionResponse,
CreateTemplateRegistrationRequest,
CreateTemplateRegistrationResponse,
GetAddressResponse,
GetBalanceRequest,
GetBalanceResponse,
GetCoinbaseRequest,
GetCoinbaseResponse,
GetCompletedTransactionsRequest,
GetCompletedTransactionsResponse,
GetConnectivityRequest,
GetIdentityRequest,
GetIdentityResponse,
GetTransactionInfoRequest,
GetTransactionInfoResponse,
GetUnspentAmountsResponse,
GetVersionRequest,
GetVersionResponse,
ImportUtxosRequest,
ImportUtxosResponse,
RegisterValidatorNodeRequest,
RegisterValidatorNodeResponse,
RevalidateRequest,
RevalidateResponse,
SendShaAtomicSwapRequest,
SendShaAtomicSwapResponse,
SetBaseNodeRequest,
SetBaseNodeResponse,
TransactionDirection,
TransactionEvent,
TransactionEventRequest,
TransactionEventResponse,
TransactionInfo,
TransactionStatus,
TransferRequest,
TransferResponse,
TransferResult,
};
use minotari_wallet::{
connectivity_service::{OnlineStatus, WalletConnectivityInterface},
Expand Down Expand Up @@ -777,7 +774,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
is_cancelled: txn.cancelled.is_some(),
direction: TransactionDirection::from(txn.direction) as i32,
fee: txn.fee.into(),
timestamp: Some(naive_datetime_to_timestamp(txn.timestamp)),
timestamp: txn.timestamp.timestamp() as u64,
excess_sig: txn
.transaction
.first_kernel_excess_sig()
Expand Down Expand Up @@ -1113,7 +1110,7 @@ fn convert_wallet_transaction_into_transaction_info(
direction: TransactionDirection::Inbound as i32,
fee: 0,
excess_sig: Default::default(),
timestamp: Some(naive_datetime_to_timestamp(tx.timestamp)),
timestamp: tx.timestamp.timestamp() as u64,
message: tx.message,
},
PendingOutbound(tx) => TransactionInfo {
Expand All @@ -1126,7 +1123,7 @@ fn convert_wallet_transaction_into_transaction_info(
direction: TransactionDirection::Outbound as i32,
fee: tx.fee.into(),
excess_sig: Default::default(),
timestamp: Some(naive_datetime_to_timestamp(tx.timestamp)),
timestamp: tx.timestamp.timestamp() as u64,
message: tx.message,
},
Completed(tx) => TransactionInfo {
Expand All @@ -1138,7 +1135,7 @@ fn convert_wallet_transaction_into_transaction_info(
is_cancelled: tx.cancelled.is_some(),
direction: TransactionDirection::from(tx.direction) as i32,
fee: tx.fee.into(),
timestamp: Some(naive_datetime_to_timestamp(tx.timestamp)),
timestamp: tx.timestamp.timestamp() as u64,
excess_sig: tx
.transaction
.first_kernel_excess_sig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ mod test {
};
use tari_service_framework::reply_channel;
use tari_test_utils::unpack_enum;
use tari_utilities::epoch_time::EpochTime;
use tokio::{sync::broadcast, task};

use super::*;
Expand Down Expand Up @@ -251,7 +252,7 @@ mod test {
]),
pruned_height: 0,
accumulated_difficulty: diff.to_be_bytes().to_vec(),
timestamp: 0,
timestamp: EpochTime::now().as_u64(),
}
}

Expand Down
8 changes: 5 additions & 3 deletions base_layer/wallet/tests/support/comms_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ use tari_core::{
},
transactions::transaction_components::{Transaction, TransactionOutput},
};
use tari_utilities::epoch_time::EpochTime;
use tokio::{sync::mpsc, time::sleep};

pub async fn connect_rpc_client<T>(connection: &mut PeerConnection) -> T
Expand Down Expand Up @@ -144,15 +145,15 @@ impl BaseNodeWalletRpcMockState {
tip_hash: Some(vec![]),
is_synced: true,
height_of_longest_chain: 0,
tip_mined_timestamp: 0,
tip_mined_timestamp: EpochTime::now().as_u64(),
})),
tip_info_response: Arc::new(Mutex::new(TipInfoResponse {
metadata: Some(ChainMetadataProto {
height_of_longest_chain: std::i64::MAX as u64,
best_block: Some(Vec::new()),
accumulated_difficulty: Vec::new(),
pruned_height: 0,
timestamp: 0,
timestamp: EpochTime::now().as_u64(),
}),
is_synced: true,
})),
Expand Down Expand Up @@ -879,6 +880,7 @@ mod test {
proto::base_node::{ChainMetadata, TipInfoResponse},
transactions::transaction_components::Transaction,
};
use tari_utilities::epoch_time::EpochTime;
use tokio::time::Duration;

use crate::support::comms_rpc::BaseNodeWalletRpcMockService;
Expand Down Expand Up @@ -935,7 +937,7 @@ mod test {
best_block: Some(Vec::new()),
accumulated_difficulty: Vec::new(),
pruned_height: 0,
timestamp: 0,
timestamp: EpochTime::now().as_u64(),
};
service_state.set_tip_info_response(TipInfoResponse {
metadata: Some(chain_metadata),
Expand Down
12 changes: 6 additions & 6 deletions base_layer/wallet/tests/transaction_service_tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3781,7 +3781,7 @@ async fn test_coinbase_generation_and_monitoring() {
block_hash: None,
confirmations: 0,
block_height: 0,
mined_timestamp: timestamp,
mined_timestamp: 0,
},
TxQueryBatchResponseProto {
signature: Some(SignatureProto::from(
Expand Down Expand Up @@ -3927,7 +3927,7 @@ async fn test_coinbase_abandoned() {
block_hash: None,
confirmations: 0,
block_height: 0,
mined_timestamp: timestamp,
mined_timestamp: 0,
}];

let batch_query_response = TxQueryBatchResponsesProto {
Expand Down Expand Up @@ -4052,7 +4052,7 @@ async fn test_coinbase_abandoned() {
block_hash: None,
confirmations: 0,
block_height: 0,
mined_timestamp: timestamp,
mined_timestamp: 0,
},
TxQueryBatchResponseProto {
signature: Some(SignatureProto::from(tx2.first_kernel_excess_sig().unwrap().clone())),
Expand Down Expand Up @@ -4138,15 +4138,15 @@ async fn test_coinbase_abandoned() {
block_hash: None,
confirmations: 0,
block_height: 0,
mined_timestamp: timestamp,
mined_timestamp: 0,
},
TxQueryBatchResponseProto {
signature: Some(SignatureProto::from(tx2.first_kernel_excess_sig().unwrap().clone())),
location: TxLocationProto::from(TxLocation::NotStored) as i32,
block_hash: None,
confirmations: 0,
block_height: 0,
mined_timestamp: timestamp,
mined_timestamp: 0,
},
];

Expand Down Expand Up @@ -4255,7 +4255,7 @@ async fn test_coinbase_abandoned() {
block_hash: None,
confirmations: 0,
block_height: 0,
mined_timestamp: timestamp,
mined_timestamp: 0,
},
TxQueryBatchResponseProto {
signature: Some(SignatureProto::from(tx2.first_kernel_excess_sig().unwrap().clone())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ async fn tx_validation_protocol_reorg() {
block_hash: None,
confirmations: 0,
block_height: 0,
mined_timestamp: timestamp,
mined_timestamp: 0,
},
TxQueryBatchResponseProto {
signature: Some(SignatureProto::from(
Expand All @@ -1282,7 +1282,7 @@ async fn tx_validation_protocol_reorg() {
block_hash: None,
confirmations: 0,
block_height: 0,
mined_timestamp: timestamp,
mined_timestamp: 0,
},
];

Expand Down
1 change: 0 additions & 1 deletion comms/dht/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ futures = "^0.3.1"
log = "0.4.8"
log-mdc = "0.1.0"
prost = "=0.9.0"
prost-types = "=0.9.0"
rand = "0.8"
serde = "1.0.90"
thiserror = "1.0.26"
Expand Down
Loading

0 comments on commit 109a9bf

Please sign in to comment.