本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.IState.VerifyIsAuthority方法的典型用法代碼示例。如果您正苦於以下問題:Golang IState.VerifyIsAuthority方法的具體用法?Golang IState.VerifyIsAuthority怎麽用?Golang IState.VerifyIsAuthority使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/common/interfaces.IState
的用法示例。
在下文中一共展示了IState.VerifyIsAuthority方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Validate
func (m *RemoveServerMsg) Validate(state interfaces.IState) int {
// Check to see if identity exists and is audit or fed server
if !state.VerifyIsAuthority(m.ServerChainID) {
//fmt.Printf("RemoveServerMsg Error: [%s] is not a server, cannot be removed\n", m.ServerChainID.String()[:8])
return -1
}
// TODO: Check valid signatures
return 1
}
示例2: Validate
func (m *ChangeServerKeyMsg) Validate(state interfaces.IState) int {
return 1
// Check to see if identity exists and is audit or fed server
if !state.VerifyIsAuthority(m.IdentityChainID) {
fmt.Println("ChangeServerKey Error. Server is not an authority")
return -1
}
// Should only be 20 bytes in the hash
if m.AdminBlockChange == constants.TYPE_ADD_BTC_ANCHOR_KEY {
for _, b := range m.Key.Bytes()[21:] {
if b != 0 {
fmt.Println("ChangeServerKey Error. Newkey is invalid length")
return -1
}
}
}
// Check signatures
bytes, err := m.MarshalForSignature()
if err != nil {
fmt.Println("ChangeServerKey Error: Err is not nil, err: ", err.Error())
return -1
}
if m.Signature == nil {
fmt.Println("ChangeServerKey Error: No signiture on ChangeServerKeyMessage")
return -1
}
sig := m.Signature.GetSignature()
authSigned, err := state.VerifyAuthoritySignature(bytes, sig, state.GetLeaderHeight())
//ackSigned, err := m.VerifySignature()
if err != nil {
fmt.Println("ChangeServerKey Error: Err is not nil, err: ", err.Error())
return -1
}
if authSigned < 1 {
fmt.Println("ChangeServerKey Error: Message not signed by an authority")
return -1
}
return 1
}