// setChildTarget computes the target of a blockNode's child. All children of a node // have the same target. func (cs *ConsensusSet) setChildTarget(blockMap *bolt.Bucket, pb *processedBlock) { // Fetch the parent block. var parent processedBlock parentBytes := blockMap.Get(pb.Block.ParentID[:]) err := encoding.Unmarshal(parentBytes, &parent) if build.DEBUG && err != nil { panic(err) } if pb.Height%(types.TargetWindow/2) != 0 { pb.ChildTarget = parent.ChildTarget return } adjustment := clampTargetAdjustment(cs.targetAdjustmentBase(blockMap, pb)) adjustedRatTarget := new(big.Rat).Mul(parent.ChildTarget.Rat(), adjustment) pb.ChildTarget = types.RatToTarget(adjustedRatTarget) }
// setTarget computes the target of a blockNode's child. All children of a node // have the same target. func (bn *blockNode) setChildTarget() { adjustment := clampTargetAdjustment(bn.targetAdjustmentBase()) adjustedRatTarget := new(big.Rat).Mul(bn.parent.childTarget.Rat(), adjustment) bn.childTarget = types.RatToTarget(adjustedRatTarget) }