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


Golang IState.VerifyIsAuthority方法代碼示例

本文整理匯總了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
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:10,代碼來源:removeServer.go

示例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
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:42,代碼來源:changeServerKey.go


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