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


Golang Action.GetRequestCode方法代碼示例

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


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

示例1: OneSub

func (state *ComputePeerState) OneSub(action *sproto.Action) *sproto.Response {
	//fmt.Println("Subtraction one from value")
	result := *action.Result
	share0 := *action.Share0
	share0val, hasShare0val := state.SharesGet(share0)
	if hasShare0val {
		val := core.Sub(1, share0val)
		state.SharesSet(result, val)
	}
	return state.failResponse(action.GetRequestCode())

}
開發者ID:apanda,項目名稱:smpc,代碼行數:12,代碼來源:operations.go

示例2: Add

// Add two shares
func (state *ComputePeerState) Add(action *sproto.Action) *sproto.Response {
	//fmt.Println("Adding two values")
	result := *action.Result
	share0 := *action.Share0
	share1 := *action.Share1
	share0val, hasShare0val := state.SharesGet(share0)
	share1val, hasShare1val := state.SharesGet(share1)
	if hasShare0val && hasShare1val {
		state.SharesSet(result, core.Add(share0val, share1val))
		//fmt.Println("Done Adding")
		return state.okResponse(action.GetRequestCode())
	}
	//fmt.Printf("Failed additions, response would have been %s (%s, %v, %s, %v)\n", result, share0, hasShare0val, share1, hasShare1val)
	return state.failResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:16,代碼來源:operations.go

示例3: Neqz

// Test inequality to zero
func (state *ComputePeerState) Neqz(action *sproto.Action) *sproto.Response {
	//fmt.Println("Comparing values")
	result := *action.Result
	share0 := *action.Share0
	share0val, hasShare0Val := state.SharesGet(share0)
	rcode := *action.RequestCode
	if !hasShare0Val {
		//fmt.Printf("Failing, variable %s not found\n", share0)
		return state.failResponse(action.GetRequestCode())
	}
	res := state.neqz(share0val, rcode)
	state.SharesSet(result, res)
	//fmt.Printf("Done testing value for not zero\n")
	return state.okResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:16,代碼來源:operations.go

示例4: GetValue

// Retrieve the value of a share
func (state *ComputePeerState) GetValue(action *sproto.Action) *sproto.Response {
	result := *action.Result
	val, hasVal := state.SharesGet(result)
	if hasVal {
		resp := &sproto.Response{}
		rcode := action.GetRequestCode()
		resp.RequestCode = &rcode
		resp.Share = &val
		status := sproto.Response_Val
		resp.Status = &status
		client := int32(state.Client)
		resp.Client = &client
		return resp
	}
	return state.failResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:17,代碼來源:operations.go

示例5: MulConst

// Multiply const
func (state *ComputePeerState) MulConst(action *sproto.Action) *sproto.Response {
	//fmt.Println("Multiplying with constants")
	result := *action.Result
	share0 := *action.Share0
	val := *action.Value
	share0val, hasShare0Val := state.SharesGet(share0)
	rcode := *action.RequestCode
	if !hasShare0Val {
		//fmt.Printf("Failing, variable %s not found\n", share0)
		return state.failResponse(action.GetRequestCode())
	}
	res := core.MultUnderMod(val, share0val)
	state.SharesSet(result, res)
	//fmt.Println("Done multiplying constants")
	return state.okResponse(rcode)
}
開發者ID:apanda,項目名稱:smpc,代碼行數:17,代碼來源:operations.go

示例6: Eqz

// Test equality to zero
func (state *ComputePeerState) Eqz(action *sproto.Action) *sproto.Response {
	//fmt.Println("Comparing values")
	result := *action.Result
	share0 := *action.Share0
	share0val, hasShare0Val := state.SharesGet(share0)
	rcode := *action.RequestCode
	if !hasShare0Val {
		return state.failResponse(action.GetRequestCode())
	}
	res := state.neqz(share0val, rcode)
	one := int64(1)
	res = core.Sub(one, res)
	state.SharesSet(result, res)
	//fmt.Printf("Done testing value for zero\n")
	return state.okResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:17,代碼來源:operations.go

示例7: Neq

// Inequality
func (state *ComputePeerState) Neq(action *sproto.Action) *sproto.Response {
	//fmt.Println("Comparing values")
	result := *action.Result
	share0 := *action.Share0
	share1 := *action.Share1
	share0val, hasShare0Val := state.SharesGet(share0)
	share1val, hasShare1Val := state.SharesGet(share1)
	rcode := *action.RequestCode
	if !hasShare0Val || !hasShare1Val {
		return state.failResponse(action.GetRequestCode())
	}
	res := state.ncmp(share0val, share1val, rcode)
	state.SharesSet(result, res)
	//fmt.Printf("Done comparing values\n")
	return state.okResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:17,代碼來源:operations.go

示例8: SetValue

// Set the value of a share
func (state *ComputePeerState) SetValue(action *sproto.Action) *sproto.Response {
	//fmt.Println("Setting value ", *action.Result, *action.Value)
	result := *action.Result
	val := *action.Value
	state.SharesSet(result, int64(val))
	//fmt.Println("Returned from sharesset")
	resp := &sproto.Response{}
	rcode := action.GetRequestCode()
	resp.RequestCode = &rcode
	status := sproto.Response_OK
	resp.Status = &status
	client := int32(state.Client)
	resp.Client = &client
	//fmt.Println("Done setting value")
	return resp
}
開發者ID:apanda,項目名稱:smpc,代碼行數:17,代碼來源:operations.go

示例9: NeqConst

// Compare to const
func (state *ComputePeerState) NeqConst(action *sproto.Action) *sproto.Response {
	//fmt.Println("Comparing to constant")
	result := *action.Result
	share0 := *action.Share0
	val := *action.Value
	share0val, hasShare0Val := state.SharesGet(share0)
	rcode := *action.RequestCode
	if !hasShare0Val {
		//fmt.Printf("Failing, variable %s not found\n", share0)
		return state.failResponse(action.GetRequestCode())
	}
	res := core.Sub(val, share0val)
	//fmt.Printf("Subtractiong const %d", val)
	res = state.neqz(res, rcode)
	state.SharesSet(result, res)
	//fmt.Printf("Done comparing to const\n")
	return state.okResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:19,代碼來源:operations.go

示例10: RemoveValue

// Remove the value for a share
func (state *ComputePeerState) RemoveValue(action *sproto.Action) *sproto.Response {
	result := *action.Result
	_, hasVal := state.SharesGet(result)
	if hasVal {
		//fmt.Println("Deleting value ", *action.Result)
		result := *action.Result
		state.SharesDelete(result)
		//fmt.Println("Returned from sharesdelete")
		resp := &sproto.Response{}
		rcode := action.GetRequestCode()
		resp.RequestCode = &rcode
		status := sproto.Response_OK
		resp.Status = &status
		client := int32(state.Client)
		resp.Client = &client
		//fmt.Println("Done setting value")
		return resp
	}
	return state.failResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:21,代碼來源:operations.go

示例11: Mul

// Multiply two shares
func (state *ComputePeerState) Mul(action *sproto.Action) *sproto.Response {
	//fmt.Println("Multiplying two values")
	result := *action.Result
	share0 := *action.Share0
	share1 := *action.Share1
	share0val, hasShare0val := state.SharesGet(share0)
	share1val, hasShare1val := state.SharesGet(share1)
	//fmt.Printf("Multiplying, will set %s\n", result)
	rcode := *action.RequestCode
	if hasShare0val && hasShare1val {
		share := state.mul(share0val, share1val, rcode, 1)
		//fmt.Printf("Done multiplying, setting %s\n", result)
		state.SharesSet(result, share)
		//fmt.Printf("Done multiplying, done setting %s\n", result)
		//fmt.Printf("Done multiplying\n")
		state.UnregisterChannelForRequest(*MakeRequestStep(rcode, 1))
		return state.okResponse(action.GetRequestCode())
	} else {
		//fmt.Printf("Not setting %s, could not find operands %s %v %s %v\n", result, share0, hasShare0val, share1, hasShare1val)
	}
	return state.failResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:23,代碼來源:operations.go

示例12: CmpConst

// Compare to const
func (state *ComputePeerState) CmpConst(action *sproto.Action) *sproto.Response {
	//fmt.Println("Comparing to constant")
	result := *action.Result
	share0 := *action.Share0
	val := *action.Value
	share0val, hasShare0Val := state.SharesGet(share0)
	rcode := *action.RequestCode
	if !hasShare0Val {
		return state.failResponse(action.GetRequestCode())
	}
	//fmt.Printf("For rcode %d (CMPCONST) subtracting\n", rcode)
	res := core.Sub(val, share0val)
	//fmt.Printf("For rcode %d (CMPCONST) neqz\n", rcode)
	res = state.neqz(res, rcode)
	//fmt.Printf("For rcode %d (CMPCONST) done with neqz\n", rcode)
	one := int64(1)
	//fmt.Printf("For rcode %d (CMPCONST) subtracting\n", rcode)
	res = core.Sub(one, res)
	//fmt.Printf("For rcode %d (CMPCONST) setting share\n", rcode)
	state.SharesSet(result, res)
	//fmt.Printf("Done comparing to const\n")
	return state.okResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:24,代碼來源:operations.go

示例13: DefaultAction

func (state *ComputePeerState) DefaultAction(action *sproto.Action) *sproto.Response {
	//fmt.Println("Illegal action")
	return state.failResponse(action.GetRequestCode())
}
開發者ID:apanda,項目名稱:smpc,代碼行數:4,代碼來源:operations.go


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