Documentation ¶
Index ¶
- Constants
- Variables
- func GetLocalhostAddress(h core.Host) string
- type Libp2pPubSub
- func (c *Libp2pPubSub) AttackVictim()
- func (c *Libp2pPubSub) Broadcast(msgBytes []byte)
- func (c *Libp2pPubSub) BroadcastMsg(msg model.Message)
- func (c *Libp2pPubSub) Cancel(cancelTime int, reconnectTime int)
- func (c *Libp2pPubSub) CreatePeer(nodeId int, port int) *core.Host
- func (c *Libp2pPubSub) CreatePeerWithIp(nodeId int, ip string, port int) *core.Host
- func (c *Libp2pPubSub) Disconnect()
- func (c *Libp2pPubSub) InitializePubSub(h core.Host)
- func (c *Libp2pPubSub) InitializeVictim(makeBuffer bool)
- func (c *Libp2pPubSub) JoinGroup(group []int)
- func (c *Libp2pPubSub) Receive() *[]byte
- func (c *Libp2pPubSub) Reconnect(topic string)
- func (c *Libp2pPubSub) ReleaseVictim()
- func (c *Libp2pPubSub) Send(msgBytes []byte, id int)
Constants ¶
const BufferLen = 500
Variables ¶
var Delayed = true
Functions ¶
func GetLocalhostAddress ¶
GetLocalhostAddress is used for getting address of hosts
Types ¶
type Libp2pPubSub ¶
type Libp2pPubSub struct {
// contains filtered or unexported fields
}
func (*Libp2pPubSub) AttackVictim ¶
func (c *Libp2pPubSub) AttackVictim()
AttackVictim adds a node to the set of indefinite-delayed nodes.
func (*Libp2pPubSub) Broadcast ¶
func (c *Libp2pPubSub) Broadcast(msgBytes []byte)
Broadcast Uses PubSub publish to broadcast messages to other peers
func (*Libp2pPubSub) BroadcastMsg ¶
func (c *Libp2pPubSub) BroadcastMsg(msg model.Message)
func (*Libp2pPubSub) Cancel ¶
func (c *Libp2pPubSub) Cancel(cancelTime int, reconnectTime int)
Cancel unsubscribes a node from pubsub
func (*Libp2pPubSub) CreatePeer ¶
func (c *Libp2pPubSub) CreatePeer(nodeId int, port int) *core.Host
createPeer creates a peer on localhost and configures it to use libp2p.
func (*Libp2pPubSub) CreatePeerWithIp ¶
CreatePeerWithIp creates a peer on specified ip and port and configures it to use libp2p.
func (*Libp2pPubSub) Disconnect ¶
func (c *Libp2pPubSub) Disconnect()
func (*Libp2pPubSub) InitializePubSub ¶
func (c *Libp2pPubSub) InitializePubSub(h core.Host)
initializePubSub creates a PubSub for the peer and also subscribes to a topic
func (*Libp2pPubSub) InitializeVictim ¶
func (c *Libp2pPubSub) InitializeVictim(makeBuffer bool)
InitializeVictim initializes buffer for keeping messages when a node is attacked by adversary.
func (*Libp2pPubSub) JoinGroup ¶
func (c *Libp2pPubSub) JoinGroup(group []int)
JoinGroup adds nodes within the same groups to the node's group variable.
func (*Libp2pPubSub) Receive ¶
func (c *Libp2pPubSub) Receive() *[]byte
Receive gets message from PubSub in a blocking way
func (*Libp2pPubSub) Reconnect ¶
func (c *Libp2pPubSub) Reconnect(topic string)
func (*Libp2pPubSub) ReleaseVictim ¶
func (c *Libp2pPubSub) ReleaseVictim()
ReleaseVictim removes the node from set of delayed nodes.
func (*Libp2pPubSub) Send ¶
func (c *Libp2pPubSub) Send(msgBytes []byte, id int)
Send uses Broadcast for sending messages