From 868a7be7172d8a86a00d8e47f7533417599727d1 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 10 Nov 2009 12:09:54 +0000 Subject: [PATCH] beautification git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@524 e16421f0-f15b-0410-abcd-98678b794739 --- hashtree.cpp | 4 ++-- hashtree.h | 4 ++-- sendrecv.cpp | 2 +- tests/hashtest.cpp | 2 +- tests/transfertest.cpp | 10 +++++----- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hashtree.cpp b/hashtree.cpp index 55586ac..ca752cb 100644 --- a/hashtree.cpp +++ b/hashtree.cpp @@ -148,13 +148,13 @@ void HashTree::RecoverProgress () { char zeros[1<<10]; memset(zeros, 0, 1<<10); Sha1Hash kilo_zero(zeros,1<<10); - for(int p=0; pfile().size_kilo()) { + if (file().size() && ackd_pos.base_offset()>=file().packet_size()) { eprintf("invalid ack: (%i,%lli)\n",ackd_pos.layer(),ackd_pos.offset()); return; } diff --git a/tests/hashtest.cpp b/tests/hashtest.cpp index d0812e6..3b24fc9 100644 --- a/tests/hashtest.cpp +++ b/tests/hashtest.cpp @@ -30,7 +30,7 @@ TEST(Sha1HashTest,OfferDataTest) { 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()); diff --git a/tests/transfertest.cpp b/tests/transfertest.cpp index 89ce3b4..521445e 100644 --- a/tests/transfertest.cpp +++ b/tests/transfertest.cpp @@ -44,7 +44,7 @@ TEST(TransferTest,TransferFile) { 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)); @@ -59,7 +59,7 @@ TEST(TransferTest,TransferFile) { for(int i=0; ipeak_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 @@ -75,7 +75,7 @@ TEST(TransferTest,TransferFile) { 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); @@ -84,7 +84,7 @@ TEST(TransferTest,TransferFile) { 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()size_kilo()) + if (sibling.base_offset()packet_size()) leech->OfferHash(sibling, seed->hash(sibling)); uint8_t memo = *buf; *buf = 'z'; @@ -93,7 +93,7 @@ TEST(TransferTest,TransferFile) { 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()); -- 2.20.1