From e35b35abc4b1b8316041bc71dbe7fe44785fdae0 Mon Sep 17 00:00:00 2001 From: bsbds <69835502+bsbds@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:34:26 +0800 Subject: [PATCH] chore: rename `SplitEntry` to `ConflictPoolEntry` Signed-off-by: bsbds <69835502+bsbds@users.noreply.github.com> --- crates/curp/src/server/conflict/mod.rs | 8 ++++---- .../curp/src/server/conflict/spec_pool_new.rs | 14 ++++++------- .../src/server/conflict/uncommitted_pool.rs | 20 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/crates/curp/src/server/conflict/mod.rs b/crates/curp/src/server/conflict/mod.rs index 07176758b..774e986cc 100644 --- a/crates/curp/src/server/conflict/mod.rs +++ b/crates/curp/src/server/conflict/mod.rs @@ -16,21 +16,21 @@ use crate::rpc::{ConfChange, PoolEntry, PoolEntryInner, ProposeId}; // TODO: relpace `PoolEntry` with this /// Entry stored in conflict pools -pub(super) enum SplitEntry { +pub(super) enum ConflictPoolEntry { /// A command entry Command(CommandEntry), /// A conf change entry ConfChange(ConfChangeEntry), } -impl From> for SplitEntry { +impl From> for ConflictPoolEntry { fn from(entry: PoolEntry) -> Self { match entry.inner { - PoolEntryInner::Command(c) => SplitEntry::Command(CommandEntry { + PoolEntryInner::Command(c) => ConflictPoolEntry::Command(CommandEntry { id: entry.id, cmd: c, }), - PoolEntryInner::ConfChange(c) => SplitEntry::ConfChange(ConfChangeEntry { + PoolEntryInner::ConfChange(c) => ConflictPoolEntry::ConfChange(ConfChangeEntry { id: entry.id, conf_change: c, }), diff --git a/crates/curp/src/server/conflict/spec_pool_new.rs b/crates/curp/src/server/conflict/spec_pool_new.rs index 34fbaf82d..41b186e4b 100644 --- a/crates/curp/src/server/conflict/spec_pool_new.rs +++ b/crates/curp/src/server/conflict/spec_pool_new.rs @@ -2,7 +2,7 @@ use curp_external_api::conflict::{ConflictPoolOp, SpeculativePoolOp}; use crate::rpc::PoolEntry; -use super::{CommandEntry, ConfChangeEntry, SplitEntry}; +use super::{CommandEntry, ConfChangeEntry, ConflictPoolEntry}; /// A speculative pool object pub type SpObject = Box> + Send + 'static>; @@ -30,15 +30,15 @@ impl SpeculativePool { return Some(entry); } - match SplitEntry::from(entry) { - SplitEntry::Command(c) => { + match ConflictPoolEntry::from(entry) { + ConflictPoolEntry::Command(c) => { for csp in &mut self.command_sps { if let Some(e) = csp.insert_if_not_conflict(c.clone()) { return Some(e.into()); } } } - SplitEntry::ConfChange(c) => { + ConflictPoolEntry::ConfChange(c) => { if !self .command_sps .iter() @@ -57,13 +57,13 @@ impl SpeculativePool { // TODO: Use reference instead of clone /// Removes an entry from the pool pub(crate) fn remove(&mut self, entry: PoolEntry) { - match SplitEntry::from(entry) { - SplitEntry::Command(c) => { + match ConflictPoolEntry::from(entry) { + ConflictPoolEntry::Command(c) => { for csp in &mut self.command_sps { csp.remove(c.clone()); } } - SplitEntry::ConfChange(c) => { + ConflictPoolEntry::ConfChange(c) => { self.conf_change_sp.remove(c); } } diff --git a/crates/curp/src/server/conflict/uncommitted_pool.rs b/crates/curp/src/server/conflict/uncommitted_pool.rs index a6a1e5cc2..ce2118fd3 100644 --- a/crates/curp/src/server/conflict/uncommitted_pool.rs +++ b/crates/curp/src/server/conflict/uncommitted_pool.rs @@ -2,7 +2,7 @@ use curp_external_api::conflict::{ConflictPoolOp, UncommittedPoolOp}; use crate::rpc::PoolEntry; -use super::{CommandEntry, ConfChangeEntry, SplitEntry}; +use super::{CommandEntry, ConfChangeEntry, ConflictPoolEntry}; /// An uncommitted pool object pub type UcpObject = Box> + Send + 'static>; @@ -30,13 +30,13 @@ impl UncommittedPool { conflict |= !self.conf_change_ucp.is_empty(); - match SplitEntry::from(entry) { - SplitEntry::Command(c) => { + match ConflictPoolEntry::from(entry) { + ConflictPoolEntry::Command(c) => { for cucp in &mut self.command_ucps { conflict |= cucp.insert(c.clone()); } } - SplitEntry::ConfChange(c) => { + ConflictPoolEntry::ConfChange(c) => { let _ignore = self.conf_change_ucp.insert(c); conflict |= !self .command_ucps @@ -51,13 +51,13 @@ impl UncommittedPool { /// Removes an entry from the pool pub(crate) fn remove(&mut self, entry: PoolEntry) { - match SplitEntry::from(entry) { - SplitEntry::Command(c) => { + match ConflictPoolEntry::from(entry) { + ConflictPoolEntry::Command(c) => { for cucp in &mut self.command_ucps { cucp.remove(c.clone()); } } - SplitEntry::ConfChange(c) => { + ConflictPoolEntry::ConfChange(c) => { self.conf_change_ucp.remove(c); } } @@ -65,9 +65,9 @@ impl UncommittedPool { /// Returns all entries in the pool that conflict with the given entry pub(crate) fn all_conflict(&self, entry: PoolEntry) -> Vec> { - match SplitEntry::from(entry) { + match ConflictPoolEntry::from(entry) { // A command entry conflict with other conflict entries plus all conf change entries - SplitEntry::Command(ref c) => self + ConflictPoolEntry::Command(ref c) => self .conf_change_ucp .all() .into_iter() @@ -80,7 +80,7 @@ impl UncommittedPool { ) .collect(), // A conf change entry conflict with all other entries - SplitEntry::ConfChange(_) => self + ConflictPoolEntry::ConfChange(_) => self .conf_change_ucp .all() .into_iter()