char zeros[1<<10];
memset(zeros, 0, 1<<10);
Sha1Hash kilo_zero(zeros,1<<10);
- for(int p=0; p<size_kilo(); p++) {
+ for(int p=0; p<packet_size(); p++) {
char buf[1<<10];
bin64_t pos(0,p);
if (hashes_[pos]==Sha1Hash::ZERO)
continue;
size_t rd = read(fd_,buf,1<<10);
- assert(rd==(1<<10) || p==size_kilo()-1);
+ assert(rd==(1<<10) || p==packet_size()-1);
if (rd==(1<<10) && !memcmp(buf, zeros, rd) && hashes_[pos]!=kilo_zero)
continue;
if ( data_recheck_ && !OfferHash(pos, Sha1Hash(buf,rd)) )
const Sha1Hash& hash (bin64_t pos) const {return hashes_[pos];}
const Sha1Hash& root_hash () const { return root_hash_; }
uint64_t size () const { return size_; }
- uint64_t size_kilo () const { return sizek_; }
+ uint64_t packet_size () const { return sizek_; }
uint64_t complete () const { return complete_; }
- uint64_t complete_kilo () const { return completek_; }
+ uint64_t packets_complete () const { return completek_; }
uint64_t seq_complete () ;
bool is_complete ()
{ return size_ && complete_==size_; }
EXPECT_STREQ(rooth123,roothash123.hex().c_str());
HashTree tree("123",roothash123);
tree.OfferHash(bin64_t(0,0),Sha1Hash(true,hash123));
- ASSERT_EQ(1,tree.size_kilo());
+ ASSERT_EQ(1,tree.packet_size());
ASSERT_TRUE(tree.OfferData(bin64_t(0,0), "123\n", 4));
unlink("123");
ASSERT_EQ(4,tree.size());
EXPECT_TRUE(E==seed->peak_hash(1));
EXPECT_TRUE(ROOT==seed->root_hash());
EXPECT_EQ(4100,seed->size());
- EXPECT_EQ(5,seed->size_kilo());
+ EXPECT_EQ(5,seed->packet_size());
EXPECT_EQ(4100,seed->complete());
EXPECT_EQ(4100,seed->seq_complete());
EXPECT_EQ(bin64_t(2,0),seed->peak(0));
for(int i=0; i<seed->peak_count(); i++)
leech->OfferHash(seed->peak(i),seed->peak_hash(i));
ASSERT_EQ(5<<10,leech->size());
- ASSERT_EQ(5,leech->size_kilo());
+ ASSERT_EQ(5,leech->packet_size());
ASSERT_EQ(0,leech->complete());
EXPECT_EQ(bin64_t(2,0),leech->peak(0));
// transfer data and hashes
leech_transfer = new FileTransfer("copy",seed->root_hash());
leech = & leech_transfer->file();
leech_transfer->picker().Randomize(0);
- EXPECT_EQ(2,leech->complete_kilo());
+ EXPECT_EQ(2,leech->packets_complete());
EXPECT_EQ(bin64_t(2,0),leech->peak(0));
}
bin64_t next = leech_transfer->picker().Pick(seed->ack_out(),0);
uint8_t buf[1024]; //size_t len = seed->storer->ReadData(next,&buf);
size_t len = pread(seed->file_descriptor(),buf,1024,next.base_offset()<<10);
bin64_t sibling = next.sibling();
- if (sibling.base_offset()<seed->size_kilo())
+ if (sibling.base_offset()<seed->packet_size())
leech->OfferHash(sibling, seed->hash(sibling));
uint8_t memo = *buf;
*buf = 'z';
EXPECT_TRUE(leech->OfferData(next, (char*)buf, len));
}
EXPECT_EQ(4100,leech->size());
- EXPECT_EQ(5,leech->size_kilo());
+ EXPECT_EQ(5,leech->packet_size());
EXPECT_EQ(4100,leech->complete());
EXPECT_EQ(4100,leech->seq_complete());