mpcService

package
v0.0.0-...-23aeb14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2019 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MpcName       = "eth"
	MpcVersion    = 1
	MpcVersionStr = "1.0"
)
View Source
const (
	MpcInterval = 30
	MpcCacity   = 20
)

Variables

This section is empty.

Functions

func GetAddressAndHash

func GetAddressAndHash(message *protocol.MpcMessage) (hash common.Hash, address common.MpcAddress, have bool)

func NewMpcNodeInfo

func NewMpcNodeInfo() *mpcNodeInfo

func NodeInfoKey

func NodeInfoKey(hash common.Hash, addr common.MpcAddress) common.Hash

Types

type BaseMpcResult

type BaseMpcResult struct {
	Result map[string]interface{}
	// contains filtered or unexported fields
}

func (*BaseMpcResult) GetValue

func (mpc *BaseMpcResult) GetValue(key string) (interface{}, error)

func (*BaseMpcResult) Initialize

func (result *BaseMpcResult) Initialize(preSetValue ...protocol.MpcValue)

func (*BaseMpcResult) SetValue

func (mpc *BaseMpcResult) SetValue(key string, value interface{}) error

type MemStatus

type MemStatus struct {
	All  uint64 `json:"all"`
	Used uint64 `json:"used"`
	Free uint64 `json:"free"`
	Self uint64 `json:"self"`
}

type MpcAddress

type MpcAddress struct {
	Address  string `json:"address"`
	PassWord string `json:"password"`
}

type MpcConfig

type MpcConfig struct {
	Address  []MpcAddress `json:"mpcAddress"`
	PassWord string       `json:"password"`
	DataDir  string       `json:"datadir"`
}

type MpcContext

type MpcContext struct {
	ContextID common.Hash //Unique id for every content

	NodeInfo protocol.MpcNodeInterface

	MpcSteps    []protocol.MpcStepFunc
	MapStepChan map[uint64]chan *protocol.StepMessage
	// contains filtered or unexported fields
}

func (*MpcContext) SubscribeResult

func (mpcCtx *MpcContext) SubscribeResult(result chan<- *protocol.MpcResult)

type MpcContextCreater

type MpcContextCreater interface {
	CreateContext(uint, common.Hash, []protocol.PeerInfo, *discover.NodeID, ...protocol.MpcValue) (MpcInterface, error) //createContext
}

type MpcCtxFactory

type MpcCtxFactory struct {
}

func (*MpcCtxFactory) CreateContext

func (*MpcCtxFactory) CreateContext(ctxType uint, hash common.Hash, peers []protocol.PeerInfo, leader *discover.NodeID, preSetValue ...protocol.MpcValue) (MpcInterface, error)

type MpcDistributor

type MpcDistributor struct {
	P2pMessager P2pMessager
	// contains filtered or unexported fields
}

func CreateMpcDistributor

func CreateMpcDistributor(keystoreDir string, msger P2pMessager, password string) *MpcDistributor

func (*MpcDistributor) BoardcastMessage

func (mpcServer *MpcDistributor) BoardcastMessage(peers []*discover.NodeID, code uint64, msg interface{}) error

func (*MpcDistributor) CreateKeystore

func (mpcServer *MpcDistributor) CreateKeystore(result protocol.MpcResultInterface, nodeInfo protocol.MpcNodeInterface) error

func (*MpcDistributor) CreateRequestMpc

func (mpcServer *MpcDistributor) CreateRequestMpc()

func (*MpcDistributor) FinishMpc

func (mpcServer *MpcDistributor) FinishMpc(PeerID *discover.NodeID, mpcMessage *protocol.MpcMessage) error

func (*MpcDistributor) GetMessage

func (mpcServer *MpcDistributor) GetMessage(PeerID discover.NodeID, msg *p2p.Msg) error

func (*MpcDistributor) GetPeerLeader

func (mpcServer *MpcDistributor) GetPeerLeader(bRequest bool) *discover.NodeID

func (*MpcDistributor) MessageLoop

func (mpcServer *MpcDistributor) MessageLoop()

func (*MpcDistributor) MpcAccountRequest

func (mpcServer *MpcDistributor) MpcAccountRequest() (hexutil.Bytes, error)

func (*MpcDistributor) NewTime

func (mpcServer *MpcDistributor) NewTime()

func (*MpcDistributor) P2pMessage

func (mpcServer *MpcDistributor) P2pMessage(peerID *discover.NodeID, code uint64, msg interface{}) error

func (*MpcDistributor) QuitMpcContext

func (mpcServer *MpcDistributor) QuitMpcContext(msg *protocol.MpcMessage)

func (*MpcDistributor) SelfNodeId

func (mpcServer *MpcDistributor) SelfNodeId() *discover.NodeID

func (*MpcDistributor) SendSignRequestPrepare

func (mpcServer *MpcDistributor) SendSignRequestPrepare(txHash common.Hash, address common.MpcAddress) error

func (*MpcDistributor) SignTransaction

func (mpcServer *MpcDistributor) SignTransaction(result protocol.MpcResultInterface) error

func (*MpcDistributor) Start

func (mpcServer *MpcDistributor) Start()

func (*MpcDistributor) Stop

func (mpcServer *MpcDistributor) Stop()

func (*MpcDistributor) UnlockKeystore

func (mpcServer *MpcDistributor) UnlockKeystore(address common.MpcAddress, password string) error

type MpcInterface

type MpcInterface interface {
	SubscribeResult(chan<- *protocol.MpcResult)
	// contains filtered or unexported methods
}

type MpcKey

type MpcKey struct {
	Hash    common.Hash
	Address common.MpcAddress
}

type MpcService

type MpcService struct {
	MpcPeerGroup []*discover.NodeID
	// contains filtered or unexported fields
}

func New

func New(cfg *MpcConfig) *MpcService

New creates a Whisper client ready to communicate through the Ethereum P2P network.

func (*MpcService) APIs

func (ms *MpcService) APIs() []rpc.API

APIs returns the RPC descriptors the Whisper implementation offers

func (*MpcService) GetPeers

func (mp *MpcService) GetPeers() []*discover.NodeID

func (*MpcService) HandlePeer

func (ms *MpcService) HandlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error

HandlePeer is called by the underlying P2P layer when the whisper sub-protocol connection is negotiated.

func (*MpcService) IsActivePeer

func (ms *MpcService) IsActivePeer(peerID *discover.NodeID) bool

func (*MpcService) MaxMessageSize

func (ms *MpcService) MaxMessageSize() uint32

MaxMessageSize returns the maximum accepted message size.

func (*MpcService) MessageChannel

func (mp *MpcService) MessageChannel() <-chan protocol.PeerMessage

func (*MpcService) Protocols

func (ms *MpcService) Protocols() []p2p.Protocol

Protocols returns the whisper sub-protocols ran by this particular client.

func (*MpcService) Self

func (mp *MpcService) Self() *discover.Node

func (*MpcService) SendToPeer

func (ms *MpcService) SendToPeer(peerID *discover.NodeID, msgcode uint64, data interface{}) error

func (*MpcService) Start

func (ms *MpcService) Start(server *p2p.Server) error

Start implements node.Service, starting the background data propagation thread of the Whisper protocol.

func (*MpcService) Stop

func (ms *MpcService) Stop() error

Stop implements node.Service, stopping the background data propagation thread of the Whisper protocol.

type MpcTestCtxFactory

type MpcTestCtxFactory struct {
	// contains filtered or unexported fields
}

func (*MpcTestCtxFactory) CreateContext

func (mf *MpcTestCtxFactory) CreateContext(ctxType uint, hash common.Hash, peers []protocol.PeerInfo, leader *discover.NodeID, preSetValue ...protocol.MpcValue) (MpcInterface, error)

func (*MpcTestCtxFactory) CreateRequestAccountMpc

func (mf *MpcTestCtxFactory) CreateRequestAccountMpc(mpcID common.Hash, peers []protocol.PeerInfo, leader *discover.NodeID, preSetValue ...protocol.MpcValue) (*MpcContext, error)

send create LockAccount from leader

type NodeCollection

type NodeCollection struct {
	Quorum int

	Seeds      []protocol.PeerInfo
	Collection map[discover.NodeID]uint64
	// contains filtered or unexported fields
}

func NewNodeCollection

func NewNodeCollection(hash common.Hash, peers []*discover.NodeID, leader *discover.NodeID, key *keystore.MpcKey) *NodeCollection

func NewNodeQuorum

func NewNodeQuorum(peers []protocol.PeerInfo, leader *discover.NodeID) *NodeCollection

func (*NodeCollection) AddNode

func (nc *NodeCollection) AddNode(seed uint64, nodeId *discover.NodeID) error

func (*NodeCollection) Address

func (nc *NodeCollection) Address() *common.MpcAddress

func (*NodeCollection) FetchQuorum

func (nc *NodeCollection) FetchQuorum() bool

func (*NodeCollection) GetNodeId

func (nc *NodeCollection) GetNodeId(seed uint64) *discover.NodeID

func (*NodeCollection) GetPeerIDs

func (nc *NodeCollection) GetPeerIDs() []*discover.NodeID

func (*NodeCollection) GetPeers

func (nc *NodeCollection) GetPeers() []protocol.PeerInfo

func (*NodeCollection) GetSeed

func (nc *NodeCollection) GetSeed(nodeId *discover.NodeID) uint64

func (*NodeCollection) GetSeedsNum

func (nc *NodeCollection) GetSeedsNum(seed uint64, nodeId *discover.NodeID) int

func (*NodeCollection) GetState

func (nc *NodeCollection) GetState() protocol.MpcState

func (*NodeCollection) Hash

func (nc *NodeCollection) Hash() *common.Hash

func (*NodeCollection) InitfromKey

func (nc *NodeCollection) InitfromKey(key *keystore.MpcKey)

func (*NodeCollection) Leader

func (nc *NodeCollection) Leader() *discover.NodeID

func (*NodeCollection) NeedQuorum

func (nc *NodeCollection) NeedQuorum() int

func (*NodeCollection) RunNode

func (nc *NodeCollection) RunNode(seed uint64, nodeId *discover.NodeID) protocol.MpcState

func (*NodeCollection) SetState

func (nc *NodeCollection) SetState(state protocol.MpcState)

type P2pMessager

type P2pMessager interface {
	SendToPeer(*discover.NodeID, uint64, interface{}) error
	MessageChannel() <-chan protocol.PeerMessage
	GetPeers() []*discover.NodeID
	Self() *discover.Node
	IsActivePeer(*discover.NodeID) bool
}

type Peer

type Peer struct {
	//	host    *Storeman
	*p2p.Peer
	// contains filtered or unexported fields
}

peer represents a whisper protocol peer connection.

func (*Peer) ID

func (p *Peer) ID() discover.NodeID

type StoremanAPI

type StoremanAPI struct {
	// contains filtered or unexported fields
}

func (*StoremanAPI) CreateMpcAccount

func (sa *StoremanAPI) CreateMpcAccount(ctx context.Context) (hexutil.Bytes, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL