HashGraph

Handles over all HashGraph algorithm 1. The event graph 2. Node information 3. Round information 4. The wave-from gossip state 5. And the refinement of generated epochs

@safe
class HashGraph {
enum default_scrap_depth;
int scrap_depth;
immutable(string) name;
HashGraphStatistics statistics;
BitMask _excluded_nodes_mask;
Refinement refinement;
protected
Node _owner_node;
const
HiRPC hirpc;
protected
EventCache _event_cache;
Topic topic;
protected
Register _register;
}

Constructors

this
this(size_t node_size, SecureNet net, Refinement refinement, GossipNet gossip_net, string name)

Creates a graph with node_size nodes

Members

Classes

Node
class Node

Contains the information of an active node

Register
class Register

Cache holding the event package current processed

Functions

areWeInGraph
bool areWeInGraph()
buildWavefront
const(Wavefront) buildWavefront(ExchangeState state, Tides tides)

Build a wave-front which can be package and send to another node

channel
Pubkey channel()

The channel is the public key used by this node

channels
const(Pubkey[]) channels()
createEvaEvent
Event createEvaEvent(sdt_t time, Buffer nonce)

Create the first event for this node Uses the eva_pack function to created the event-package

create_init_tide
const(HiRPC.Sender) create_init_tide(Document payload, sdt_t time)
const(HiRPC.Sender) create_init_tide(T payload, sdt_t time)

Creates and wave-front init-tide as a HiRPC Which can be send to other active nodes Note. Will generate tidalWavewave but if the node are not yet in the graph then a sharpWave is generate

eliminate
void eliminate(const(Buffer) fingerprint)

Removes an event-package with the fingerprint

eva_pack
immutable(EventPackage*) eva_pack(sdt_t time, Buffer nonce)

Special function to generate the first event-package when the this node starts

event_pack
immutable(EventPackage)* event_pack(sdt_t time, const(Event) father_event, Document doc)

Create and event package which can be serialized and send to other nodes

getNode
Node getNode(Pubkey channel)

Same as node(channel) except that the node will be add if it doesn't exists This function is only used internally

isMajority
bool isMajority(size_t votes)

Checks if votes is the majority

net
const(SecureNet) net()
next_event_id
uint next_event_id()

Used to set the local Event.id

next_node_id
uint next_node_id()
node
const(Node) node(Pubkey channel)

Lookup the node on the channel

nodes
const(Node[Pubkey]) nodes()

Get a map of all the nodes currently handled by the graph

number_of_registered_event
size_t number_of_registered_event()
opSlice
NodeRange opSlice()
owner_node
const(Node) owner_node()
register
Event register(const(Buffer) fingerprint)

Register the event-package with the fingerprint hash Calls the Register.register function if it's defined or else it uses the event_cache

register_wavefront
const(Event) register_wavefront(Wavefront received_wave, Pubkey from_channel)
removeNode
bool removeNode(Pubkey channel)

Remove the node at the channel

rounds
const(Round.Rounder) rounds()

* The rounds containing the information of rounds which a process or has been processed * The processed rounds will over time be erased * Returns:

select_channel
Pubkey select_channel()
sharpResponse
const(Wavefront) sharpResponse(Wavefront received_wave)
sharpWave
const(Wavefront) sharpWave()

First time it is called we only send our own eva since this is all we know. Later we send everything it knows.

tidalWave
const(Wavefront) tidalWave()

to synchronize two _nodes A and B 1) Node A send it's wave front to B This is done via the waveFront function 2) B collects all the events it has which is are in front of the wave front of A. This is done via the waveFront function B send the all the collected event to B including B's wave font of all the node which B know it leads in, The wave from is collect via the waveFront function by adding the remaining tides 3) A send the rest of the event which is in front of B's wave-front

wavefront_response
HiRPC.Sender wavefront_response(HiRPC.Receiver received, const(sdt_t) time, const(Document) payload)

Converts a received wave-front to a response. Handles the wavefront-state dependent response. If the package is not recognized the an HiRPC error response is generated

Variables

_rounds
Round.Rounder _rounds;

The rounder hold the round in the queue both decided and undecided rounds

node_size
size_t node_size;

Number of active nodes in the graph