Beispiel #1
0
void Manifest::merge(const Manifest& other)
{
    if (size() != other.size()) error("Invalid manifest sizes for merging.");

    FileStats fileStats;

    for (std::size_t i(0); i < size(); ++i)
    {
        FileInfo& ours(m_fileInfo[i]);
        const FileInfo& theirs(other.m_fileInfo[i]);

        if (ours.path() != theirs.path()) error("Invalid manifest paths");

        if (
                ours.status() == FileInfo::Status::Outstanding &&
                theirs.status() != FileInfo::Status::Outstanding)
        {
            ours.status(theirs.status());

            switch (theirs.status())
            {
                case FileInfo::Status::Inserted: fileStats.addInsert(); break;
                case FileInfo::Status::Omitted: fileStats.addOmit(); break;
                case FileInfo::Status::Error: fileStats.addError(); break;
                default: throw std::runtime_error("Invalid file status");
            }
        }

        ours.pointStats().add(theirs.pointStats());
    }

    m_pointStats.add(other.pointStats());
    m_fileStats.add(fileStats);
}
Beispiel #2
0
int main(int argc, char *argv[])
{
	std::istream &in = input_file(argv[1]);

	unsigned int blocknum, overhead;
	txmap block;
	std::unordered_map<bitcoin_txid, tx *> knowns;

	while (read_blockline(in, &blocknum, &overhead, &block, &knowns, NULL)) {
		u64 seed;
		size_t ibltslices;
		raw_iblt *theirs = read_iblt(in, &ibltslices, &seed);

		txmap mempool;
		std::string peername;
		while (read_mempool(in, &peername, &mempool, &knowns, NULL)) {
			if (!theirs) {
				std::cout << blocknum << "," << overhead << ",0,"
						  << peername << ","
						  << true
						  << std::endl;
			} else {
				// Create our equivalent iblt.
				raw_iblt ours(theirs->size(), seed, mempool);

				std::cout << blocknum << "," << overhead << "," << ibltslices
						  << "," << peername << ","
						  << recover_block(*theirs, ours, seed, mempool, block)
						  << std::endl;
			}
		}
	}
}