本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.IState.APIQueue方法的典型用法代碼示例。如果您正苦於以下問題:Golang IState.APIQueue方法的具體用法?Golang IState.APIQueue怎麽用?Golang IState.APIQueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/common/interfaces.IState
的用法示例。
在下文中一共展示了IState.APIQueue方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandleV2RevealEntry
func HandleV2RevealEntry(state interfaces.IState, params interface{}) (interface{}, *primitives.JSONError) {
e := new(EntryRequest)
err := MapToObject(params, e)
if err != nil {
return nil, NewInvalidParamsError()
}
entry := entryBlock.NewEntry()
if p, err := hex.DecodeString(e.Entry); err != nil {
return nil, NewInvalidEntryError()
} else {
_, err := entry.UnmarshalBinaryData(p)
if err != nil {
return nil, NewInvalidEntryError()
}
}
msg := new(messages.RevealEntryMsg)
msg.Entry = entry
msg.Timestamp = state.GetTimestamp()
state.APIQueue() <- msg
resp := new(RevealEntryResponse)
resp.Message = "Entry Reveal Success"
resp.EntryHash = entry.GetHash().String()
return resp, nil
}
示例2: HandleV2FactoidSubmit
func HandleV2FactoidSubmit(state interfaces.IState, params interface{}) (interface{}, *primitives.JSONError) {
t := new(TransactionRequest)
err := MapToObject(params, t)
if err != nil {
return nil, NewInvalidParamsError()
}
msg := new(messages.FactoidTransaction)
p, err := hex.DecodeString(t.Transaction)
if err != nil {
return nil, NewUnableToDecodeTransactionError()
}
_, err = msg.UnmarshalTransData(p)
if err != nil {
return nil, NewUnableToDecodeTransactionError()
}
state.IncFCTSubmits()
state.APIQueue() <- msg
resp := new(FactoidSubmitResponse)
resp.Message = "Successfully submitted the transaction"
resp.TxID = msg.Transaction.GetSigHash().String()
return resp, nil
}
示例3: HandleV2CommitEntry
func HandleV2CommitEntry(state interfaces.IState, params interface{}) (interface{}, *primitives.JSONError) {
commitEntryMsg := new(EntryRequest)
err := MapToObject(params, commitEntryMsg)
if err != nil {
return nil, NewInvalidParamsError()
}
commit := entryCreditBlock.NewCommitEntry()
if p, err := hex.DecodeString(commitEntryMsg.Entry); err != nil {
return nil, NewInvalidCommitEntryError()
} else {
_, err := commit.UnmarshalBinaryData(p)
if err != nil {
return nil, NewInvalidCommitEntryError()
}
}
msg := new(messages.CommitEntryMsg)
msg.CommitEntry = commit
state.APIQueue() <- msg
state.IncECommits()
resp := new(CommitEntryResponse)
resp.Message = "Entry Commit Success"
resp.TxID = commit.GetSigHash().String()
return resp, nil
}
示例4: HandleV2SendRawMessage
func HandleV2SendRawMessage(state interfaces.IState, params interface{}) (interface{}, *primitives.JSONError) {
r := new(SendRawMessageRequest)
err := MapToObject(params, r)
if err != nil {
return nil, NewInvalidParamsError()
}
data, err := hex.DecodeString(r.Message)
if err != nil {
return nil, NewInvalidParamsError()
}
_, msg, err := messages.UnmarshalMessageData(data)
if err != nil {
return nil, NewInvalidParamsError()
}
state.APIQueue() <- msg
resp := new(SendRawMessageResponse)
resp.Message = "Successfully sent the message"
return resp, nil
}