MCPcopy Create free account
hub / github.com/Parchive/par2cmdline / Load

Method Load

src/verificationhashtable.cpp:68–107  ·  view source on GitHub ↗

Load data from a verification packet

Source from the content-addressed store, hash-verified

66
67// Load data from a verification packet
68void VerificationHashTable::Load(Par2RepairerSourceFile *sourcefile, u64 blocksize)
69{
70 VerificationHashEntry *preventry = 0;
71
72 // Get information from the sourcefile
73 VerificationPacket *verificationpacket = sourcefile->GetVerificationPacket();
74 u32 blockcount = verificationpacket->BlockCount();
75
76 // Iterate through the data blocks for the source file and the verification
77 // entries in the verification packet.
78 std::vector<DataBlock>::iterator sourceblocks = sourcefile->SourceBlocks();
79 const FILEVERIFICATIONENTRY *verificationentry = verificationpacket->VerificationEntry(0);
80 u32 blocknumber = 0;
81
82 while (blocknumber<blockcount)
83 {
84 DataBlock &datablock = *sourceblocks;
85
86 // Create a new VerificationHashEntry with the details for the current
87 // data block and verification entry.
88 VerificationHashEntry *entry = new VerificationHashEntry(sourcefile,
89 &datablock,
90 blocknumber == 0,
91 verificationentry);
92
93 // Insert the entry in the hash table
94 entry->Insert(&hashtable[entry->Checksum() & hashmask]);
95
96 // Make the previous entry point forwards to this one
97 if (preventry)
98 {
99 preventry->Next(entry);
100 }
101 preventry = entry;
102
103 ++blocknumber;
104 ++sourceblocks;
105 ++verificationentry;
106 }
107}

Callers

nothing calls this directly

Calls 7

GetVerificationPacketMethod · 0.80
SourceBlocksMethod · 0.80
VerificationEntryMethod · 0.80
NextMethod · 0.80
BlockCountMethod · 0.45
InsertMethod · 0.45
ChecksumMethod · 0.45

Tested by

no test coverage detected