本文整理匯總了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
}
示例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)
}
示例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
}