MCPcopy
hub / github.com/dgraph-io/dgraph / checkForCIDInEntries

Method checkForCIDInEntries

dgraph/cmd/zero/raft.go:592–630  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

590}
591
592func (n *node) checkForCIDInEntries() (bool, error) {
593 first, err := n.Store.FirstIndex()
594 if err != nil {
595 return false, err
596 }
597 last, err := n.Store.LastIndex()
598 if err != nil {
599 return false, err
600 }
601
602 for batch := first; batch <= last; {
603 entries, err := n.Store.Entries(batch, last+1, 64<<20)
604 if err != nil {
605 return false, err
606 }
607
608 // Exit early from the loop if no entries were found.
609 if len(entries) == 0 {
610 break
611 }
612
613 // increment the iterator to the next batch
614 batch = entries[len(entries)-1].Index + 1
615
616 for _, entry := range entries {
617 if entry.Type != raftpb.EntryNormal || len(entry.Data) == 0 {
618 continue
619 }
620 var proposal pb.ZeroProposal
621 if err = proto.Unmarshal(entry.Data[8:], &proposal); err != nil {
622 return false, errors.Wrapf(err, "error unmarshlling wal entry: [%x]", entry.Data[8:])
623 }
624 if len(proposal.Cid) > 0 {
625 return true, err
626 }
627 }
628 }
629 return false, err
630}
631
632func (n *node) initAndStartNode() error {
633 x.Check(n.initProposalKey(n.Id))

Callers 1

initAndStartNodeMethod · 0.95

Calls 3

FirstIndexMethod · 0.80
EntriesMethod · 0.80
LastIndexMethod · 0.45

Tested by

no test coverage detected