func WriteBitstring(w io.Writer, bs *cf.Bitstring) (err error) { err = WriteInt(w, bs.BitLen()) if err != nil { return } err = WriteInt(w, len(bs.Bytes())) if err != nil { return } _, err = w.Write(bs.Bytes()) return }
func (t *prefixTree) Node(bs *cf.Bitstring) (node recon.PrefixNode, err error) { nbq := t.BitQuantum key := bs nodeKey := mustEncodeBitstring(key) for { node, err = t.getNode(nodeKey) if err != recon.ErrNodeNotFound || key.BitLen() == 0 { break } key = cf.NewBitstring(key.BitLen() - nbq) key.SetBytes(bs.Bytes()) nodeKey = mustEncodeBitstring(key) } return node, err }