aboutsummaryrefslogtreecommitdiff
path: root/src/serialize.h
AgeCommit message (Collapse)Author
2014-07-16Break up CAddrMan's IMPLEMENT_SERIALIZEPieter Wuille
2014-06-23Avoid undefined behavior using CFlatData in CScript serializationWladimir J. van der Laan
`&vch[vch.size()]` and even `&vch[0]` on vectors can cause assertion errors with VC in debug mode. This is the problem mentioned in #4239. The deeper problem with this is that we rely on undefined behavior. - Add `begin_ptr` and `end_ptr` functions that get the beginning and end pointer of vector in a reliable way that copes with empty vectors and doesn't reference outside the vector (see https://stackoverflow.com/questions/1339470/how-to-get-the-address-of-the-stdvector-buffer-start-most-elegantly/1339767#1339767). - Add a convenience constructor to CFlatData that wraps a vector. I added `begin_ptr` and `end_ptr` as separate functions as I imagine they will be useful in more places.
2014-03-28remove an assignment which is never used.Yoichi Hirai
2013-11-10Cleanup code using forward declarations.Brandon Dahler
Use misc methods of avoiding unnecesary header includes. Replace int typedefs with int##_t from stdint.h. Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h. Normalize QT_VERSION ifs where possible. Resolve some indirect dependencies as direct ones. Remove extern declarations from .cpp files.
2013-10-30Merge pull request #3173 from gavinandresen/fuzzmessagesGavin Andresen
-fuzzmessagestest=N : randomly corrupt 1-of-N sent messages
2013-10-29Bug fix: CDataStream::GetAndClear() when nReadPos > 0Gavin Andresen
Changed CDataStream::GetAndClear() to use the most obvious get get and clear instead of a tricky swap(). Added a unit test for CDataStream insert/erase/GetAndClear. Note: GetAndClear() is not performance critical, it is used only by the send-a-message-to-the-network code. Bug was not noticed before now because the send-a-message code never erased from the stream.
2013-10-26Remove redundant insert method in serialize.Pieter Wuille
This seems to cause problems on recent clang, and looks totally redundant and unused. The const_iterator version is identical to the vector::const_iterator one (which is a typedef thereof). Marking it private (instead of removing) compiles fine, so this version is effectively unused even.
2013-10-20Merge pull request #3119Pieter Wuille
db0e8cc Bump Year Number to 2013 (super3)
2013-10-20Bump Year Number to 2013super3
2013-08-09Reject non-canonically-encoded sizesGavin Andresen
The length of vectors, maps, sets, etc are serialized using Write/ReadCompactSize -- which, unfortunately, do not use a unique encoding. So deserializing and then re-serializing a transaction (for example) can give you different bits than you started with. That doesn't cause any problems that we are aware of, but it is exactly the type of subtle mismatch that can lead to exploits. With this pull, reading a non-canonical CompactSize throws an exception, which means nodes will ignore 'tx' or 'block' or other messages that are not properly encoded. Please check my logic... but this change is safe with respect to causing a network split. Old clients that receive non-canonically-encoded transactions or blocks deserialize them into CTransaction/CBlock structures in memory, and then re-serialize them before relaying them to peers. And please check my logic with respect to causing a blockchain split: there are no CompactSize fields in the block header, so the block hash is always canonical. The merkle root in the block header is computed on a vector<CTransaction>, so any non-canonical encoding of the transactions in 'tx' or 'block' messages is erased as they are read into memory by old clients, and does not affect the block hash. And, as noted above, old clients re-serialize (with canonical encoding) 'tx' and 'block' messages before relaying to peers.
2013-03-29Use per-message send buffer, rather than per connectionPieter Wuille
2012-11-16Split off CBlockHeader from CBlockPieter Wuille
Cleaner and removes the need for the application-specific flags in serialize.h.
2012-11-09Add CBufferedFilePieter Wuille
2012-10-20Compact serialization for variable-length integersPieter Wuille
Variable-length integers: bytes are a MSB base-128 encoding of the number. The high bit in each byte signifies whether another digit follows. To make the encoding is one-to-one, one is subtracted from all but the last digit. Thus, the byte sequence a[] with length len, where all but the last byte has bit 128 set, encodes the number: (a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1)) Properties: * Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes) * Every integer has exactly one encoding * Encoding does not depend on size of original integer type
2012-09-09Remove VC6 comment and pointless #ifdef'd benchmark codeWladimir J. van der Laan
We're in a wholly different world now, C++-compiler-wise. Current std::stringstream implementations don't have the stated problem anymore, and are just as fast as CDataStream. The #ifdef'd block does not even compile anymore; CDataStream constructor changed, and missing some std::. Also timing in whole seconds is also way too granular to say anything sensible in such microbenchmarks. Just remove it, it can always be found again in git history.
2012-07-02Fix signed/unsigned warnings in {script,serialize}.h (fixes #1541)Matt Corallo
2012-05-18Update License in File HeadersFordy
I originally created a pull to replace the "COPYING" in crypter.cpp and crypter.h, but it turned out that COPYING was actually the correct file.
2012-05-01remove unused typedef in serialize.hPhilip Kaufmann
2012-04-17Further reduce header dependenciesPieter Wuille
This commit removes the dependency of serialize.h on PROTOCOL_VERSION, and makes this parameter required instead of implicit. This is much saner, as it makes the places where changing a version number can have an influence obvious.
2012-04-17Merge pull request #1106 from jgarzik/sign-compareGavin Andresen
Fix many sign-comparison warnings found in bitcoin codebase
2012-04-17Merge pull request #1115 from laanwj/2012_04_cleanupmiscGavin Andresen
Delete unused, unreachable and commented code, add missing initializer
2012-04-17Remove unused and unreachable codeWladimir J. van der Laan
2012-04-15serialize.h: CAutoFile's read and write may take size_t nSizeJeff Garzik
2012-04-12version.h: separate client, net sections. Move more constants to this file.Jeff Garzik
* move PROTOCOL_VERSION to version.h * move CLIENT_VERSION* to version.h, make available past cpp stage * clearly separate client, network version portions of version.h
2012-04-04remove dependency on serialize.h and util.h for SecureStringWladimir J. van der Laan
2012-04-03VC2010 compile fixesWladimir J. van der Laan
2012-03-26Begin doxygen-compatible commentsPieter Wuille
2012-02-18Fix compilation warning.Matt Corallo
2012-02-07Update all copyrights to 2012Gavin Andresen
2012-01-12Compile with extra warnings turned on. And more makefile/code tidying up.Gavin Andresen
This turns on most gcc warnings, and removes some unused variables and other code that triggers warnings. Exceptions are: -Wno-sign-compare : triggered by lots of comparisons of signed integer to foo.size(), which is unsigned. -Wno-char-subscripts : triggered by the convert-to-hex functions (I may fix this in a future commit).
2012-01-04Fix horrific performance found by gmaxwell.Matt Corallo
2011-12-21Revert "Use standard C99 (and Qt) types for 64-bit integers"Wladimir J. van der Laan
This reverts commit 21d9f36781604e4ca9fc35dc65265593423b73e9.
2011-12-20Use standard C99 (and Qt) types for 64-bit integersLuke Dashjr
2011-12-20Include limits, not climints (using std::numeric_limits now)Gavin Andresen
2011-12-19Use std::numeric_limits<> for typesafe INT_MAX/etcGavin Andresen
2011-12-19Cleanup: removed dead code, and use C99 typedefs for int64 (supported by all ↵Gavin Andresen
modern c++ compilers)
2011-12-19Implement BIP 14 : separate protocol version from client versionGavin Andresen
2011-12-16Bump version 0.5.99 (prep for pulling for version 0.6)Gavin Andresen
2011-11-21Bump version to 0.5.1Gavin Andresen
2011-11-15Obsolete keypool and make sure database removes log files on shutdown.Gavin Andresen
2011-10-08Bump version to 0.5.0.0Gavin Andresen
2011-10-07Fix build on windows and macGavin Andresen
Replaced all occurrences of #if* __WXMSW__ with WIN32, and all occurrences of __WXMAC_OSX__ with MAC_OSX, and made sure those are defined appropriately in the makefile and bitcoin-qt.pro.
2011-09-26Bump version to 0.4.1Gavin Andresen
2011-09-03Merge branch 'master' of https://github.com/bitcoin/bitcoinWladimir J. van der Laan
2011-09-02Bumped version numbers to 0.4.0rc1v0.4.00rc1Gavin Andresen
2011-09-02Merge branch 'master' of https://github.com/bitcoin/bitcoinWladimir J. van der Laan
Conflicts: src/main.cpp
2011-08-19Move func 'REF' from util.h to serialize.hGiel van Schijndel
util.h doesn't use REF, serialize.h does, creating a dependency of serialize.h on util.h, but util.h already depends on serialize.h. To resolve this circular dependency the function 'REF' has now been moved closer to one of its two points of use. Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-08-16Merge branch 'master' of https://github.com/bitcoin/bitcoinWladimir J. van der Laan
2011-08-11Merge pull request #458 from TheBlueMatt/copyrightGavin Andresen
Unify copyright notices.
2011-08-11Merge branch 'master' of https://github.com/bitcoin/bitcoinWladimir J. van der Laan