FederationRoutingTokenHeader RoutingToken::SplitPredToken(PartnerNodeSPtr const & pred, uint64 targetVersion, NodeId const & ownerId) { if (pred->Id == ownerId) { return FederationRoutingTokenHeader(); } // This is the boundary that should still belong to the current node. NodeId splitID = ownerId.GetPredMidPoint(pred->Id); // This is the bounary that should belong to the neighbor. NodeId transferID = splitID.PredWalk(LargeInteger::One); // Split is possible only when the transfer point is within the range. if (ownerId.PredDist(transferID) > ownerId.PredDist(range_.Begin)) { return FederationRoutingTokenHeader(); } // Split current token. NodeId oldStart = range_.Begin; Update(NodeIdRange(splitID, range_.End)); return FederationRoutingTokenHeader(NodeIdRange(oldStart, transferID), version_, targetVersion); }
FederationRoutingTokenHeader RoutingToken::SplitFullToken(PartnerNodeSPtr const & neighbor, uint64 targetVersion, NodeId const & ownerId) { NodeId succMid = ownerId.GetSuccMidPoint(neighbor->Id); NodeId predMid = ownerId.GetPredMidPoint(neighbor->Id); Update(NodeIdRange(predMid, succMid)); return FederationRoutingTokenHeader( NodeIdRange(succMid.SuccWalk(LargeInteger::One), predMid.PredWalk(LargeInteger::One)), version_, targetVersion); }