From 76f21a54c973da8830f6b91b86b61c349ba46375 Mon Sep 17 00:00:00 2001 From: Timothy Wu Date: Tue, 20 Aug 2024 15:56:07 +0200 Subject: [PATCH] update client/consensus/grandpa comments --- internal/client/consensus/grandpa/authorities.go | 12 ++++++------ internal/client/consensus/grandpa/change_tree.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/client/consensus/grandpa/authorities.go b/internal/client/consensus/grandpa/authorities.go index c381b0ef0b..970ef540ea 100644 --- a/internal/client/consensus/grandpa/authorities.go +++ b/internal/client/consensus/grandpa/authorities.go @@ -149,7 +149,7 @@ func (sas *SharedAuthoritySet[H, N]) applyForcedChanges(bestHash H, //nolint //s // method ensures that if there are multiple changes in the same branch, // finalising this block won't finalise past multiple transitions (i.e. // transitions must be finalised in-order). The given function -// `is_descendent_of` should return `true` if the second hash (target) is a +// `isDescendentOf` should return `true` if the second hash (target) is a // descendent of the first hash (base). // // When the set has changed, the return value will be a status type where newSetBlockInfo @@ -172,7 +172,7 @@ func (sas *SharedAuthoritySet[H, N]) applyStandardChanges(finalisedHash H, //nol // change that can be immediately applied, *false if the block being // finalised enacts a change but it cannot be applied yet since there are // other dependent changes, and nil if no change is enacted. The given -// function `is_descendent_of` should return `true` if the second hash +// function `isDescendentOf` should return `true` if the second hash // (target) is a descendent of the first hash (base). func (sas *SharedAuthoritySet[H, N]) EnactsStandardChange(finalisedHash H, finalisedNumber N, @@ -277,7 +277,7 @@ func (authSet *AuthoritySet[H, N]) revert() { //nolint //skipcq: SCC-U1000 //ski } // Returns the block hash and height at which the next pending HashNumber in -// the given chain (i.e. it includes `best_hash`) was signalled, nil if +// the given chain (i.e. it includes `bestHash`) was signalled, nil if // there are no pending changes for the given chain. func (authSet *AuthoritySet[H, N]) nextChange(bestHash H, //skipcq: RVV-B0001 isDescendentOf IsDescendentOf[H]) (*HashNumber[H, N], error) { @@ -432,7 +432,7 @@ func (authSet *AuthoritySet[H, N]) addForcedChange( // on the same branch can be added as long as they don't overlap. Forced // changes are restricted to one per fork. This method assumes that changes // on the same branch will be added in-order. The given function -// `is_descendent_of` should return `true` if the second hash (target) is a +// `isDescendentOf` should return `true` if the second hash (target) is a // descendent of the first hash (base). func (authSet *AuthoritySet[H, N]) addPendingChange( pending PendingChange[H, N], @@ -570,7 +570,7 @@ func (authSet *AuthoritySet[H, N]) applyForcedChanges(bestHash H, //skipcq: RVV // method ensures that if there are multiple changes in the same branch, // finalising this block won't finalise past multiple transitions (i.e. // transitions must be finalised in-order). The given function -// `is_descendent_of` should return `true` if the second hash (target) is a +// `isDescendantOf` should return `true` if the second hash (target) is a // descendent of the first hash (base). // // When the set has changed, the return value will be a status type where newSetBlock @@ -651,7 +651,7 @@ func (authSet *AuthoritySet[H, N]) applyStandardChanges( //skipcq: RVV-B0001 // HashNumber that can be immediately applied, *false if the block being // finalised enacts a HashNumber but it cannot be applied yet since there are // other dependent changes, and nil if no HashNumber is enacted. The given -// function `is_descendent_of` should return `true` if the second hash +// function `isDescendentOf` should return `true` if the second hash // (target) is a descendent of the first hash (base). func (authSet *AuthoritySet[H, N]) EnactsStandardChange( //skipcq: RVV-B0001 finalisedHash H, finalisedNumber N, isDescendentOf IsDescendentOf[H]) (*bool, error) { diff --git a/internal/client/consensus/grandpa/change_tree.go b/internal/client/consensus/grandpa/change_tree.go index ecfcf59fae..2b8e43f25e 100644 --- a/internal/client/consensus/grandpa/change_tree.go +++ b/internal/client/consensus/grandpa/change_tree.go @@ -54,7 +54,7 @@ func (ct *ChangeTree[H, N]) Roots() []*PendingChangeNode[H, N] { //skipcq: RVV-B // Import a new node into the roots. // -// The given function `is_descendent_of` should return `true` if the second +// The given function `isDescendentOf` should return `true` if the second // hash (target) is a descendent of the first hash (base). // // This method assumes that children in the same branch are imported in order. @@ -62,7 +62,7 @@ func (ct *ChangeTree[H, N]) Roots() []*PendingChangeNode[H, N] { //skipcq: RVV-B // Returns `true` if the imported node is a root. // WARNING: some users of this method (i.e. consensus epoch changes roots) currently silently // rely on a **post-order DFS** traversal. If we are using instead a top-down traversal method -// then the `is_descendent_of` closure, when used after a warp-sync, may end up querying the +// then the `isDescendentOf` closure, when used after a warp-sync, may end up querying the // backend for a block (the one corresponding to the root) that is not present and thus will // return a wrong result. func (ct *ChangeTree[H, N]) Import(hash H, @@ -127,7 +127,7 @@ func (ct *ChangeTree[H, N]) getPreOrderChangeNodes() []*PendingChangeNode[H, N] // a root, *false if the node being finalized is not a root, and // nil if no node in the tree is finalized. The given `Predicate` is // checked on the prospective finalized root and must pass for finalisation -// to occur. The given function `is_descendent_of` should return `true` if +// to occur. The given function `isDescendentOf` should return `true` if // the second hash (target) is a descendent of the first hash (base). func(T) bool func (ct *ChangeTree[H, N]) FinalizesAnyWithDescendentIf( hash *H, @@ -249,7 +249,7 @@ type unchanged struct{} // being finalized isn't a descendent of (or equal to) any of the root's // children. The given `Predicate` is checked on the prospective finalized // root and must pass for finalisation to occur. The given function -// `is_descendent_of` should return `true` if the second hash (target) is a +// `isDescendentOf` should return `true` if the second hash (target) is a // descendent of the first hash (base). func (ct *ChangeTree[H, N]) FinalizeWithDescendentIf( hash *H,