iroha
iroha copied to clipboard
Separate the pipeline events into block and transaction events
Also consider switching the block events filtering to use height, as there's no real way to predict block hashes.
// IMO it should have the suffix `Box`
pub enum PipelineEventBox {
Block(BlockEvent),
Transaction(TransactionEvent),
}
struct BlockEvent {
pub status: BlockStatus,
// NOTE: Does it make sense to have hash filtering for blocks?
// because it's unpredictable which block will be constructed
// It might be only relevant when replaying blocks in which case we can use height
// pub hash: HashOf<SignedBlock>,
pub height: u64,
}
struct TransactionEvent {
pub status: TransactionStatus,
pub hash: HashOf<SignedTransaction>,
}
// FIXME: Some variants are never actually emitted. Fix this in the codebase
enum BlockStatus {
Validating,
Committed,
Rejected(crate::block::error::BlockRejectionReason),
}
// FIXME: Some variants are never actually emitted. Fix this in the codebase
enum TransactionStatus {
Validating,
// it's factually incorrect to say that transaction was committed unless block get committed
Approved,
// Rejected transactions are also committed
Rejected(crate::transaction::error::TransactionRejectionReason),
// I think we can emit a batch of committed transaction events at the time of block commit
Committed,
}
I think this makes more sense
Originally posted by @mversic in https://github.com/hyperledger/iroha/pull/4240#discussion_r1497192564