mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -275,6 +275,10 @@
|
||||
</CustomBuild>
|
||||
<None Include="README" />
|
||||
<None Include="SConstruct" />
|
||||
<None Include="test\buster.js" />
|
||||
<None Include="test\server.js" />
|
||||
<None Include="test\standalone-test.js" />
|
||||
<None Include="test\utils.js" />
|
||||
<None Include="validators.txt" />
|
||||
<None Include="wallet.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -102,6 +102,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()<data2->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
|
||||
{
|
||||
|
||||
@@ -1314,11 +1314,9 @@ Json::Value RPCServer::doPeers(const Json::Value& params)
|
||||
return obj;
|
||||
}
|
||||
|
||||
// profile offers <pass_a> <account_a> <currency_offer_a> <pass_b> <account_b> <currency_offer_b> <count> [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:<count> 8:[submit]
|
||||
// profile offers <pass_a> <account_a> <currency_offer_a> <account_b> <currency_offer_b> <count> [submit]
|
||||
// profile 0:offers 1:pass_a 2:account_a 3:currency_offer_a 4:account_b 5:currency_offer_b 6:<count> 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())) // <currency_offer_a>
|
||||
return RPCError(rpcINVALID_PARAMS);
|
||||
|
||||
if (!naSeedB.setSeedGeneric(params[4u].asString())) // <pass_b>
|
||||
naAccountB.setAccountID(params[4u].asString()); // <account_b>
|
||||
if (!STAmount::currencyFromString(uCurrencyOfferB, params[5u].asString())) // <currency_offer_b>
|
||||
return RPCError(rpcINVALID_PARAMS);
|
||||
|
||||
naAccountB.setAccountID(params[5u].asString()); // <account_b>
|
||||
if (!STAmount::currencyFromString(uCurrencyOfferB, params[6u].asString())) // <currency_offer_b>
|
||||
return RPCError(rpcINVALID_PARAMS);
|
||||
iCount = lexical_cast_s<uint32>(params[6u].asString());
|
||||
|
||||
if (iArgs >= 8)
|
||||
iCount = lexical_cast_s<uint32>(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; n<iCount; n++)
|
||||
{
|
||||
NewcoinAddress naMasterGeneratorA;
|
||||
NewcoinAddress naAccountPublicA;
|
||||
NewcoinAddress naAccountPrivateA;
|
||||
AccountState::pointer asSrcA;
|
||||
STAmount saSrcBalanceA;
|
||||
|
||||
Json::Value jvObjA = authorize(uint256(0), naSeedA, naAccountA, naAccountPublicA, naAccountPrivateA,
|
||||
saSrcBalanceA, theConfig.FEE_DEFAULT, asSrcA, naMasterGeneratorA);
|
||||
|
||||
@@ -1381,42 +1379,17 @@ Json::Value RPCServer::doProfile(const Json::Value ¶ms)
|
||||
0, // uSourceTag,
|
||||
false, // bPassive
|
||||
STAmount(uCurrencyOfferA, naAccountA.getAccountID(), 1), // saTakerPays
|
||||
STAmount(uCurrencyOfferB, naAccountB.getAccountID(), 1), // saTakerGets
|
||||
STAmount(uCurrencyOfferB, naAccountB.getAccountID(), 1+n), // saTakerGets
|
||||
0); // uExpiration
|
||||
|
||||
if (bSubmit)
|
||||
if(bSubmit)
|
||||
tpOfferA = mNetOps->submitTransaction(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);
|
||||
|
||||
@@ -753,7 +753,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.
|
||||
|
||||
Reference in New Issue
Block a user