forked from mirrors/jj
backend: declare CHANGE_ID_HASH_LENGTH as constant
This commit is contained in:
parent
6d0a6f32aa
commit
ef33bd76df
2 changed files with 5 additions and 3 deletions
|
@ -23,6 +23,8 @@ use thiserror::Error;
|
|||
use crate::content_hash::ContentHash;
|
||||
use crate::repo_path::{RepoPath, RepoPathComponent};
|
||||
|
||||
pub const CHANGE_ID_HASH_LENGTH: usize = 16;
|
||||
|
||||
pub trait ObjectId {
|
||||
fn new(value: Vec<u8>) -> Self;
|
||||
fn object_type(&self) -> String;
|
||||
|
@ -337,7 +339,7 @@ pub fn make_root_commit(empty_tree_id: TreeId) -> Commit {
|
|||
email: String::new(),
|
||||
timestamp,
|
||||
};
|
||||
let change_id = ChangeId::new(vec![0; 16]);
|
||||
let change_id = ChangeId::new(vec![0; CHANGE_ID_HASH_LENGTH]);
|
||||
Commit {
|
||||
parents: vec![],
|
||||
predecessors: vec![],
|
||||
|
|
|
@ -19,7 +19,7 @@ use chrono::DateTime;
|
|||
use rand::prelude::*;
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
|
||||
use crate::backend::{ChangeId, ObjectId, Signature, Timestamp};
|
||||
use crate::backend::{ChangeId, ObjectId, Signature, Timestamp, CHANGE_ID_HASH_LENGTH};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct UserSettings {
|
||||
|
@ -167,7 +167,7 @@ impl UserSettings {
|
|||
pub struct JJRng(Mutex<ChaCha20Rng>);
|
||||
impl JJRng {
|
||||
pub fn new_change_id(&self) -> ChangeId {
|
||||
let random_bytes: [u8; 16] = self.gen();
|
||||
let random_bytes: [u8; CHANGE_ID_HASH_LENGTH] = self.gen();
|
||||
ChangeId::new(random_bytes.into())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue