From e071a3f6c06f41068ad17134189a4ac3073ef76b Mon Sep 17 00:00:00 2001 From: sirius-m Date: Sun, 30 Aug 2009 03:46:39 +0000 Subject: First commit git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@1 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- market.h | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 market.h (limited to 'market.h') diff --git a/market.h b/market.h new file mode 100644 index 0000000000..2714787307 --- /dev/null +++ b/market.h @@ -0,0 +1,182 @@ +// Copyright (c) 2009 Satoshi Nakamoto +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +class CUser; +class CReview; +class CProduct; + +static const unsigned int nFlowthroughRate = 2; + + + + +bool AdvertInsert(const CProduct& product); +void AdvertErase(const CProduct& product); +bool AddAtomsAndPropagate(uint256 hashUserStart, const vector& vAtoms, bool fOrigin); + + + + + + + + +class CUser +{ +public: + vector vAtomsIn; + vector vAtomsNew; + vector vAtomsOut; + vector vLinksOut; + + CUser() + { + } + + IMPLEMENT_SERIALIZE + ( + if (!(nType & SER_GETHASH)) + READWRITE(nVersion); + READWRITE(vAtomsIn); + READWRITE(vAtomsNew); + READWRITE(vAtomsOut); + READWRITE(vLinksOut); + ) + + void SetNull() + { + vAtomsIn.clear(); + vAtomsNew.clear(); + vAtomsOut.clear(); + vLinksOut.clear(); + } + + uint256 GetHash() const { return SerializeHash(*this); } + + + int GetAtomCount() const + { + return (vAtomsIn.size() + vAtomsNew.size()); + } + + void AddAtom(unsigned short nAtom, bool fOrigin); +}; + + + + + + + +class CReview +{ +public: + int nVersion; + uint256 hashTo; + map mapValue; + vector vchPubKeyFrom; + vector vchSig; + + // memory only + unsigned int nTime; + int nAtoms; + + + CReview() + { + nVersion = 1; + hashTo = 0; + nTime = 0; + nAtoms = 0; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->nVersion); + nVersion = this->nVersion; + if (!(nType & SER_DISK)) + READWRITE(hashTo); + READWRITE(mapValue); + READWRITE(vchPubKeyFrom); + if (!(nType & SER_GETHASH)) + READWRITE(vchSig); + ) + + uint256 GetHash() const { return SerializeHash(*this); } + uint256 GetSigHash() const { return SerializeHash(*this, SER_GETHASH|SER_SKIPSIG); } + uint256 GetUserHash() const { return Hash(vchPubKeyFrom.begin(), vchPubKeyFrom.end()); } + + + bool AcceptReview(); +}; + + + + + + + +class CProduct +{ +public: + int nVersion; + CAddress addr; + map mapValue; + map mapDetails; + vector > vOrderForm; + unsigned int nSequence; + vector vchPubKeyFrom; + vector vchSig; + + // disk only + int nAtoms; + + // memory only + set setSources; + + CProduct() + { + nVersion = 1; + nAtoms = 0; + nSequence = 0; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(this->nVersion); + nVersion = this->nVersion; + READWRITE(addr); + READWRITE(mapValue); + if (!(nType & SER_GETHASH)) + { + READWRITE(mapDetails); + READWRITE(vOrderForm); + READWRITE(nSequence); + } + READWRITE(vchPubKeyFrom); + if (!(nType & SER_GETHASH)) + READWRITE(vchSig); + if (nType & SER_DISK) + READWRITE(nAtoms); + ) + + uint256 GetHash() const { return SerializeHash(*this); } + uint256 GetSigHash() const { return SerializeHash(*this, SER_GETHASH|SER_SKIPSIG); } + uint256 GetUserHash() const { return Hash(vchPubKeyFrom.begin(), vchPubKeyFrom.end()); } + + + bool CheckSignature(); + bool CheckProduct(); +}; + + + + + + + + +extern map mapProducts; +extern CCriticalSection cs_mapProducts; +extern map mapMyProducts; -- cgit v1.2.3