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

     1  package protocol
     2  
     3  import (
     4  	"github.com/ethereum/go-ethereum/p2p/discover"
     5  	"github.com/ethereum/go-ethereum/common"
     6  )
     7  type MpcValue struct {
     8  	Key       string
     9  	Value     interface{}
    10  }
    11  type MpcResult struct {
    12  	Hash common.Hash
    13  	Result []byte
    14  }
    15  type MpcResultInterface interface {
    16  	Initialize(preSetValue ...MpcValue)
    17  	SetValue(key string, value interface{}) error
    18  	GetValue(key string) (interface{}, error)
    19  }
    20  type MpcState int
    21  const (
    22  	MpcCollection  MpcState = iota + 0
    23  	MpcWaiting
    24  	MpcRunning
    25  	MpcFinish
    26  	MpcNotFound
    27  )
    28  type MpcNodeInterface interface {
    29  	NeedQuorum()int
    30  	Address()*common.MpcAddress
    31  	Hash()*common.Hash
    32  	Leader() *discover.NodeID
    33  	FetchQuorum()bool
    34  	RunNode(uint64,*discover.NodeID)MpcState
    35  	AddNode(seed uint64,nodeId *discover.NodeID) error
    36  	GetSeedsNum(seed uint64,nodeId *discover.NodeID)int
    37  	SetState(MpcState)
    38  	GetState()MpcState
    39  	GetSeed(nodeId *discover.NodeID)uint64
    40  	GetNodeId(seed uint64) *discover.NodeID
    41  	GetPeers() []PeerInfo
    42  	GetPeerIDs() []*discover.NodeID
    43  }