Skip to content

Commit

Permalink
chore: removed Unconnected method
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Dec 10, 2024
1 parent 1dfeb76 commit ba8ede8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,6 @@ func (f *FragmentChain) BestChainVec() (hashes []parachaintypes.CandidateHash) {
return hashes
}

// Unconnected returns a vector of the unconnected potential candidate hashes, in arbitrary order.
func (f *FragmentChain) Unconnected() iter.Seq[*CandidateEntry] {
return f.unconnected.candidates()
}

func (f *FragmentChain) IsCandidateBacked(hash parachaintypes.CandidateHash) bool {
if f.bestChain.Contains(hash) {
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {
require.NoError(t, err)
} else {
potentials := make([]parachaintypes.CandidateHash, 0)
for unconnected := range chain.Unconnected() {
for _, unconnected := range chain.unconnected.byCandidateHash {
potentials = append(potentials, unconnected.candidateHash)
}

Expand Down Expand Up @@ -1179,7 +1179,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {

// Check that the unconnected candidates are as expected
unconnectedHashes := make(map[parachaintypes.CandidateHash]struct{})
for unconnected := range chain.Unconnected() {
for _, unconnected := range chain.unconnected.byCandidateHash {
unconnectedHashes[unconnected.candidateHash] = struct{}{}
}

Expand Down Expand Up @@ -1348,7 +1348,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {
require.Equal(t, []parachaintypes.CandidateHash{candidateAHash, candidateBHash}, chain.BestChainVec())

unconnected := make(map[parachaintypes.CandidateHash]struct{})
for entry := range chain.Unconnected() {
for _, entry := range chain.unconnected.byCandidateHash {
unconnected[entry.candidateHash] = struct{}{}
}

Expand Down Expand Up @@ -1659,7 +1659,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {
assert.Equal(t, []parachaintypes.CandidateHash{candidateAHash, candidateBHash, candidateCHash}, chain.BestChainVec())

unconnectedHashes := make(map[parachaintypes.CandidateHash]struct{})
for unconnected := range chain.Unconnected() {
for _, unconnected := range chain.unconnected.byCandidateHash {
unconnectedHashes[unconnected.candidateHash] = struct{}{}
}

Expand All @@ -1684,7 +1684,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {

// candidate F is kept as it was truly unconnected. The rest will be trimmed
unconnected := map[parachaintypes.CandidateHash]struct{}{}
for entry := range chain.Unconnected() {
for _, entry := range chain.unconnected.byCandidateHash {
unconnected[entry.candidateHash] = struct{}{}
}

Expand Down Expand Up @@ -1766,7 +1766,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {
}, chain.BestChainVec())

unconnected := make(map[parachaintypes.CandidateHash]struct{})
for entry := range chain.Unconnected() {
for _, entry := range chain.unconnected.byCandidateHash {
unconnected[entry.candidateHash] = struct{}{}
}

Expand All @@ -1790,7 +1790,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {
require.Equal(t, []parachaintypes.CandidateHash{candidateAHash, candidateBHash, candidateCHash}, chain.BestChainVec())

unconnected := make(map[parachaintypes.CandidateHash]struct{})
for entry := range chain.Unconnected() {
for _, entry := range chain.unconnected.byCandidateHash {
unconnected[entry.candidateHash] = struct{}{}
}
require.Equal(t, map[parachaintypes.CandidateHash]struct{}{
Expand Down Expand Up @@ -1821,7 +1821,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {
chain.BestChainVec())

unconnectedHashes := make(map[parachaintypes.CandidateHash]struct{})
for unconnected := range chain.Unconnected() {
for _, unconnected := range chain.unconnected.byCandidateHash {
unconnectedHashes[unconnected.candidateHash] = struct{}{}
}

Expand All @@ -1845,7 +1845,7 @@ func TestPopulateAndCheckPotential(t *testing.T) {
require.Equal(t, []parachaintypes.CandidateHash{candidateDHash}, chain.BestChainVec())

unconnectedHashes = make(map[parachaintypes.CandidateHash]struct{})
for unconnected := range chain.Unconnected() {
for _, unconnected := range chain.unconnected.byCandidateHash {
unconnectedHashes[unconnected.candidateHash] = struct{}{}
}

Expand Down

0 comments on commit ba8ede8

Please sign in to comment.