MCPcopy Create free account
hub / github.com/dfinity/orbit / create_entry

Method create_entry

core/station/impl/src/services/address_book.rs:111–136  ·  view source on GitHub ↗

Creates a new address book entry.

(
        &self,
        input: AddAddressBookEntryOperationInput,
    )

Source from the content-addressed store, hash-verified

109
110 /// Creates a new address book entry.
111 pub async fn create_entry(
112 &self,
113 input: AddAddressBookEntryOperationInput,
114 ) -> ServiceResult<AddressBookEntry> {
115 let uuid = generate_uuid_v4().await;
116 let key = AddressBookEntry::key(*uuid.as_bytes());
117
118 let new_entry = AddressBookMapper::from_create_input(input.to_owned(), *uuid.as_bytes())?;
119 new_entry.validate()?;
120
121 if let Some(v) = self
122 .address_book_repository
123 .find_by_address(new_entry.blockchain.clone(), new_entry.address.clone())
124 {
125 return Err(AddressBookError::DuplicateAddress {
126 id: Uuid::from_bytes(v.id).hyphenated().to_string(),
127 })?;
128 }
129
130 // Inserting the address book entry into the repository and its associations is the last step of the address book entry creation
131 // process to avoid potential consistency issues due to the fact that some of the calls to create the address book entry
132 // happen in an asynchronous way.
133 self.address_book_repository.insert(key, new_entry.clone());
134
135 Ok(new_entry)
136 }
137
138 /// Edits an existing address book entry.
139 pub async fn edit_entry(

Callers 2

executeMethod · 0.80
create_entryFunction · 0.80

Calls 4

find_by_addressMethod · 0.80
generate_uuid_v4Function · 0.50
validateMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected