Hey! When calling the traverse_remaining method:
protected def self.traverse_remaining(
from vertex : DAG::Vertex,
visited = Hash(String, Bool).new,
remaining_dag = Hash(BlockHash, DAG::Vertex).new,
remaining_parents = Hash(BlockHash, Array(BlockHash)).new(
->(hash : Hash(BlockHash, Array(BlockHash)), key : BlockHash) {
hash[key] = Array(BlockHash).new
}
)
) :
.....
And passing arguments to it:
remaining_chain = self.traverse_remaining from: tolb.branch_root
The compiler throws an error:
Error: no overload matches ‘ProbFin.traverse_remaining’, from: (DAG::Vertex | Nil)
Without having the code to reproduce, I’d have to guess that tolb.branch_root
is of type DAG::Vertex?
and the method only allows DAG::Vertex
. Basically just need to ensure that it’s not nil
before calling the method.
I apologize wildly. Full code:
dag.cr
module DAG
record Tip,
vertex : DAG::Vertex,
distance : Int32,
branch_root : (DAG::Vertex | Nil)
class Vertex
alias Name = String
getter name : Name
This file has been truncated. show original
probfin.cr
require "./dag"
module ProbFin
alias BlockHash = String
module Chain
extend self
def dag
@@dag ||= Hash(BlockHash, DAG::Vertex).new
This file has been truncated. show original
Yea, my initial guess seems to be the problem. Will need to ensure that tolb.branch_root
is not nil
before calling that method.
EDIT: Or optionally allow that argument to accept nil
and handle it within the method.
1 Like