-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrand.go
39 lines (33 loc) · 1.08 KB
/
rand.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package random
import (
. "github.com/kaifei-bianjie/msg-parser/modules"
models "github.com/kaifei-bianjie/msg-parser/types"
)
type DocTxMsgRequestRand struct {
Consumer string `bson:"consumer"` // request address
BlockInterval int64 `bson:"block_interval"` // block interval after which the requested random number will be generated
Oracle bool `bson:"oracle"`
ServiceFeeCap []models.Coin `bson:"service_fee_cap"`
}
func (doctx *DocTxMsgRequestRand) GetType() string {
return TxTypeRequestRand
}
func (doctx *DocTxMsgRequestRand) BuildMsg(txMsg interface{}) {
msg := txMsg.(*MsgRequestRandom)
doctx.Consumer = msg.Consumer
doctx.BlockInterval = int64(msg.BlockInterval)
doctx.Oracle = msg.Oracle
doctx.ServiceFeeCap = models.BuildDocCoins(msg.ServiceFeeCap)
}
func (doctx *DocTxMsgRequestRand) HandleTxMsg(v SdkMsg) MsgDocInfo {
var (
addrs []string
msg MsgRequestRandom
)
ConvertMsg(v, &msg)
addrs = append(addrs, msg.Consumer)
handler := func() (Msg, []string) {
return doctx, addrs
}
return CreateMsgDocInfo(v, handler)
}