Complete initial implementation of transaction relaying.

This commit is contained in:
JoelKatz
2012-01-19 15:56:06 -08:00
parent 0b69be862f
commit 06d69888fd
5 changed files with 63 additions and 10 deletions

View File

@@ -24,7 +24,7 @@ uint32 NetworkOPs::getCurrentLedgerID()
return theApp->getMasterLedger().getCurrentLedger()->getLedgerSeq();
}
Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans)
Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans, Peer* source)
{
Transaction::pointer dbtx=Transaction::load(trans->getID());
if(dbtx) return dbtx;
@@ -57,8 +57,19 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans)
if(r==Ledger::TR_SUCCESS)
{
trans->setStatus(INCLUDED);
// WRITEME: send to others
theApp->getWallet().applyTransaction(trans);
newcoin::TMTransaction *tx=new newcoin::TMTransaction();
Serializer::pointer s(trans->getSigned());
tx->set_rawtransaction(&s->getData().front(), s->getLength());
tx->set_status(newcoin::tsCURRENT);
tx->set_receivetimestamp(getNetworkTime());
tx->set_ledgerindexpossible(trans->getLedger());
PackedMessage::pointer packet(new PackedMessage(PackedMessage::MessagePointer(tx), newcoin::mtTRANSACTION));
theApp->getConnectionPool().relayMessage(source, packet);
return trans;
}