gossip.util package¶
Submodule which contains different utility functions for usage all over Gossip.
Submodules¶
gossip.util.byte_formatting module¶
gossip.util.config_parser module¶
gossip.util.exceptions module¶
gossip.util.message module¶
-
class
gossip.util.message.MessageGossip(code, data)[source]¶ Bases:
objectBaseclass for gossip messages
C’tor
Parameters: code – the code of this message -
encode()[source]¶ Encodes this message into a byte array
Returns: a byte array with the encoded header and payload
-
-
class
gossip.util.message.MessageGossip51x(code, data)[source]¶ Bases:
gossip.util.message.MessageGossipBaseclass for gossip messages of code 510-519
C’Tor
Parameters: code – the code of this message
-
class
gossip.util.message.MessageGossipAnnounce(data)[source]¶ Bases:
gossip.util.message.MessageGossipGossipAnnounceMessage This messages are received from api connections. If you want to implement an api client for gossip its messages need to be structured like that
C’Tor
Parameters: data (bytes) – the data of the message
-
class
gossip.util.message.MessageGossipNotification(data)[source]¶ Bases:
gossip.util.message.MessageGossipMessage that is sent from gossip to api clients which was received from other peers
C’Tor
Parameters: data (bytes) – the data from this message
-
class
gossip.util.message.MessageGossipNotify(data)[source]¶ Bases:
gossip.util.message.MessageGossipThis message is sent from the gossip instance to all apis that registered for this specific datatype An api client needs to implement this messageformat
C’Tor
Parameters: data (bytes) – the data of the message
-
class
gossip.util.message.MessageGossipPeerInit(data)[source]¶ Bases:
gossip.util.message.MessageGossip51xInitial message that is sent from the connection peer to the remote peer to inform that peer about his server adderss (especially the port)
C’Tor
Parameters: data – the data from this message
-
class
gossip.util.message.MessageGossipPeerRequest(data)[source]¶ Bases:
gossip.util.message.MessageGossip51xMessage that is sent from one peer to another to get addresses of peers the other peer is connected to
C’Tor
Parameters: data – the data from this message
-
class
gossip.util.message.MessageGossipPeerResponse(data)[source]¶ Bases:
gossip.util.message.MessageGossip51xMessage that is sent as an answer to a previously sent peer request. It contains a list of server identifiers (address:port)
C’Tor
Parameters: data – the data from this message
-
class
gossip.util.message.MessageGossipPeerUpdate(data)[source]¶ Bases:
gossip.util.message.MessageGossip51xMessage that is sent recursively through the network as a respone to a new established connection
C’Tor
Parameters: data – the data from this message
-
class
gossip.util.message.MessageGossipValidation(data)[source]¶ Bases:
gossip.util.message.MessageGossipMessage that is sent from gossip to api clients to know whether or not a received message is valid
C’Tor
Parameters: data – the data from this message
gossip.util.message_code module¶
gossip.util.packing module¶
-
gossip.util.packing.pack_gossip_announce(ttl, data_type, msg_data)[source]¶ Method by which a message of type ‘GOSSIP ANNOUNCE’ is packed/encoded
Parameters: - ttl – the time to live
- data_type – the data type of the message
- msg_data – the data to pack
Returns: dict, code and data
-
gossip.util.packing.pack_gossip_notification(msg_id, data_type, msg_data)[source]¶ Method by which a message of type ‘GOSSIP NOTIFICATION’ is packed/encoded
Parameters: - msg_id – the id of the message
- data_type – the data type of the message
- msg_data – the data to pack
Returns: dict, code and data
-
gossip.util.packing.pack_gossip_notify(data_type)[source]¶ Method by which a message of type ‘GOSSIP NOTIFY’ is packed/encoded
Parameters: data_type – the data type of the message Returns: dict, code and data
-
gossip.util.packing.pack_gossip_peer_init(identifier)[source]¶ Method by which a message of type MESSAGE_CODE_PEER_INIT is packed/encoded
Returns: dict, code and data
-
gossip.util.packing.pack_gossip_peer_request(address_port)[source]¶ Method by which a message of type MESSAGE_CODE_PEER_REQUEST is packed/encoded
Returns: dict, code and data
-
gossip.util.packing.pack_gossip_peer_response(local_connections)[source]¶ Method by which a message of type MESSAGE_CODE_PEER_RESPONSE is packed/encoded
Parameters: local_connections – list with all local connections Returns: dict with format {‘code’: <message_code>, ‘data’: <data>}
-
gossip.util.packing.pack_gossip_peer_update(identifier, ttl, update_type)[source]¶ Method by which a message of type MESSAGE_CODE_PEER_UPDATE is packed/encoded
Returns: dict, code and data
-
gossip.util.packing.pack_gossip_validation(msg_id, valid_bit)[source]¶ Method by which a message of type ‘GOSSIP VALIDATION’ is packed/encoded
Parameters: - msg_id – the id of the message
- valid_bit – set iff valid, unset else value may be 0 or 1
Returns: dict, code and data
-
gossip.util.packing.pack_message_other(code, data)[source]¶ Method by which other modules messages are (re-)packed
Parameters: - code – the code of the message
- data – the data to pack
Returns: dict, code and data