本文整理匯總了Golang中github.com/FactomProject/btcd/wire.MsgFactoidTX類的典型用法代碼示例。如果您正苦於以下問題:Golang MsgFactoidTX類的具體用法?Golang MsgFactoidTX怎麽用?Golang MsgFactoidTX使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了MsgFactoidTX類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleFactoidSubmit
func handleFactoidSubmit(ctx *web.Context) {
type x struct{ Transaction string }
t := new(x)
var p []byte
var err error
if p, err = ioutil.ReadAll(ctx.Request.Body); err != nil {
wsLog.Error(err)
returnMsg(ctx, "Unable to read the request", false)
return
} else {
if err := json.Unmarshal(p, t); err != nil {
returnMsg(ctx, "Unable to Unmarshal the request", false)
return
}
}
msg := new(wire.MsgFactoidTX)
if p, err = hex.DecodeString(t.Transaction); err != nil {
returnMsg(ctx, "Unable to decode the transaction", false)
return
}
msg.Transaction = new(fct.Transaction)
_, err = msg.Transaction.UnmarshalBinaryData(p)
if err != nil {
returnMsg(ctx, err.Error(), false)
return
}
err = common.FactoidState.Validate(1, msg.Transaction)
if err != nil {
returnMsg(ctx, err.Error(), false)
return
}
inMessageQ <- msg
returnMsg(ctx, "Successfully submitted the transaction", true)
}
示例2: processBuyEntryCredit
// processBuyEntryCredit validates the MsgCommitChain and adds it to processlist
func processBuyEntryCredit(msg *wire.MsgFactoidTX) error {
// Update the credit balance in memory
for _, v := range msg.Transaction.GetECOutputs() {
pub := new([32]byte)
copy(pub[:], v.GetAddress().Bytes())
cred := int32(v.GetAmount() / uint64(FactoshisPerCredit))
eCreditMap[string(pub[:])] += cred
}
h, _ := msg.Sha()
if plMgr.IsMyPListExceedingLimit() {
procLog.Warning("Exceeding MyProcessList size limit!")
return fMemPool.addOrphanMsg(msg, &h)
}
if _, err := plMgr.AddMyProcessListItem(msg, &h, wire.ACK_FACTOID_TX); err != nil {
return err
}
return nil
}
示例3: FactoidTX
func FactoidTX(t fct.ITransaction) error {
m := new(wire.MsgFactoidTX)
m.SetTransaction(t)
inMsgQ <- m
return nil
}