algolio

package
v0.0.0-...-8cd5e98 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KnowledgeSharing      = "KnowledgeSharing"
	TransactionProcessing = "TransactionProcessing"
	PeerDiscovery         = "PeerDiscovery"
)

Define specific interaction types as constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Algolio

type Algolio interface {
	ProcessTransaction(transaction.Transaction) error
	DiscoverPeers(targetAddr string)
	ShareKnowledge(transaction.Transaction) error

	ContributeToCommunityMemory(transaction.Transaction) error
	ProcessInteraction(interaction Interaction)
	LearnFromInteraction(interaction Interaction)
	Id() string
	Metadata() map[string]string
	Con(context.Context) net.Conn
	Log(level, message string)
	GetPeers() map[string]string
	StartServer()
	Peer
}

func NewAlgolio

func NewAlgolio(id, address string) Algolio

type AlgolioImpl

type AlgolioImpl struct {
	ID          string
	InternalID  int
	Conn        net.Conn
	Peers       map[string]string
	Addr        string
	DKGInstance *ped.DistKeyGenerator
	Deals       map[int]*ped.Deal
	Responses   map[int][]*ped.Response
	PrivateKey  kyber.Scalar
	PublicKey   kyber.Point
}

func (*AlgolioImpl) Communicate

func (a *AlgolioImpl) Communicate(peer interface{}) error

func (*AlgolioImpl) CommunicateWithPeer

func (a *AlgolioImpl) CommunicateWithPeer(peer Peer) error

func (*AlgolioImpl) Con

func (a *AlgolioImpl) Con(ctx context.Context) net.Conn

func (*AlgolioImpl) ContributeToCommunityMemory

func (a *AlgolioImpl) ContributeToCommunityMemory(t transaction.Transaction) error

func (*AlgolioImpl) DiscoverPeers

func (a *AlgolioImpl) DiscoverPeers(targetAddr string)

func (*AlgolioImpl) GetID

func (a *AlgolioImpl) GetID() string

func (*AlgolioImpl) GetMetadata

func (a *AlgolioImpl) GetMetadata() map[string]string

func (*AlgolioImpl) GetPeers

func (a *AlgolioImpl) GetPeers() map[string]string

func (*AlgolioImpl) Id

func (a *AlgolioImpl) Id() string

func (*AlgolioImpl) LearnFromInteraction

func (a *AlgolioImpl) LearnFromInteraction(interaction Interaction)

func (*AlgolioImpl) Log

func (a *AlgolioImpl) Log(level, message string)

func (*AlgolioImpl) Metadata

func (a *AlgolioImpl) Metadata() map[string]string

func (*AlgolioImpl) ProcessInteraction

func (a *AlgolioImpl) ProcessInteraction(interaction Interaction)

func (*AlgolioImpl) ProcessTransaction

func (a *AlgolioImpl) ProcessTransaction(t transaction.Transaction) error

func (*AlgolioImpl) ShareKnowledge

func (a *AlgolioImpl) ShareKnowledge(t transaction.Transaction) error

func (*AlgolioImpl) StartServer

func (a *AlgolioImpl) StartServer()

type Graph

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

func (*Graph) AStar

func (g *Graph) AStar(startAddr, goalAddr string) (path []*Node)

type Interaction

type Interaction interface {
	GetType() string               // Returns the type of interaction (e.g., "KnowledgeSharing", "TransactionProcessing")
	GetDetails() map[string]string // Returns details about the interaction
}

Interaction defines the interface for interactions between Algolios.

type MockAlgolio

type MockAlgolio struct {
	ID                string
	Peers             []algolio.Algolio
	PeerInfo          []Peer
	DiscoveryCriteria map[string]string
	Metadata          map[string]string
}

MockAlgolio is a mock implementation of the Algolio interface.

func (*MockAlgolio) Communicate

func (m *MockAlgolio) Communicate(peer algolio.Algolio) error

func (*MockAlgolio) CommunicateWithPeer

func (m *MockAlgolio) CommunicateWithPeer(peer Peer) error

CommunicateWithPeer Updated CommunicateWithPeer method to initiate specific interactions

func (*MockAlgolio) ContributeToCommunityMemory

func (m *MockAlgolio) ContributeToCommunityMemory(t transaction.Transaction) error

func (*MockAlgolio) DiscoverPeers

func (m *MockAlgolio) DiscoverPeers() ([]Peer, error)

DiscoverPeers Enhanced DiscoverPeers method with dynamic criteria

func (*MockAlgolio) GetID

func (m *MockAlgolio) GetID() string

GetID Ensure MockAlgolio implements the Peer interface

func (*MockAlgolio) GetMetadata

func (m *MockAlgolio) GetMetadata() map[string]string

func (*MockAlgolio) LearnFromInteraction

func (m *MockAlgolio) LearnFromInteraction(interaction Interaction)

Simple learning mechanism to adjust Algolio's peer discovery strategy

func (*MockAlgolio) ProcessInteraction

func (m *MockAlgolio) ProcessInteraction(interaction Interaction)

ProcessInteraction Implement interaction logic in Algolio's behaviors

func (*MockAlgolio) ProcessTransaction

func (m *MockAlgolio) ProcessTransaction(t transaction.Transaction) error

func (*MockAlgolio) ShareKnowledge

func (m *MockAlgolio) ShareKnowledge(t transaction.Transaction) error

type MockInteraction

type MockInteraction struct{}

func (MockInteraction) GetDetails

func (mi MockInteraction) GetDetails() map[string]string

func (MockInteraction) GetType

func (mi MockInteraction) GetType() string

type Node

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

type Peer

type Peer interface {
	GetID() string
	GetMetadata() map[string]string
	CommunicateWithPeer(peer Peer) error
}

type SpecificInteraction

type SpecificInteraction struct {
	Type    string
	Details map[string]string
}

SpecificInteraction represents a concrete implementation of the Interaction interface, tailored to our defined interaction types.

func NewSpecificInteraction

func NewSpecificInteraction(interactionType string, details map[string]string) SpecificInteraction

NewSpecificInteraction creates a new instance of a specific interaction.

func (SpecificInteraction) GetDetails

func (si SpecificInteraction) GetDetails() map[string]string

func (SpecificInteraction) GetType

func (si SpecificInteraction) GetType() string

Jump to

Keyboard shortcuts

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