github.com/cranelv/ethereum_mpc@v0.0.0-20191031014521-23aeb1415092/mpcService/mpc_ctx_factory.go (about)

     1  package mpcService
     2  
     3  import (
     4  	"github.com/ethereum/go-ethereum/mpcService/protocol"
     5  	"github.com/ethereum/go-ethereum/common"
     6  	"github.com/ethereum/go-ethereum/p2p/discover"
     7  )
     8  
     9  type MpcCtxFactory struct {
    10  }
    11  
    12  func (*MpcCtxFactory) CreateContext(ctxType uint, hash common.Hash, peers []protocol.PeerInfo,leader *discover.NodeID, preSetValue ...protocol.MpcValue) (MpcInterface, error) {
    13  	switch ctxType {
    14  	case protocol.MpcCreateLockAccountLeader:
    15  		return requestCreateLockAccountMpc(hash, peers,leader, preSetValue...)
    16  	case protocol.MpcCreateLockAccountPeer:
    17  		return acknowledgeCreateLockAccountMpc(hash, peers,leader, preSetValue...)
    18  
    19  	case protocol.MpcTXSignLeader:
    20  		return requestTxSignMpc(hash, peers,leader, preSetValue...)
    21  	case protocol.MpcTXSignPeer:
    22  		return acknowledgeTxSignMpc(hash, peers,leader, preSetValue...)
    23  	}
    24  
    25  	return nil, protocol.ErrContextType
    26  }