Bitcoin v0.2.0 · 2009-12-16
market.h
1// Copyright (c) 2009 Satoshi Nakamoto2// Distributed under the MIT/X11 software license, see the accompanying3// file license.txt or http://www.opensource.org/licenses/mit-license.php.45class CUser;6class CReview;7class CProduct;89static const unsigned int nFlowthroughRate = 2;1011121314bool AdvertInsert(const CProduct& product);15void AdvertErase(const CProduct& product);16bool AddAtomsAndPropagate(uint256 hashUserStart, const vector<unsigned short>& vAtoms, bool fOrigin);171819202122232425class CUser26{27public:28 vector<unsigned short> vAtomsIn;29 vector<unsigned short> vAtomsNew;30 vector<unsigned short> vAtomsOut;31 vector<uint256> vLinksOut;3233 CUser()34 {35 }3637 IMPLEMENT_SERIALIZE38 (39 if (!(nType & SER_GETHASH))40 READWRITE(nVersion);41 READWRITE(vAtomsIn);42 READWRITE(vAtomsNew);43 READWRITE(vAtomsOut);44 READWRITE(vLinksOut);45 )4647 void SetNull()48 {49 vAtomsIn.clear();50 vAtomsNew.clear();51 vAtomsOut.clear();52 vLinksOut.clear();53 }5455 uint256 GetHash() const { return SerializeHash(*this); }565758 int GetAtomCount() const59 {60 return (vAtomsIn.size() + vAtomsNew.size());61 }6263 void AddAtom(unsigned short nAtom, bool fOrigin);64};6566676869707172class CReview73{74public:75 int nVersion;76 uint256 hashTo;77 map<string, string> mapValue;78 vector<unsigned char> vchPubKeyFrom;79 vector<unsigned char> vchSig;8081 // memory only82 unsigned int nTime;83 int nAtoms;848586 CReview()87 {88 nVersion = 1;89 hashTo = 0;90 nTime = 0;91 nAtoms = 0;92 }9394 IMPLEMENT_SERIALIZE95 (96 READWRITE(this->nVersion);97 nVersion = this->nVersion;98 if (!(nType & SER_DISK))99 READWRITE(hashTo);100 READWRITE(mapValue);101 READWRITE(vchPubKeyFrom);102 if (!(nType & SER_GETHASH))103 READWRITE(vchSig);104 )105106 uint256 GetHash() const { return SerializeHash(*this); }107 uint256 GetSigHash() const { return SerializeHash(*this, SER_GETHASH|SER_SKIPSIG); }108 uint256 GetUserHash() const { return Hash(vchPubKeyFrom.begin(), vchPubKeyFrom.end()); }109110111 bool AcceptReview();112};113114115116117118119120class CProduct121{122public:123 int nVersion;124 CAddress addr;125 map<string, string> mapValue;126 map<string, string> mapDetails;127 vector<pair<string, string> > vOrderForm;128 unsigned int nSequence;129 vector<unsigned char> vchPubKeyFrom;130 vector<unsigned char> vchSig;131132 // disk only133 int nAtoms;134135 // memory only136 set<unsigned int> setSources;137138 CProduct()139 {140 nVersion = 1;141 nAtoms = 0;142 nSequence = 0;143 }144145 IMPLEMENT_SERIALIZE146 (147 READWRITE(this->nVersion);148 nVersion = this->nVersion;149 READWRITE(addr);150 READWRITE(mapValue);151 if (!(nType & SER_GETHASH))152 {153 READWRITE(mapDetails);154 READWRITE(vOrderForm);155 READWRITE(nSequence);156 }157 READWRITE(vchPubKeyFrom);158 if (!(nType & SER_GETHASH))159 READWRITE(vchSig);160 if (nType & SER_DISK)161 READWRITE(nAtoms);162 )163164 uint256 GetHash() const { return SerializeHash(*this); }165 uint256 GetSigHash() const { return SerializeHash(*this, SER_GETHASH|SER_SKIPSIG); }166 uint256 GetUserHash() const { return Hash(vchPubKeyFrom.begin(), vchPubKeyFrom.end()); }167168169 bool CheckSignature();170 bool CheckProduct();171};172173174175176177178179180extern map<uint256, CProduct> mapProducts;181extern CCriticalSection cs_mapProducts;182extern map<uint256, CProduct> mapMyProducts;
Click a line number to link to it; use #L10-L20 for a range. "=" next to a version means the file is identical there.
