From 3ee9ded98a829cb2529b6f9ac25328ec2bb15f8f Mon Sep 17 00:00:00 2001 From: nikoPLP Date: Sun, 5 Mar 2023 07:10:51 +0200 Subject: [PATCH] Object::is_root --- p2p-repo/src/branch.rs | 2 +- p2p-repo/src/object.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/p2p-repo/src/branch.rs b/p2p-repo/src/branch.rs index 7b7d7cf..985b144 100644 --- a/p2p-repo/src/branch.rs +++ b/p2p-repo/src/branch.rs @@ -130,7 +130,7 @@ impl Branch { let id = cobj.id(); // root has no deps - let is_root = cobj.deps().len() == 0; + let is_root = cobj.is_root(); //debug_println!(" deps: {:?}", cobj.deps()); // check if this commit object is present in their_heads diff --git a/p2p-repo/src/object.rs b/p2p-repo/src/object.rs index f38cc03..914e803 100644 --- a/p2p-repo/src/object.rs +++ b/p2p-repo/src/object.rs @@ -379,6 +379,11 @@ impl Object { } } + pub fn is_root(&self) -> bool { + self.deps().len() == 0 + //TODO: add && sdeps().len() == 0 && self.acks().len() == 0 && self.nacks().len() == 0 + } + pub fn root(&self) -> &Block { self.blocks.last().unwrap() }