added GET_BLOCK transport message
@@ -52,7 +52,8 @@ static int block_arrive_callback(void *packet, void *connection) {
if (s->total_nmain > g->total_nmain) g->total_nmain = s->total_nmain;
if (s->total_nhosts > g->total_nhosts) g->total_nhosts = s->total_nhosts;
cheatcoin_netdb_receive((uint8_t *)&b->field[2] + sizeof(struct cheatcoin_stats),
- (cheatcoin_type(b, 1) == CHEATCOIN_MESSAGE_SUMS_REPLY ? 6 : 14) * sizeof(struct cheatcoin_field)
+ (cheatcoin_type(b, 1) == CHEATCOIN_MESSAGE_SUMS_REPLY ? 6 :
+ (cheatcoin_type(b, 1) == CHEATCOIN_MESSAGE_BLOCK_REQUEST ? 13 : 14)) * sizeof(struct cheatcoin_field)
- sizeof(struct cheatcoin_stats));
switch (cheatcoin_type(b, 1)) {
case CHEATCOIN_MESSAGE_BLOCKS_REQUEST:
@@ -95,6 +96,15 @@ static int block_arrive_callback(void *packet, void *connection) {
reply_result = b->field[0].time;
}
break;
+ case CHEATCOIN_MESSAGE_BLOCK_REQUEST:
+ {
+ struct cheatcoin_block buf, *blk;
+ cheatcoin_time_t t;
+ int64_t pos = cheatcoin_get_block_pos(b->field[CHEATCOIN_BLOCK_FIELDS - 1].hash, &t);
+ if (pos >= 0 && (blk = cheatcoin_storage_load(t, pos, &buf)))
+ dnet_send_cheatcoin_packet(blk, connection);
+ }
+ break;
default:
return -1;
}
