Skip to content

Commit

Permalink
Rename ChangeSet to CreateSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpfs committed Jun 19, 2024
1 parent b626d9b commit ee0ad31
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions crates/net/src/client/net/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
client::{CancelReason, Error, Result, SyncClient},
protocol::{
sync::{
ChangeSet, FileSet, FileTransfersSet, Origin, SyncPacket,
CreateSet, FileSet, FileTransfersSet, Origin, SyncPacket,
SyncStatus, UpdateSet,
},
DiffRequest, DiffResponse, PatchRequest, PatchResponse, ScanRequest,
Expand Down Expand Up @@ -259,7 +259,7 @@ impl SyncClient for HttpClient {
}

#[instrument(skip_all)]
async fn create_account(&self, account: ChangeSet) -> Result<()> {
async fn create_account(&self, account: CreateSet) -> Result<()> {
let body = account.encode().await?;
let url = self.build_url("api/v1/sync/account")?;

Expand Down Expand Up @@ -312,7 +312,7 @@ impl SyncClient for HttpClient {
}

#[instrument(skip_all)]
async fn fetch_account(&self) -> Result<ChangeSet> {
async fn fetch_account(&self) -> Result<CreateSet> {
let url = self.build_url("api/v1/sync/account")?;

tracing::debug!(url = %url, "http::fetch_account");
Expand All @@ -337,7 +337,7 @@ impl SyncClient for HttpClient {
tracing::debug!(status = %status, "http::fetch_account");
let response = self.check_response(response).await?;
let buffer = response.bytes().await?;
Ok(ChangeSet::decode(buffer).await?)
Ok(CreateSet::decode(buffer).await?)
}

#[instrument(skip_all)]
Expand Down
6 changes: 3 additions & 3 deletions crates/net/src/client/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
client::{CancelReason, Result},
protocol::{
sync::{
ChangeSet, Origin, SyncOptions, SyncPacket, SyncStatus, UpdateSet,
CreateSet, Origin, SyncOptions, SyncPacket, SyncStatus, UpdateSet,
},
DiffRequest, DiffResponse, PatchRequest, PatchResponse, ScanRequest,
ScanResponse,
Expand Down Expand Up @@ -70,13 +70,13 @@ pub trait SyncClient {
async fn account_exists(&self) -> Result<bool>;

/// Create a new account.
async fn create_account(&self, account: ChangeSet) -> Result<()>;
async fn create_account(&self, account: CreateSet) -> Result<()>;

/// Update an account.
async fn update_account(&self, account: UpdateSet) -> Result<()>;

/// Fetch an account from a remote server.
async fn fetch_account(&self) -> Result<ChangeSet>;
async fn fetch_account(&self) -> Result<CreateSet>;

/// Delete the account on the server.
async fn delete_account(&self) -> Result<()>;
Expand Down
14 changes: 7 additions & 7 deletions crates/net/src/protocol/bindings/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
protocol::{
decode_uuid, encode_uuid,
sync::{
ChangeSet, MaybeDiff, MergeOutcome, Origin, SyncCompare,
CreateSet, MaybeDiff, MergeOutcome, Origin, SyncCompare,
SyncDiff, SyncPacket, SyncStatus, UpdateSet,
},
Error, ProtoBinding, Result,
Expand Down Expand Up @@ -246,14 +246,14 @@ where
}
}

impl ProtoBinding for ChangeSet {
type Inner = WireChangeSet;
impl ProtoBinding for CreateSet {
type Inner = WireCreateSet;
}

impl TryFrom<WireChangeSet> for ChangeSet {
impl TryFrom<WireCreateSet> for CreateSet {
type Error = Error;

fn try_from(value: WireChangeSet) -> Result<Self> {
fn try_from(value: WireCreateSet) -> Result<Self> {
let mut folders = HashMap::with_capacity(value.folders.len());
for folder in value.folders {
folders.insert(
Expand All @@ -273,8 +273,8 @@ impl TryFrom<WireChangeSet> for ChangeSet {
}
}

impl From<ChangeSet> for WireChangeSet {
fn from(value: ChangeSet) -> Self {
impl From<CreateSet> for WireCreateSet {
fn from(value: CreateSet) -> Self {
Self {
identity: Some(value.identity.into()),
account: Some(value.account.into()),
Expand Down
2 changes: 1 addition & 1 deletion crates/net/src/protocol/protobuf/sync.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ message WireSyncFolderPatch {
WirePatch patch = 2;
}

message WireChangeSet {
message WireCreateSet {
// Patch for the identity folder.
WirePatch identity = 1;
// Patch for the account events.
Expand Down
6 changes: 3 additions & 3 deletions crates/net/src/protocol/sync/primitives.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Synchronization types that are used internally.
use crate::protocol::sync::{
ChangeSet, MaybeDiff, MergeOutcome, Origin, SyncCompare, SyncDiff,
CreateSet, MaybeDiff, MergeOutcome, Origin, SyncCompare, SyncDiff,
SyncStatus,
};
use crate::sdk::{
Expand Down Expand Up @@ -515,7 +515,7 @@ pub trait SyncStorage: StorageEventLogs {
///
/// Used by network aware implementations to transfer
/// entire accounts.
async fn change_set(&self) -> Result<ChangeSet> {
async fn change_set(&self) -> Result<CreateSet> {
let identity = {
let log = self.identity_log().await?;
let reader = log.read().await;
Expand Down Expand Up @@ -551,7 +551,7 @@ pub trait SyncStorage: StorageEventLogs {
folders.insert(*id, log_file.diff_events(None).await?);
}

Ok(ChangeSet {
Ok(CreateSet {
identity,
account,
folders,
Expand Down
2 changes: 1 addition & 1 deletion crates/net/src/protocol/sync/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub struct SyncDiff {

/// Collection of patches for an account.
#[derive(Debug, Default, PartialEq, Eq)]
pub struct ChangeSet {
pub struct CreateSet {
/// Identity vault event logs.
pub identity: FolderPatch,
/// Account event logs.
Expand Down
4 changes: 2 additions & 2 deletions crates/net/src/server/api_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use utoipa::{openapi::security::*, Modify, OpenApi, ToSchema};

#[derive(ToSchema)]
#[allow(dead_code)]
struct ChangeSet(crate::protocol::sync::ChangeSet);
struct CreateSet(crate::protocol::sync::CreateSet);

#[derive(ToSchema)]
#[allow(dead_code)]
Expand Down Expand Up @@ -48,7 +48,7 @@ struct SyncPacket(crate::protocol::sync::SyncPacket);
),
components(
schemas(
ChangeSet,
CreateSet,
SyncStatus,
SyncPacket,
),
Expand Down
6 changes: 3 additions & 3 deletions crates/net/src/server/backend.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{Error, Result};
use crate::{
protocol::sync::{ChangeSet, MergeOutcome, SyncStorage, UpdateSet},
protocol::sync::{CreateSet, MergeOutcome, SyncStorage, UpdateSet},
sdk::{
signer::{
ecdsa::Address,
Expand Down Expand Up @@ -118,7 +118,7 @@ impl Backend {
pub async fn create_account(
&mut self,
owner: &Address,
account_data: ChangeSet,
account_data: CreateSet,
) -> Result<()> {
{
let accounts = self.accounts.read().await;
Expand Down Expand Up @@ -193,7 +193,7 @@ impl Backend {
}

/// Fetch an existing account.
pub async fn fetch_account(&self, owner: &Address) -> Result<ChangeSet> {
pub async fn fetch_account(&self, owner: &Address) -> Result<CreateSet> {
tracing::debug!(address = %owner, "backend::fetch_account");

let accounts = self.accounts.read().await;
Expand Down
12 changes: 6 additions & 6 deletions crates/net/src/server/handlers/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(crate) async fn account_exists(
),
request_body(
content_type = "application/octet-stream",
content = ChangeSet,
content = CreateSet,
),
responses(
(
Expand Down Expand Up @@ -186,7 +186,7 @@ pub(crate) async fn delete_account(
),
request_body(
content_type = "application/octet-stream",
content = ChangeSet,
content = CreateSet,
),
responses(
(
Expand Down Expand Up @@ -259,7 +259,7 @@ pub(crate) async fn update_account(
status = StatusCode::OK,
content_type = "application/octet-stream",
description = "Account data sent.",
body = ChangeSet,
body = CreateSet,
),
),
)]
Expand Down Expand Up @@ -587,7 +587,7 @@ mod handlers {
use super::Caller;
use crate::{
protocol::sync::{
self, ChangeSet, EventLogType, Merge, MergeOutcome, SyncPacket,
self, CreateSet, EventLogType, Merge, MergeOutcome, SyncPacket,
SyncStorage, UpdateSet,
},
sdk::{
Expand Down Expand Up @@ -653,7 +653,7 @@ mod handlers {
}
}

let account = ChangeSet::decode(bytes).await?;
let account = CreateSet::decode(bytes).await?;
let mut writer = backend.write().await;
writer.create_account(caller.address(), account).await?;
Ok(())
Expand Down Expand Up @@ -687,7 +687,7 @@ mod handlers {
caller: Caller,
) -> Result<(HeaderMap, Vec<u8>)> {
let reader = backend.read().await;
let account: ChangeSet =
let account: CreateSet =
reader.fetch_account(caller.address()).await?;

let mut headers = HeaderMap::new();
Expand Down
4 changes: 2 additions & 2 deletions crates/net/src/server/storage/filesystem/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::ServerStorage;
use crate::{
protocol::sync::{
ChangeSet, ForceMerge, Merge, MergeOutcome, SyncStatus, SyncStorage,
CreateSet, ForceMerge, Merge, MergeOutcome, SyncStatus, SyncStorage,
UpdateSet,
},
sdk::{
Expand Down Expand Up @@ -71,7 +71,7 @@ impl ServerStorage {
/// account from a collection of patches.
pub async fn import_account(
&mut self,
account_data: &ChangeSet,
account_data: &CreateSet,
) -> Result<()> {
{
let mut writer = self.account_log.write().await;
Expand Down
8 changes: 4 additions & 4 deletions crates/net/src/tests/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use prost::bytes::Bytes;
use crate::{
protocol::{
sync::{
ChangeSet, EventLogType, MaybeDiff, MergeOutcome, Origin,
CreateSet, EventLogType, MaybeDiff, MergeOutcome, Origin,
SyncCompare, SyncDiff, SyncPacket, SyncStatus, UpdateSet,
},
DiffRequest, DiffResponse, PatchRequest, PatchResponse, ScanRequest,
Expand Down Expand Up @@ -337,11 +337,11 @@ async fn encode_decode_maybe_diff() -> Result<()> {

#[tokio::test]
async fn encode_decode_create_set() -> Result<()> {
let value = ChangeSet::default();
let value = CreateSet::default();
let buffer = value.encode().await?;
let buffer: Bytes = buffer.into();
let decoded = ChangeSet::decode(buffer).await?;
assert_eq!(ChangeSet::default(), decoded);
let decoded = CreateSet::decode(buffer).await?;
assert_eq!(CreateSet::default(), decoded);
Ok(())
}

Expand Down

0 comments on commit ee0ad31

Please sign in to comment.