Skip to content

Commit

Permalink
chore: rename SplitEntry to ConflictPoolEntry
Browse files Browse the repository at this point in the history
Signed-off-by: bsbds <69835502+bsbds@users.noreply.github.com>
  • Loading branch information
bsbds authored and Phoenix500526 committed Apr 3, 2024
1 parent 2e6844e commit e35b35a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions crates/curp/src/server/conflict/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C> {
pub(super) enum ConflictPoolEntry<C> {
/// A command entry
Command(CommandEntry<C>),
/// A conf change entry
ConfChange(ConfChangeEntry),
}

impl<C> From<PoolEntry<C>> for SplitEntry<C> {
impl<C> From<PoolEntry<C>> for ConflictPoolEntry<C> {
fn from(entry: PoolEntry<C>) -> 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,
}),
Expand Down
14 changes: 7 additions & 7 deletions crates/curp/src/server/conflict/spec_pool_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C> = Box<dyn SpeculativePoolOp<Entry = CommandEntry<C>> + Send + 'static>;
Expand Down Expand Up @@ -30,15 +30,15 @@ impl<C> SpeculativePool<C> {
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()
Expand All @@ -57,13 +57,13 @@ impl<C> SpeculativePool<C> {
// TODO: Use reference instead of clone
/// Removes an entry from the pool
pub(crate) fn remove(&mut self, entry: PoolEntry<C>) {
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);
}
}
Expand Down
20 changes: 10 additions & 10 deletions crates/curp/src/server/conflict/uncommitted_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C> = Box<dyn UncommittedPoolOp<Entry = CommandEntry<C>> + Send + 'static>;
Expand Down Expand Up @@ -30,13 +30,13 @@ impl<C> UncommittedPool<C> {

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
Expand All @@ -51,23 +51,23 @@ impl<C> UncommittedPool<C> {

/// Removes an entry from the pool
pub(crate) fn remove(&mut self, entry: PoolEntry<C>) {
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);
}
}
}

/// Returns all entries in the pool that conflict with the given entry
pub(crate) fn all_conflict(&self, entry: PoolEntry<C>) -> Vec<PoolEntry<C>> {
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()
Expand All @@ -80,7 +80,7 @@ impl<C> UncommittedPool<C> {
)
.collect(),
// A conf change entry conflict with all other entries
SplitEntry::ConfChange(_) => self
ConflictPoolEntry::ConfChange(_) => self
.conf_change_ucp
.all()
.into_iter()
Expand Down

0 comments on commit e35b35a

Please sign in to comment.