-
Notifications
You must be signed in to change notification settings - Fork 41
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
BlockMetadataResponse 2.0 update #700
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ use alloc::{string::String, vec::Vec}; | |
use crate::types::block::{ | ||
output::{dto::OutputDto, OutputId, OutputMetadata, OutputWithMetadata}, | ||
protocol::ProtocolParameters, | ||
semantic::ConflictReason, | ||
slot::SlotIndex, | ||
BlockId, IssuerId, | ||
}; | ||
|
@@ -118,17 +119,35 @@ pub struct SubmitBlockResponse { | |
pub block_id: BlockId, | ||
} | ||
|
||
/// Describes the ledger inclusion state of a transaction. | ||
/// Describes the state of a block and/or transaction. | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
#[cfg_attr( | ||
feature = "serde", | ||
derive(serde::Serialize, serde::Deserialize), | ||
serde(rename_all = "camelCase") | ||
)] | ||
pub enum LedgerInclusionState { | ||
Conflicting, | ||
Included, | ||
NoTransaction, | ||
pub enum BlockTransactionState { | ||
// Stored but not confirmed or contains not yet included transaction. | ||
Pending, | ||
// Confirmed with the first level of knowledge. | ||
Confirmed, | ||
// Included and cannot be reverted anymore. | ||
Finalized, | ||
} | ||
|
||
/// Describes the reason of a block state. | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
#[cfg_attr( | ||
feature = "serde", | ||
derive(serde::Serialize, serde::Deserialize), | ||
serde(rename_all = "camelCase") | ||
)] | ||
#[non_exhaustive] | ||
#[repr(u8)] | ||
pub enum BlockStateReason { | ||
Invalid = 1, | ||
OrphanedCongestionControl = 2, | ||
OrphanedNegativeManaBalance = 3, | ||
} | ||
|
||
/// Response of GET /api/core/v3/blocks/{block_id}/metadata. | ||
|
@@ -141,22 +160,21 @@ pub enum LedgerInclusionState { | |
)] | ||
pub struct BlockMetadataResponse { | ||
pub block_id: BlockId, | ||
pub parents: Vec<BlockId>, | ||
pub is_solid: bool, | ||
pub strong_parents: Vec<BlockId>, | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add |
||
pub referenced_by_milestone_index: Option<u32>, | ||
pub weak_parents: Option<Vec<BlockId>>, | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub milestone_index: Option<u32>, | ||
pub shallow_like_parents: Option<Vec<BlockId>>, | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub ledger_inclusion_state: Option<LedgerInclusionState>, | ||
pub block_state: Option<BlockTransactionState>, | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub conflict_reason: Option<u8>, | ||
pub tx_state: Option<BlockTransactionState>, | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub white_flag_index: Option<u32>, | ||
pub block_state_reason: Option<BlockStateReason>, | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub should_promote: Option<bool>, | ||
pub tx_state_reason: Option<ConflictReason>, | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub should_reattach: Option<bool>, | ||
pub reissue_payload: Option<bool>, | ||
} | ||
|
||
/// Response of GET /api/core/v3/outputs/{output_id}. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,12 +45,15 @@ impl std::error::Error for ConflictError {} | |
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
#[packable(unpack_error = ConflictError)] | ||
#[packable(tag_type = u8, with_error = ConflictError::InvalidConflict)] | ||
// TODO may want to rename this to TransactionStateReason | ||
pub enum ConflictReason { | ||
/// The block has no conflict. | ||
None = 0, | ||
/// The referenced Utxo was already spent. | ||
InputUtxoAlreadySpent = 1, | ||
/// The referenced Utxo was already spent while confirming this milestone. | ||
/// TODO weird | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very weird! |
||
/// * `2` - denotes that the transaction is conflicting with another transaction. | ||
InputUtxoAlreadySpentInThisMilestone = 2, | ||
/// The referenced Utxo cannot be found. | ||
InputUtxoNotFound = 3, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.