crdt: Remove redundant `Author` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
d18b67ba21
commit
b79e2f5b56
|
|
@ -6,10 +6,8 @@ use serde::{Deserialize, Serialize};
|
||||||
use crate::clock::LClock;
|
use crate::clock::LClock;
|
||||||
|
|
||||||
/// Identifies a change.
|
/// Identifies a change.
|
||||||
pub type ChangeId = (LClock, Author);
|
pub type ChangeId = (LClock, ActorId);
|
||||||
/// The author of a change.
|
/// The author of a change.
|
||||||
pub type Author = PublicKey;
|
|
||||||
/// Alias for `Author`.
|
|
||||||
pub type ActorId = PublicKey;
|
pub type ActorId = PublicKey;
|
||||||
|
|
||||||
/// The `Change` is the unit of replication.
|
/// The `Change` is the unit of replication.
|
||||||
|
|
@ -20,7 +18,7 @@ pub struct Change<A> {
|
||||||
/// The action carried out by this change.
|
/// The action carried out by this change.
|
||||||
pub action: A,
|
pub action: A,
|
||||||
/// The author of the change.
|
/// The author of the change.
|
||||||
pub author: Author,
|
pub author: ActorId,
|
||||||
/// Lamport clock.
|
/// Lamport clock.
|
||||||
pub clock: LClock,
|
pub clock: LClock,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,20 +10,18 @@ use serde::{Deserialize, Serialize};
|
||||||
use crate::cob::common::{Reaction, Tag};
|
use crate::cob::common::{Reaction, Tag};
|
||||||
use crate::cob::store;
|
use crate::cob::store;
|
||||||
use crate::cob::{History, TypeName};
|
use crate::cob::{History, TypeName};
|
||||||
use crate::crypto::{PublicKey, Signer};
|
use crate::crypto::Signer;
|
||||||
|
|
||||||
use crdt::clock::LClock;
|
use crdt::clock::LClock;
|
||||||
use crdt::lwwreg::LWWReg;
|
use crdt::lwwreg::LWWReg;
|
||||||
use crdt::lwwset::LWWSet;
|
use crdt::lwwset::LWWSet;
|
||||||
use crdt::redactable::Redactable;
|
use crdt::redactable::Redactable;
|
||||||
use crdt::{Change, ChangeId, Semilattice};
|
use crdt::{ActorId, Change, ChangeId, Semilattice};
|
||||||
|
|
||||||
/// Type name of a thread.
|
/// Type name of a thread.
|
||||||
pub static TYPENAME: Lazy<TypeName> =
|
pub static TYPENAME: Lazy<TypeName> =
|
||||||
Lazy::new(|| FromStr::from_str("xyz.radicle.thread").expect("type name is valid"));
|
Lazy::new(|| FromStr::from_str("xyz.radicle.thread").expect("type name is valid"));
|
||||||
|
|
||||||
/// Alias for `Author`.
|
|
||||||
pub type ActorId = PublicKey;
|
|
||||||
/// Identifies a comment.
|
/// Identifies a comment.
|
||||||
pub type CommentId = ChangeId;
|
pub type CommentId = ChangeId;
|
||||||
|
|
||||||
|
|
@ -383,7 +381,7 @@ mod tests {
|
||||||
let mut changes = Vec::new();
|
let mut changes = Vec::new();
|
||||||
let mut permutations: [Vec<Change<Action>>; N] = array::from_fn(|_| Vec::new());
|
let mut permutations: [Vec<Change<Action>>; N] = array::from_fn(|_| Vec::new());
|
||||||
let mut clock = LClock::default();
|
let mut clock = LClock::default();
|
||||||
let author = PublicKey::from([0; 32]);
|
let author = ActorId::from([0; 32]);
|
||||||
|
|
||||||
for action in gen.take(g.size().min(8)) {
|
for action in gen.take(g.size().min(8)) {
|
||||||
let clock = clock.tick();
|
let clock = clock.tick();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue