Skip to content

Commit

Permalink
Merge branch 'decouple/jsonrpc/remove-actix' into decouple/jsonrpc/me…
Browse files Browse the repository at this point in the history
…rge-parser-errors
  • Loading branch information
miraclx committed May 30, 2022
2 parents 6f4ef65 + f516a37 commit cd41125
Show file tree
Hide file tree
Showing 19 changed files with 806 additions and 227 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions chain/client-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ actix = "0.13.0"
chrono = { version = "0.4.4", features = ["serde"] }
strum = { version = "0.24", features = ["derive"] }
thiserror = "1.0"
serde_json = "1"
serde = { version = "1", features = ["derive"] }



near-chain-primitives = { path = "../chain-primitives" }
near-chain-configs = { path = "../../core/chain-configs" }
Expand Down
43 changes: 35 additions & 8 deletions chain/client-primitives/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ use near_primitives::types::{
use near_primitives::utils::generate_random_string;
use near_primitives::views::validator_stake_view::ValidatorStakeView;
use near_primitives::views::{
BlockView, ChunkView, EpochValidatorInfo, ExecutionOutcomeWithIdView,
FinalExecutionOutcomeViewEnum, GasPriceView, LightClientBlockLiteView, LightClientBlockView,
QueryRequest, QueryResponse, ReceiptView, StateChangesKindsView, StateChangesRequestView,
StateChangesView,
BlockView, ChunkView, DebugBlockStatus, EpochInfoView, EpochValidatorInfo,
ExecutionOutcomeWithIdView, FinalExecutionOutcomeViewEnum, GasPriceView,
LightClientBlockLiteView, LightClientBlockView, QueryRequest, QueryResponse, ReceiptView,
StateChangesKindsView, StateChangesRequestView, StateChangesView, TrackedShardsView,
};
pub use near_primitives::views::{StatusResponse, StatusSyncInfo};
use serde::Serialize;

/// Combines errors coming from chain, tx pool and block producer.
#[derive(Debug, thiserror::Error)]
Expand All @@ -41,7 +42,7 @@ pub enum Error {
Other(String),
}

#[derive(Debug)]
#[derive(Debug, Serialize)]
pub struct DownloadStatus {
pub start_time: DateTime<Utc>,
pub prev_update_time: DateTime<Utc>,
Expand All @@ -67,7 +68,7 @@ impl Clone for DownloadStatus {
}

/// Various status of syncing a specific shard.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize)]
pub enum ShardSyncStatus {
StateDownloadHeader,
StateDownloadParts,
Expand All @@ -79,14 +80,14 @@ pub enum ShardSyncStatus {
StateSyncDone,
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize)]
pub struct ShardSyncDownload {
pub downloads: Vec<DownloadStatus>,
pub status: ShardSyncStatus,
}

/// Various status sync can be in, whether it's fast sync or archival.
#[derive(Clone, Debug, strum::AsRefStr)]
#[derive(Clone, Debug, strum::AsRefStr, Serialize)]
pub enum SyncStatus {
/// Initial state. Not enough peers to do anything yet.
AwaitingPeers,
Expand Down Expand Up @@ -335,6 +336,32 @@ pub struct Status {
pub detailed: bool,
}

// Different debug requests that can be sent by HTML pages, via GET.
pub enum DebugStatus {
// Request for the current sync status
SyncStatus,
// Request currently tracked shards
TrackedShards,
// Detailed information about last couple epochs.
EpochInfo,
// Detailed information about last couple blocks.
BlockStatus,
}

impl Message for DebugStatus {
type Result = Result<DebugStatusResponse, StatusError>;
}

#[derive(Serialize, Debug)]
pub enum DebugStatusResponse {
SyncStatus(SyncStatus),
TrackedShards(TrackedShardsView),
// List of epochs - in descending order (next epoch is first).
EpochInfo(Vec<EpochInfoView>),
// Detailed information about blocks.
BlockStatus(Vec<DebugBlockStatus>),
}

#[derive(thiserror::Error, Debug)]
pub enum StatusError {
#[error("Node is syncing")]
Expand Down
Loading

0 comments on commit cd41125

Please sign in to comment.