Skip to content

Commit

Permalink
[data-client] Print less debug info for GlobalDataSummary
Browse files Browse the repository at this point in the history
Closes: #10057
  • Loading branch information
khiemngo authored and bors-libra committed Dec 20, 2021
1 parent bf16231 commit accd358
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
3 changes: 0 additions & 3 deletions state-sync/diem-data-client/src/diemnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ impl DiemNetDataClient {

match result {
Ok(response) => {
// TODO(khiemngo): consider logging response payload
// after we override Debug for some response types with large payload.
debug!(
(LogSchema::new(LogEntry::StorageServiceResponse)
.event(LogEvent::ResponseSuccess)
Expand Down Expand Up @@ -507,7 +505,6 @@ impl DataSummaryPoller {
self.data_client.update_summary(peer, storage_summary);
self.data_client.update_global_summary_cache();

// TODO(khiemngo): implement overriding Debug for GlobalDataSummary struct
debug!(
(LogSchema::new(LogEntry::PeerStates)
.event(LogEvent::AggregateSummary)
Expand Down
16 changes: 15 additions & 1 deletion state-sync/diem-data-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl OptimalChunkSizes {
}

/// A summary of all data that is currently advertised in the network.
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Eq, PartialEq)]
pub struct AdvertisedData {
/// The ranges of account states advertised, e.g., if a range is
/// (X,Y), it means all account states are held for every version X->Y
Expand All @@ -307,6 +307,20 @@ pub struct AdvertisedData {
pub transaction_outputs: Vec<CompleteDataRange<Version>>,
}

impl fmt::Debug for AdvertisedData {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let sync_lis = (&self.synced_ledger_infos)
.iter()
.map(|LedgerInfoWithSignatures::V0(ledger)| format!("{}", ledger))
.join(", ");
write!(
f,
"account_states: {:?}, epoch_ending_ledger_infos: {:?}, synced_ledger_infos: [{}], transactions: {:?}, transaction_outputs: {:?}",
&self.account_states, &self.epoch_ending_ledger_infos, sync_lis, &self.transactions, &self.transaction_outputs
)
}
}

impl AdvertisedData {
pub fn empty() -> Self {
AdvertisedData {
Expand Down
7 changes: 6 additions & 1 deletion types/src/ledger_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ pub struct LedgerInfoWithV0 {

impl Display for LedgerInfoWithV0 {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "{}", self.ledger_info)
write!(
f,
"LedgerInfo {{ commit_info: BlockInfo {{ epoch: {:?}, version: {:?} }} }}",
self.ledger_info.commit_info().epoch(),
self.ledger_info.commit_info().version()
)
}
}

Expand Down

0 comments on commit accd358

Please sign in to comment.