Skip to content

Commit

Permalink
fix: Document an access key separator inconsistency (#10166)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikurt authored Nov 14, 2023
1 parent f29c75c commit 628fd96
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/primitives/src/trie_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use crate::hash::CryptoHash;
use crate::types::AccountId;

pub(crate) const ACCOUNT_DATA_SEPARATOR: u8 = b',';
// The use of `ACCESS_KEY` as a separator is a historical artefact.
// Changing it would require a very long DB migration for basically no benefits.
pub(crate) const ACCESS_KEY_SEPARATOR: u8 = col::ACCESS_KEY;

/// Type identifiers used for DB key generation to store values in the key-value storage.
pub mod col {
Expand Down Expand Up @@ -162,7 +165,7 @@ impl TrieKey {
TrieKey::AccessKey { account_id, public_key } => {
buf.push(col::ACCESS_KEY);
buf.extend(account_id.as_bytes());
buf.push(col::ACCESS_KEY);
buf.push(ACCESS_KEY_SEPARATOR);
buf.extend(borsh::to_vec(&public_key).unwrap());
}
TrieKey::ReceivedData { receiver_id, data_id } => {
Expand Down Expand Up @@ -331,7 +334,7 @@ pub mod trie_key_parsers {
raw_key: &[u8],
) -> Result<AccountId, std::io::Error> {
let account_id_prefix = parse_account_id_prefix(col::ACCESS_KEY, raw_key)?;
if let Some(account_id) = next_token(account_id_prefix, col::ACCESS_KEY) {
if let Some(account_id) = next_token(account_id_prefix, ACCESS_KEY_SEPARATOR) {
parse_account_id_from_slice(account_id, "AccessKey")
} else {
Err(std::io::Error::new(
Expand Down

0 comments on commit 628fd96

Please sign in to comment.