From 5ada5cc8c2df8f73fe235f81ed43b6ab44beb743 Mon Sep 17 00:00:00 2001 From: jed Date: Sat, 15 Sep 2012 21:17:50 -0700 Subject: [PATCH 1/6] . --- src/Interpreter.cpp | 4 +- src/Operation.h | 96 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/src/Interpreter.cpp b/src/Interpreter.cpp index c97b8780c..dabbb692d 100644 --- a/src/Interpreter.cpp +++ b/src/Interpreter.cpp @@ -21,7 +21,7 @@ Interpreter::Interpreter() mBlockJump=0; mFunctionTable.resize(NUM_OF_OPS); - /* + mFunctionTable[INT_OP]=new IntOp(); mFunctionTable[FLOAT_OP]=new FloatOp(); mFunctionTable[UINT160_OP]=new Uint160Op(); @@ -47,6 +47,7 @@ Interpreter::Interpreter() mFunctionTable[BLOCK_OP]=new SubOp(); mFunctionTable[BLOCK_END_OP]=new SubOp(); mFunctionTable[SEND_XNS_OP]=new SendXNSOp(); + /* mFunctionTable[SEND_OP]=new SendOp(); mFunctionTable[REMOVE_CONTRACT_OP]=new SubOp(); mFunctionTable[FEE_OP]=new SubOp(); @@ -70,6 +71,7 @@ Interpreter::Interpreter() mFunctionTable[GET_ACCEPTOR_ID_OP]=new GetAcceptorIDOp(); mFunctionTable[GET_CONTRACT_ID_OP]=new GetContractIDOp(); */ + } Data::pointer Interpreter::popStack() diff --git a/src/Operation.h b/src/Operation.h index 9fca2498c..09f023f6a 100644 --- a/src/Operation.h +++ b/src/Operation.h @@ -100,6 +100,102 @@ public: } }; +class MulOp : public Operation +{ +public: + bool work(Interpreter* interpreter) + { + Data::pointer data1=interpreter->popStack(); + Data::pointer data2=interpreter->popStack(); + if( (data1->isInt32() || data1->isFloat()) && + (data2->isInt32() || data2->isFloat()) ) + { + if(data1->isFloat() || data2->isFloat()) interpreter->pushStack(Data::pointer(new FloatData(data1->getFloat()*data2->getFloat()))); + else interpreter->pushStack(Data::pointer(new IntData(data1->getInt()*data2->getInt()))); + return(true); + }else + { + return(false); + } + } +}; + +class DivOp : public Operation +{ +public: + bool work(Interpreter* interpreter) + { + Data::pointer data1=interpreter->popStack(); + Data::pointer data2=interpreter->popStack(); + if( (data1->isInt32() || data1->isFloat()) && + (data2->isInt32() || data2->isFloat()) ) + { + if(data1->isFloat() || data2->isFloat()) interpreter->pushStack(Data::pointer(new FloatData(data1->getFloat()/data2->getFloat()))); + else interpreter->pushStack(Data::pointer(new IntData(data1->getInt()/data2->getInt()))); + return(true); + }else + { + return(false); + } + } +}; + +class GtrOp : public Operation +{ +public: + bool work(Interpreter* interpreter) + { + Data::pointer data1=interpreter->popStack(); + Data::pointer data2=interpreter->popStack(); + if( (data1->isInt32() || data1->isFloat()) && + (data2->isInt32() || data2->isFloat()) ) + { + interpreter->pushStack(Data::pointer(new BoolData(data1->getFloat()>data2->getFloat()))); + return(true); + }else + { + return(false); + } + } +}; + +class LessOp : public Operation +{ +public: + bool work(Interpreter* interpreter) + { + Data::pointer data1=interpreter->popStack(); + Data::pointer data2=interpreter->popStack(); + if( (data1->isInt32() || data1->isFloat()) && + (data2->isInt32() || data2->isFloat()) ) + { + interpreter->pushStack(Data::pointer(new FloatData(data1->getFloat()getFloat()))); + return(true); + }else + { + return(false); + } + } +}; + +class ModOp : public Operation +{ +public: + bool work(Interpreter* interpreter) + { + Data::pointer data1=interpreter->popStack(); + Data::pointer data2=interpreter->popStack(); + if( data1->isInt32() && data2->isInt32() ) + { + interpreter->pushStack(Data::pointer(new IntData(data1->getInt()%data2->getInt()))); + return(true); + }else + { + return(false); + } + } +}; + class StartBlockOp : public Operation { From 87a4e295e820736eec38b7e9e0c452d2942e2e36 Mon Sep 17 00:00:00 2001 From: jed Date: Mon, 24 Sep 2012 20:34:54 -0700 Subject: [PATCH 2/6] . --- newcoin.vcxproj | 7 +++++++ newcoin.vcxproj.filters | 24 ++++++++++++++++++++++++ src/TransactionAction.cpp | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 0f21cebef..d13b9e530 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -136,6 +136,7 @@ + @@ -156,7 +157,9 @@ + + @@ -271,6 +274,10 @@ obj\src\newcoin.pb.h + + + + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index f569d1ac4..09047e49d 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -31,6 +31,9 @@ {92775c5f-dc9f-4a97-a9a6-6d4bd4e424b4} + + {b8dcb73e-9f6f-48d3-ad81-9858068aacf7} + @@ -294,6 +297,15 @@ Source Files + + Source Files + + + Source Files + + + Source Files + @@ -557,6 +569,18 @@ + + test + + + test + + + test + + + test + diff --git a/src/TransactionAction.cpp b/src/TransactionAction.cpp index f60ae0af5..ae308351c 100644 --- a/src/TransactionAction.cpp +++ b/src/TransactionAction.cpp @@ -741,7 +741,7 @@ TER TransactionEngine::takeOffers( } if (!sleOfferDir // No offer directory to take. - || uTakeQuality < uTipQuality // No offer's of sufficient quality available. + || uTakeQuality < uTipQuality // No offers of sufficient quality available. || (bPassive && uTakeQuality == uTipQuality)) { // Done. From 4e077a529102dc20b54b1f69bdbbf12dbb51f02c Mon Sep 17 00:00:00 2001 From: jed Date: Mon, 1 Oct 2012 20:10:52 -0700 Subject: [PATCH 3/6] compile on windows --- newcoin.vcxproj | 1 - newcoin.vcxproj.filters | 3 --- src/SerializedObject.h | 1 + 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/newcoin.vcxproj b/newcoin.vcxproj index d13b9e530..9dde2b546 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -103,7 +103,6 @@ - diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index 09047e49d..1aa747c00 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -66,9 +66,6 @@ Source Files - - Source Files - Source Files diff --git a/src/SerializedObject.h b/src/SerializedObject.h index 5255c463e..3b7f3d4f9 100644 --- a/src/SerializedObject.h +++ b/src/SerializedObject.h @@ -19,6 +19,7 @@ public: SField::ref e_field; const SOE_Flags flags; + }; class STObject : public SerializedType From e59aa90858fcf6c55c0168f31418c90f22845c93 Mon Sep 17 00:00:00 2001 From: jed Date: Mon, 8 Oct 2012 14:32:20 -0700 Subject: [PATCH 4/6] windows --- newcoin.vcxproj | 1 + newcoin.vcxproj.filters | 3 +++ 2 files changed, 4 insertions(+) diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 9dde2b546..95d0bd84d 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -106,6 +106,7 @@ + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index 1aa747c00..1ad172a39 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -303,6 +303,9 @@ Source Files + + Source Files + From 04f244ce9d5312ccfe9556c62855cdb30acb516c Mon Sep 17 00:00:00 2001 From: jed Date: Thu, 11 Oct 2012 09:19:05 -0700 Subject: [PATCH 5/6] change profile --- src/RPCServer.cpp | 57 +++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index 0723e7936..798dd0c1a 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -1314,11 +1314,9 @@ Json::Value RPCServer::doPeers(const Json::Value& params) return obj; } -// profile offers [submit] -// profile 0:offers 1:pass_a 2:account_a 3:currency_offer_a 4:pass_b 5:account_b 6:currency_offer_b 7: 8:[submit] +// profile offers [submit] +// profile 0:offers 1:pass_a 2:account_a 3:currency_offer_a 4:account_b 5:currency_offer_b 6: 7:[submit] // issuer is the offering account -// the amount of each offer will be 1. -// --> count: defaults to 100, does 2 offers per iteration. // --> submit: 'submit|true|false': defaults to false // Prior to running allow each to have a credit line of what they will be getting from the other account. Json::Value RPCServer::doProfile(const Json::Value ¶ms) @@ -1333,7 +1331,7 @@ Json::Value RPCServer::doProfile(const Json::Value ¶ms) uint32 iCount = 100; bool bSubmit = false; - if (iArgs < 7 || "offers" != params[0u].asString()) + if (iArgs < 6 || "offers" != params[0u].asString()) { return RPCError(rpcINVALID_PARAMS); } @@ -1346,27 +1344,27 @@ Json::Value RPCServer::doProfile(const Json::Value ¶ms) if (!STAmount::currencyFromString(uCurrencyOfferA, params[3u].asString())) // return RPCError(rpcINVALID_PARAMS); - if (!naSeedB.setSeedGeneric(params[4u].asString())) // + naAccountB.setAccountID(params[4u].asString()); // + if (!STAmount::currencyFromString(uCurrencyOfferB, params[5u].asString())) // return RPCError(rpcINVALID_PARAMS); - naAccountB.setAccountID(params[5u].asString()); // - if (!STAmount::currencyFromString(uCurrencyOfferB, params[6u].asString())) // - return RPCError(rpcINVALID_PARAMS); + iCount = lexical_cast_s(params[6u].asString()); - if (iArgs >= 8) - iCount = lexical_cast_s(params[7u].asString()); - - if (iArgs >= 9 && "false" != params[8u].asString()) + if (iArgs >= 8 && "false" != params[7u].asString()) bSubmit = true; + Log::setMinSeverity(lsFATAL); + boost::posix_time::ptime ptStart(boost::posix_time::microsec_clock::local_time()); - for (int i = iCount; i-- >= 0;) { + for(int n=0; nsubmitTransaction(tpOfferA); - - NewcoinAddress naMasterGeneratorB; - NewcoinAddress naAccountPublicB; - NewcoinAddress naAccountPrivateB; - AccountState::pointer asSrcB; - STAmount saSrcBalanceB; - Json::Value jvObjB = authorize(uint256(0), naSeedB, naAccountB, naAccountPublicB, naAccountPrivateB, - saSrcBalanceB, theConfig.FEE_DEFAULT, asSrcB, naMasterGeneratorB); - - if (!jvObjB.empty()) - return jvObjB; - - Transaction::pointer tpOfferB = Transaction::sharedOfferCreate( - naAccountPublicB, naAccountPrivateB, - naAccountB, // naSourceAccount, - asSrcB->getSeq(), // uSeq - theConfig.FEE_DEFAULT, - 0, // uSourceTag, - false, // bPassive - STAmount(uCurrencyOfferB, naAccountB.getAccountID(), 1), // saTakerPays - STAmount(uCurrencyOfferA, naAccountA.getAccountID(), 1), // saTakerGets - 0); // uExpiration - - if (bSubmit) - tpOfferB = mNetOps->submitTransaction(tpOfferB); } boost::posix_time::ptime ptEnd(boost::posix_time::microsec_clock::local_time()); boost::posix_time::time_duration tdInterval = ptEnd-ptStart; long lMicroseconds = tdInterval.total_microseconds(); - int iTransactions = iCount*2; + int iTransactions = iCount; float fRate = lMicroseconds ? iTransactions/(lMicroseconds/1000000.0) : 0.0; Json::Value obj(Json::objectValue); From 391ef2fb1f55417433eb1a74724e966739031da9 Mon Sep 17 00:00:00 2001 From: jed Date: Fri, 12 Oct 2012 08:59:51 -0700 Subject: [PATCH 6/6] . --- src/SHAMapNodes.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SHAMapNodes.cpp b/src/SHAMapNodes.cpp index ad1e27749..f70897975 100644 --- a/src/SHAMapNodes.cpp +++ b/src/SHAMapNodes.cpp @@ -518,6 +518,7 @@ std::ostream& operator<<(std::ostream& out, const SHAMapMissingNode& mn) out << "Missing/STA(" << mn.getNodeID() << ")"; else out << "Missing/" << mn.getNodeID(); + return(out); }