github.com/cranelv/ethereum_mpc@v0.0.0-20191031014521-23aeb1415092/mpcService/step/request_mpcSign_step.go (about) 1 package step 2 3 import ( 4 "github.com/ethereum/go-ethereum/common" 5 "github.com/ethereum/go-ethereum/mpcService/protocol" 6 "github.com/ethereum/go-ethereum/log" 7 ) 8 9 type RequestMpcSignStep struct { 10 BaseStep 11 messageType int64 12 txHash common.Hash 13 address common.MpcAddress 14 message map[common.Hash]bool 15 } 16 func (req *RequestMpcSignStep) InitStep()error{ 17 addr, err := req.mpcResult.GetValue(protocol.MpcAddress) 18 if err != nil { 19 return err 20 } 21 txhash, err := req.mpcResult.GetValue(protocol.MpcTxHash) 22 if err != nil { 23 return err 24 } 25 req.address = common.BytesToMpcAddress(addr.([]byte)) 26 req.txHash = common.BytesToHash(txhash.([]byte)) 27 return nil 28 } 29 30 func (req *RequestMpcSignStep) CreateMessage() []protocol.StepMessage { 31 msg := protocol.StepMessage{ 32 Msgcode:protocol.MSG_RequestMPC, 33 PeerID:nil, 34 Peers:req.nodeInfo.GetPeers()} 35 msg.Data = append(msg.Data,&protocol.MpcData{protocol.MpcAddress,req.address}) 36 msg.Data = append(msg.Data,&protocol.MpcData{protocol.MpcTxHash,req.txHash[:]}) 37 return []protocol.StepMessage{msg} 38 } 39 40 func (req *RequestMpcSignStep) FinishStep(mpc protocol.MpcManager) error { 41 err := req.BaseStep.FinishStep() 42 if err != nil { 43 return err 44 } 45 46 return nil 47 } 48 49 func (req *RequestMpcSignStep) HandleMessage(msg *protocol.StepMessage) bool { 50 log.Info("RequestMpcStep.HandleMessage begin, peerID:%s", msg.PeerID) 51 return true 52 }