void Channel::AddPeakHashes (Datagram& dgram) { for(int i=0; i<file().peak_count(); i++) { bin64_t peak = file().peak(i); dgram.Push8(SWIFT_HASH); dgram.Push32((uint32_t)peak); dgram.PushHash(file().peak_hash(i)); dprintf("%s #%u +phash %s\n",tintstr(),id_,peak.str()); } }
void Channel::AddUncleHashes (Datagram& dgram, bin64_t pos) { bin64_t peak = file().peak_for(pos); while (pos!=peak && ((NOW&3)==3 || !data_out_cap_.within(pos.parent())) && ack_in_.get(pos.parent())==binmap_t::EMPTY ) { bin64_t uncle = pos.sibling(); dgram.Push8(SWIFT_HASH); dgram.Push32((uint32_t)uncle); dgram.PushHash( file().hash(uncle) ); dprintf("%s #%u +hash %s\n",tintstr(),id_,uncle.str()); pos = pos.parent(); } }
void Channel::AddHandshake (Datagram& dgram) { if (!peer_channel_id_) { // initiating dgram.Push8(SWIFT_HASH); dgram.Push32(bin64_t::ALL32); dgram.PushHash(file().root_hash()); dprintf("%s #%u +hash ALL %s\n", tintstr(),id_,file().root_hash().hex().c_str()); } dgram.Push8(SWIFT_HANDSHAKE); int encoded = EncodeID(id_); dgram.Push32(encoded); dprintf("%s #%u +hs %x\n",tintstr(),id_,encoded); have_out_.clear(); AddHave(dgram); }