本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.IState.PutCommit方法的典型用法代碼示例。如果您正苦於以下問題:Golang IState.PutCommit方法的具體用法?Golang IState.PutCommit怎麽用?Golang IState.PutCommit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/common/interfaces.IState
的用法示例。
在下文中一共展示了IState.PutCommit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Validate
func (m *RevealEntryMsg) Validate(state interfaces.IState) int {
commit, rtn := m.ValidateRTN(state)
if rtn == 1 {
// Don't lose the commit that validates the entry
state.PutCommit(m.Entry.GetHash(), commit)
}
return rtn
}
示例2: ValidateRTN
// Validate the message, given the state. Three possible results:
// < 0 -- Message is invalid. Discard
// 0 -- Cannot tell if message is Valid
// 1 -- Message is valid
// Also return the matching commit, if 1 (Don't put it back into the Commit List)
func (m *RevealEntryMsg) ValidateRTN(state interfaces.IState) (interfaces.IMsg, int) {
commit := state.NextCommit(m.Entry.GetHash())
if commit == nil {
return nil, 0
}
//
// Make sure one of the two proper commits got us here.
var okChain, okEntry bool
m.commitChain, okChain = commit.(*CommitChainMsg)
m.commitEntry, okEntry = commit.(*CommitEntryMsg)
if !okChain && !okEntry { // Discard any invalid entries in the map. Should never happen.
fmt.Println("dddd Bad EB Commit", state.GetFactomNodeName())
return m.ValidateRTN(state)
}
// Now make sure the proper amount of credits were paid to record the entry.
// The chain must exist
if okEntry {
m.IsEntry = true
ECs := int(m.commitEntry.CommitEntry.Credits)
if m.Entry.KSize() > ECs {
fmt.Println("dddd EB Commit is short", state.GetFactomNodeName())
return m.ValidateRTN(state) // Discard commits that are not funded properly.
}
// Make sure we have a chain. If we don't, then bad things happen.
db := state.GetAndLockDB()
dbheight := state.GetLeaderHeight()
eb := state.GetNewEBlocks(dbheight, m.Entry.GetChainID())
eb_db := state.GetNewEBlocks(dbheight-1, m.Entry.GetChainID())
if eb_db == nil {
eb_db, _ = db.FetchEBlockHead(m.Entry.GetChainID())
}
if eb_db == nil && eb == nil {
// If we don't have a chain, put the commit back. Don't want to lose it.
state.PutCommit(m.Entry.GetHash(), commit)
return nil, 0
}
} else {
m.IsEntry = false
ECs := int(m.commitChain.CommitChain.Credits)
if m.Entry.KSize()+10 > ECs { // Discard commits that are not funded properly
return m.ValidateRTN(state)
}
}
return commit, 1
}