-
Notifications
You must be signed in to change notification settings - Fork 66
Broadcaster component #117
Broadcaster component #117
Conversation
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is freed at the end of the chain, in the broadcaster (https://github.com/iotaledger/entangled/pull/117/files#diff-855c1ef07801182e60e316606f5cadceR27)
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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( \ |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
* 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
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 TCPecho | nc -u 127.0.0.1 14261 -p 14263
for UDP