コード例 #1
0
ファイル: processedblock.go プロジェクト: cfromknecht/Sia
// 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)
}
コード例 #2
0
ファイル: blocknode.go プロジェクト: mm3/Sia
// 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)
}