當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FileContractID.StorageProofOutputID方法代碼示例

本文整理匯總了Golang中github.com/NebulousLabs/Sia/types.FileContractID.StorageProofOutputID方法的典型用法代碼示例。如果您正苦於以下問題:Golang FileContractID.StorageProofOutputID方法的具體用法?Golang FileContractID.StorageProofOutputID怎麽用?Golang FileContractID.StorageProofOutputID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/NebulousLabs/Sia/types.FileContractID的用法示例。


在下文中一共展示了FileContractID.StorageProofOutputID方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: applyMissedStorageProof

// applyMissedStorageProof adds the outputs and diffs that result from a file
// contract expiring.
func (cs *State) applyMissedStorageProof(bn *blockNode, fcid types.FileContractID) {
	// Sanity checks.
	fc, exists := cs.fileContracts[fcid]
	if build.DEBUG {
		// Check that the file contract in question exists.
		if !exists {
			panic("misuse of applyMissedProof")
		}

		// Check that the file contract in question expires at bn.height.
		if fc.WindowEnd != bn.height {
			panic("applyMissedStorageProof being called at the wrong height")
		}
	}

	// Add all of the outputs in the missed proof outputs to the consensus set.
	for i, mpo := range fc.MissedProofOutputs {
		// Sanity check - output should not already exist.
		spid := fcid.StorageProofOutputID(types.ProofMissed, i)
		if build.DEBUG {
			_, exists := cs.delayedSiacoinOutputs[bn.height+types.MaturityDelay][spid]
			if exists {
				panic("missed proof output already exists in the delayed outputs set")
			}
			_, exists = cs.siacoinOutputs[spid]
			if exists {
				panic("missed proof output already exists in the siacoin outputs set")
			}
		}

		dscod := modules.DelayedSiacoinOutputDiff{
			Direction:      modules.DiffApply,
			ID:             spid,
			SiacoinOutput:  mpo,
			MaturityHeight: bn.height + types.MaturityDelay,
		}
		bn.delayedSiacoinOutputDiffs = append(bn.delayedSiacoinOutputDiffs, dscod)
		cs.commitDelayedSiacoinOutputDiff(dscod, modules.DiffApply)
	}

	// Remove the contract from the State and record the diff in the blockNode.
	delete(cs.fileContracts, fcid)
	bn.fileContractDiffs = append(bn.fileContractDiffs, modules.FileContractDiff{
		Direction:    modules.DiffRevert,
		ID:           fcid,
		FileContract: fc,
	})

	return
}
開發者ID:mm3,項目名稱:Sia,代碼行數:52,代碼來源:maintenance.go

示例2: applyTxMissedStorageProof

// applyMissedStorageProof adds the outputs and diffs that result from a file
// contract expiring.
func (cs *ConsensusSet) applyTxMissedStorageProof(tx *bolt.Tx, pb *processedBlock, fcid types.FileContractID) error {
	// Sanity checks.
	fc, err := getFileContract(tx, fcid)
	if err != nil {
		return err
	}
	if build.DEBUG {
		// Check that the file contract in question expires at pb.Height.
		if fc.WindowEnd != pb.Height {
			panic(errStorageProofTiming)
		}
	}

	// Add all of the outputs in the missed proof outputs to the consensus set.
	for i, mpo := range fc.MissedProofOutputs {
		// Sanity check - output should not already exist.
		spoid := fcid.StorageProofOutputID(types.ProofMissed, uint64(i))
		if build.DEBUG {
			exists := isSiacoinOutput(tx, spoid)
			if exists {
				panic(errPayoutsAlreadyPaid)
			}
		}

		dscod := modules.DelayedSiacoinOutputDiff{
			Direction:      modules.DiffApply,
			ID:             spoid,
			SiacoinOutput:  mpo,
			MaturityHeight: pb.Height + types.MaturityDelay,
		}
		pb.DelayedSiacoinOutputDiffs = append(pb.DelayedSiacoinOutputDiffs, dscod)
		err = cs.commitTxDelayedSiacoinOutputDiff(tx, dscod, modules.DiffApply)
		if err != nil {
			return err
		}
	}

	// Remove the file contract from the consensus set and record the diff in
	// the blockNode.
	fcd := modules.FileContractDiff{
		Direction:    modules.DiffRevert,
		ID:           fcid,
		FileContract: fc,
	}
	pb.FileContractDiffs = append(pb.FileContractDiffs, fcd)
	return cs.commitTxFileContractDiff(tx, fcd, modules.DiffApply)
}
開發者ID:kustomzone,項目名稱:Sia,代碼行數:49,代碼來源:maintenance.go

示例3: applyMissedStorageProof

// applyMissedStorageProof adds the outputs and diffs that result from a file
// contract expiring.
func applyMissedStorageProof(tx *bolt.Tx, pb *processedBlock, fcid types.FileContractID) (dscods []modules.DelayedSiacoinOutputDiff, fcd modules.FileContractDiff) {
	// Sanity checks.
	fc, err := getFileContract(tx, fcid)
	if build.DEBUG && err != nil {
		panic(err)
	}
	if build.DEBUG {
		// Check that the file contract in question expires at pb.Height.
		if fc.WindowEnd != pb.Height {
			panic(errStorageProofTiming)
		}
	}

	// Add all of the outputs in the missed proof outputs to the consensus set.
	for i, mpo := range fc.MissedProofOutputs {
		// Sanity check - output should not already exist.
		spoid := fcid.StorageProofOutputID(types.ProofMissed, uint64(i))
		if build.DEBUG && isSiacoinOutput(tx, spoid) {
			panic(errPayoutsAlreadyPaid)
		}

		// Don't add the output if the value is zero.
		dscod := modules.DelayedSiacoinOutputDiff{
			Direction:      modules.DiffApply,
			ID:             spoid,
			SiacoinOutput:  mpo,
			MaturityHeight: pb.Height + types.MaturityDelay,
		}
		dscods = append(dscods, dscod)
	}

	// Remove the file contract from the consensus set and record the diff in
	// the blockNode.
	fcd = modules.FileContractDiff{
		Direction:    modules.DiffRevert,
		ID:           fcid,
		FileContract: fc,
	}
	return dscods, fcd
}
開發者ID:cfromknecht,項目名稱:Sia,代碼行數:42,代碼來源:maintenance.go


注:本文中的github.com/NebulousLabs/Sia/types.FileContractID.StorageProofOutputID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。