mapping

package
v0.0.0-...-d9fe26e Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const NullMappingID = MappingID("")

Variables

This section is empty.

Functions

This section is empty.

Types

type MappingDataSource

type MappingDataSource interface {
	Init()
	GetType() string
	SetMappingNode(*MappingNode) error
	RetrieveKeyMapping(index big.Int) (MappingKey, error)
}

type MappingID

type MappingID string

MappingID is the identifying string for MappingMessage

type MappingIDDetails

type MappingIDDetails struct {
	OldEpoch int
	NewEpoch int
}

func (*MappingIDDetails) FromMappingID

func (mappingIDDetails *MappingIDDetails) FromMappingID(mappingID MappingID) error

func (*MappingIDDetails) ToMappingID

func (mappingIDDetails *MappingIDDetails) ToMappingID() MappingID

type MappingKey

type MappingKey struct {
	Index     big.Int             `json:"index"`
	PublicKey common.Point        `json:"publicKey"`
	Threshold int                 `json:"threshold"`
	Verifiers map[string][]string `json:"verifiers"` // Verifier => VerifierID
}

func (*MappingKey) ID

func (m *MappingKey) ID() MappingKeyID

type MappingKeyBroadcastMessage

type MappingKeyBroadcastMessage struct {
	MappingKey MappingKey
}

type MappingKeyID

type MappingKeyID string

type MappingKeyIDToNodeDetailsIDToIntCMap

type MappingKeyIDToNodeDetailsIDToIntCMap struct {
	cmap.ConcurrentMap
}

func NewMappingKeyIDToNodeDetailsIDToIntCMap

func NewMappingKeyIDToNodeDetailsIDToIntCMap() *MappingKeyIDToNodeDetailsIDToIntCMap

func (*MappingKeyIDToNodeDetailsIDToIntCMap) Get

func (s *MappingKeyIDToNodeDetailsIDToIntCMap) Get(mappingKeyID MappingKeyID) (nodeDetailsIDToIntSyncMap *NodeDetailsIDToIntCMap)

func (*MappingKeyIDToNodeDetailsIDToIntCMap) Set

func (s *MappingKeyIDToNodeDetailsIDToIntCMap) Set(mappingKeyID MappingKeyID, nodeDetailsIDToIntCMap *NodeDetailsIDToIntCMap)

func (*MappingKeyIDToNodeDetailsIDToIntCMap) SyncUpdate

type MappingKeyMessage

type MappingKeyMessage struct {
	MappingKey MappingKey
}

type MappingKeys

type MappingKeys struct {
	SendCount *MappingKeyIDToNodeDetailsIDToIntCMap
}

type MappingMessage

type MappingMessage struct {
	Version   mappingMessageVersion `json:"version,omitempty"`
	MappingID MappingID             `json:"mappingID"`
	Method    string                `json:"method"`
	Data      []byte                `json:"data"`
}

MappingMessage should not be used directly, use the CreateMappingMessage constructor

func CreateMappingMessage

func CreateMappingMessage(r MappingMessageRaw) MappingMessage

type MappingMessageRaw

type MappingMessageRaw struct {
	MappingID MappingID
	Method    string
	Data      []byte
}

type MappingNode

type MappingNode struct {
	idmutex.Mutex
	NodeDetails    NodeDetails
	OldNodes       NodeNetwork
	NewNodes       NodeNetwork
	NodeIndex      int
	Transport      MappingTransport
	DataSource     MappingDataSource
	MappingSummary *MappingSummary
	MappingKeys    *MappingKeys
	IsOldNode      bool
	IsNewNode      bool
}

func NewMappingNode

func NewMappingNode(
	nodeDetails pcmn.Node,
	oldEpoch int,
	oldNodeList []pcmn.Node,
	oldNodesT int,
	oldNodesK int,
	newEpoch int,
	newNodeList []pcmn.Node,
	newNodesT int,
	newNodesK int,
	nodeIndex int,
	transport MappingTransport,
	dataSource MappingDataSource,
	isOldNode bool,
	isNewNode bool,
) *MappingNode

func (*MappingNode) ProcessBroadcastMessage

func (mappingNode *MappingNode) ProcessBroadcastMessage(mappingMessage MappingMessage) error

ProcessBroadcastMessage is called when the node receives a message via broadcast (eg. Tendermint)

func (*MappingNode) ProcessMessage

func (mappingNode *MappingNode) ProcessMessage(senderDetails NodeDetails, mappingMessage MappingMessage) error

ProcessMessage is called when the transport for the node receives a message via direct send. It works similar to a router, processing different messages differently based on their associated method. Each method handler's code path consists of parsing the message -> state checks -> logic -> state updates. Defer state changes until the end of the function call to ensure that the state is consistent in the handler. When sending messages to other nodes, it's important to use a goroutine to ensure that it isnt synchronous We assume that senderDetails have already been validated by the transport and are always correct

type MappingProposeFreezeBroadcastMessage

type MappingProposeFreezeBroadcastMessage struct {
	MappingID MappingID
}

type MappingProposeFreezeMessage

type MappingProposeFreezeMessage struct {
	MappingID MappingID
}

type MappingSummary

type MappingSummary struct {
	SendCount           *NodeDetailsToIntCMap
	MappingSummaryStore *TransferSummaryIDToTransferSummaryCMap
	MappingSummaryCount *TransferSummaryToIntCMap
}

type MappingSummaryBroadcastMessage

type MappingSummaryBroadcastMessage struct {
	TransferSummary TransferSummary
}

type MappingSummaryMessage

type MappingSummaryMessage struct {
	TransferSummary TransferSummary
}

type MappingTransport

type MappingTransport interface {
	Init()
	GetType() string
	SetMappingNode(*MappingNode) error
	Sign([]byte) ([]byte, error)
	Send(NodeDetails, MappingMessage) error
	Receive(NodeDetails, MappingMessage) error
	SendBroadcast(MappingMessage) error
	ReceiveBroadcast(MappingMessage) error
	Output(interface{})
}

type NodeDetails

type NodeDetails pcmn.Node

func (*NodeDetails) FromNodeDetailsID

func (n *NodeDetails) FromNodeDetailsID(nodeDetailsID NodeDetailsID)

func (*NodeDetails) ToNodeDetailsID

func (n *NodeDetails) ToNodeDetailsID() NodeDetailsID

type NodeDetailsID

type NodeDetailsID string

type NodeDetailsIDToIntCMap

type NodeDetailsIDToIntCMap struct {
	cmap.ConcurrentMap
}

func NewNodeDetailsIDToIntCMap

func NewNodeDetailsIDToIntCMap() *NodeDetailsIDToIntCMap

func (*NodeDetailsIDToIntCMap) Get

func (s *NodeDetailsIDToIntCMap) Get(nodeDetailsID NodeDetailsID) (i int)

func (*NodeDetailsIDToIntCMap) Set

func (s *NodeDetailsIDToIntCMap) Set(nodeDetailsID NodeDetailsID, i int)

type NodeDetailsToIntCMap

type NodeDetailsToIntCMap struct {
	cmap.ConcurrentMap
}

func NewNodeDetailsToIntCMap

func NewNodeDetailsToIntCMap() *NodeDetailsToIntCMap

func (*NodeDetailsToIntCMap) Get

func (s *NodeDetailsToIntCMap) Get(nodeDetailsID NodeDetailsID) (i int)

func (*NodeDetailsToIntCMap) Set

func (s *NodeDetailsToIntCMap) Set(nodeDetailsID NodeDetailsID, i int)

type NodeNetwork

type NodeNetwork struct {
	Nodes   map[NodeDetailsID]NodeDetails
	N       int
	T       int
	K       int
	EpochID int
}

func (*NodeNetwork) NodeExists

func (nodeNetwork *NodeNetwork) NodeExists(nodeDetails NodeDetails) bool

type TransferSummary

type TransferSummary struct {
	LastUnassignedIndex uint `json:"last_unassigned_index"`
}

func (*TransferSummary) ID

type TransferSummaryID

type TransferSummaryID string

type TransferSummaryIDToTransferSummaryCMap

type TransferSummaryIDToTransferSummaryCMap struct {
	cmap.ConcurrentMap
}

func NewTransferSummaryIDToTransferSummaryCMap

func NewTransferSummaryIDToTransferSummaryCMap() *TransferSummaryIDToTransferSummaryCMap

func (*TransferSummaryIDToTransferSummaryCMap) Get

func (s *TransferSummaryIDToTransferSummaryCMap) Get(transferSummaryID TransferSummaryID) (transferSummary TransferSummary)

func (*TransferSummaryIDToTransferSummaryCMap) Set

func (s *TransferSummaryIDToTransferSummaryCMap) Set(transferSummaryID TransferSummaryID, transferSummary TransferSummary)

type TransferSummaryToIntCMap

type TransferSummaryToIntCMap struct {
	cmap.ConcurrentMap
}

func NewTransferSummaryToIntCMap

func NewTransferSummaryToIntCMap() *TransferSummaryToIntCMap

func (*TransferSummaryToIntCMap) Get

func (s *TransferSummaryToIntCMap) Get(transferSummaryID TransferSummaryID) (i int)

func (*TransferSummaryToIntCMap) Set

func (s *TransferSummaryToIntCMap) Set(transferSummaryID TransferSummaryID, i int)

func (*TransferSummaryToIntCMap) SyncUpdate

func (s *TransferSummaryToIntCMap) SyncUpdate(transferSummaryID TransferSummaryID, cb func(valueInMap int) int) (res int)

type VerifierIterator

type VerifierIterator struct {
	pcmn.Iterator
}

func (*VerifierIterator) Value

func (v *VerifierIterator) Value() (val pcmn.VerifierData)

Jump to

Keyboard shortcuts

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