Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Broadcaster component #117

Merged
merged 26 commits into from
Aug 8, 2018

Conversation

thibault-martinez
Copy link
Member

This PR adds a working implementation for TCP and UDP broadcasting to a node tethered neighbours.

Test Plan:

The main function currently act as a simple node repeatedly broadcasting the same hash to a TCP neighbour and a UDP neighbour.

It can be tested by connecting two nc clients to it

nc 127.0.0.1 14260 -p 14262 for TCP

echo | nc -u 127.0.0.1 14261 -p 14263 for UDP

@thibault-martinez thibault-martinez added P-medium Priority - Medium A-ciri Area - cIRI labels Aug 7, 2018
flex_trit_t raw_trits[] = {-1, 0, 1, 1, 0, 1, 1, 0, -1,
-1, 1, 0, 1, 1, 0, -1, 1};
while (1) {
trit_array_p trits = trit_array_new(17);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a memleak, could you fix? (even though this is just for debugging

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trit_array_new is only available if dynamic allocation is available though 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, fine for now then.

if (self == NULL) { \
return CONCURRENT_LIST_NULL_SELF; \
} \
node = (concurrent_list_node_of_##TYPE##_t *)calloc( \
1, sizeof(concurrent_list_node_of_##TYPE##_t)); \
node = (concurrent_list_node_of_##TYPE *)calloc( \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you open an issue to implement a statically-sized list that can be used as a drop-in for this?
Not needed right now, but for some targets in the future it'll probably be

if (endpoint == NULL || endpoint->opaque_inetaddr == NULL) {
return false;
}
size_t trytes_num = num_trytes_for_trits(hash->num_trits);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some macros for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find it, do we ?

return false;
}
size_t trytes_num = num_trytes_for_trits(hash->num_trits);
trit_t trytes[trytes_num];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a macro for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misread, you're right.

However the type is wrong should be tryte_t trytes

return false;
}
size_t trytes_num = num_trytes_for_trits(hash->num_trits);
trit_t trytes[trytes_num];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misread, you're right.

However the type is wrong should be tryte_t trytes

return false;
}
size_t trytes_num = num_trytes_for_trits(hash->num_trits);
trit_t trytes[trytes_num];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong type

flex_trit_t raw_trits[] = {-1, 0, 1, 1, 0, 1, 1, 0, -1,
-1, 1, 0, 1, 1, 0, -1, 1};
while (1) {
trit_array_p trits = trit_array_new(17);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trit_array_new is only available if dynamic allocation is available though 🤔

flex_trit_t raw_trits[] = {-1, 0, 1, 1, 0, 1, 1, 0, -1,
-1, 1, 0, 1, 1, 0, -1, 1};
while (1) {
trit_array_p trits = trit_array_new(17);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, fine for now then.

@thibault-martinez thibault-martinez merged commit 8dc0572 into iotaledger:develop Aug 8, 2018
@thibault-martinez thibault-martinez deleted the broadcaster branch August 8, 2018 06:56
howjmay pushed a commit to howjmay/entangled that referenced this pull request Aug 8, 2018
* Remove _t suffix from queue/list node typename

* Add neighbours list to node

* Simple broadcast loop

* Check node pointers against NULL

* Add C linkage guards to neighbour functions

* Create tmp neighbor on TCP connection

* Check if new TCP connection is from a tethered neighbor

* Add find function to lists

* TCP broadcasting

* Nullify opaque_inetaddr if tcp connection is lost

* Clean logs

* Clean accept/deny neigbours

* change tcp connection destructor null check

* broadcaster: add UDP sender

* broadcaster: release the hash after broadcasting it

* broadcaster: block UDP packets from non-tethered neighbours

* broadcaster: UDP broadcasting

* broadcaster: broadcast trit_array_p hashes

* broadcaster: uniform log outputs

* broadcaster: right size for flex_trits trytes conversion

* broadcaster: clean

* broadcaster: receive whole TCP packet

* broadcaster: compact destination

* broadcaster: async send

* broadcaster: fix trytes type
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-ciri Area - cIRI P-medium Priority - Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants