Documentation ¶
Index ¶
- type Event
- type Node
- func (n *Node) DecideFame()
- func (n *Node) DivideRounds(e *Event)
- func (n *Node) FindOrder()
- func (n *Node) GenerateTransactions(count int, max float64, min float64, peerAddress []string) []Transaction
- func (n *Node) GetNumberOfMissingEvents(numEventsAlreadyKnown map[string]int, numEventsToSend *map[string]int) error
- func (n *Node) SyncAllEvents(events SyncEventsDTO, success *bool) error
- type SyncEventsDTO
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { Owner string `json:"owner"` // Address of the node that created this event Signature string `json:"signature"` // Event should be signed by it's creator SelfParentHash string `json:"self_parent_hash"` // Hash of the self-parent, which is the hash for the event before this event in my timeline. OtherParentHash string `json:"other_parent_hash"` // Hash of the other-parent, which is the hash for the last event of the peer that called me. Timestamp time.Time `json:"timestamp"` // Datetime of creation Transactions []Transaction `json:"transactions"` // List of transactions for this event, size can be 0 too. Round uint32 `json:"round"` // Calculated by divideRounds(), initial event is round 1 IsWitness bool `json:"is_witness"` // Is this event the first event in it's round at it's member? IsFamous bool `json:"is_famous"` // Is this witness a famous witness? IsFameDecided bool `json:"is_fame_decided"` // Has there been a decision for this Event's fame? RoundReceived uint32 `json:"round_received"` // Consensus round ConsensusTimestamp time.Time `json:"consensus_timestamp"` // Timestamp assigned by the consensus Latency time.Duration `json:"latency"` // How long did it take for this event to reach to a consensus }
Event : An event of hashgraph
type Node ¶
type Node struct { sync.RWMutex Address string // ip:port of the peer Hashgraph map[string][]*Event // local copy of hashgraph, map to peer address -> peer events Events map[string]*Event // events as a map of signature -> event Witnesses map[string]map[uint32]*Event // map of peer addres -> (map of round -> witness) FirstRoundOfFameUndecided map[string]uint32 // the round of first witness that's fame is undecided for each peer FirstEventOfNotConsensusIndex map[string]int // the index of first non-consensus event ConsensusEvents []*Event // list of events with roundReceived and consensusTimestamp TransactionBuffer []Transaction // slice of transactions stored until next gossip // contains filtered or unexported fields }
Node : A member of the distributed ledger system. Is identified by it's address.
func (*Node) DecideFame ¶
func (n *Node) DecideFame()
DecideFame : Decides if a witness is famous or not
func (*Node) DivideRounds ¶
DivideRounds : Calculates the round of a new event
func (*Node) FindOrder ¶
func (n *Node) FindOrder()
FindOrder : Arrive at a consensus on the order of events
func (*Node) GenerateTransactions ¶
func (n *Node) GenerateTransactions(count int, max float64, min float64, peerAddress []string) []Transaction
GenerateTransactions : Generates an arbitrary amount of random transactions
func (*Node) GetNumberOfMissingEvents ¶
func (n *Node) GetNumberOfMissingEvents(numEventsAlreadyKnown map[string]int, numEventsToSend *map[string]int) error
GetNumberOfMissingEvents : Node A calls Node B to learn which events B does not know and A knows.
func (*Node) SyncAllEvents ¶
func (n *Node) SyncAllEvents(events SyncEventsDTO, success *bool) error
SyncAllEvents : Node A first calls GetNumberOfMissingEvents on B, and then sends the missing events in this function
type SyncEventsDTO ¶
type SyncEventsDTO struct { SenderAddress string // address of the node who made the call MissingEvents map[string][]*Event // map of addresses to events of those addresses that are missing on the remotely called node }
SyncEventsDTO : Data Transfer Object for SyncAllEvents function
type Transaction ¶
type Transaction struct { SenderAddress string `json:"sender_address"` // ip:port of sender ReceiverAddress string `json:"receiver_address"` // ip:port of receiver Amount float64 `json:"amount"` // amount }
Transaction : A statement of money transfer from a sender to a receiver.