From d51b87e80aa6049e1c5ca010baf2c8edd2ae321d Mon Sep 17 00:00:00 2001
From: orignal <i2porignal@yandex.ru>
Date: Tue, 10 Mar 2015 21:54:25 -0400
Subject: [PATCH] reduced memory usage

---
 I2NPProtocol.cpp  | 8 ++++----
 I2NPProtocol.h    | 2 +-
 Tunnel.cpp        | 2 +-
 TunnelGateway.cpp | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp
index f2ef9ec1..3aa012ce 100644
--- a/I2NPProtocol.cpp
+++ b/I2NPProtocol.cpp
@@ -102,7 +102,7 @@ namespace i2p
 	I2NPMessage * CreateRouterInfoDatabaseLookupMsg (const uint8_t * key, const uint8_t * from, 
 		uint32_t replyTunnelID, bool exploratory, std::set<i2p::data::IdentHash> * excludedPeers)
 	{
-		I2NPMessage * m = NewI2NPMessage ();
+		I2NPMessage * m = NewI2NPShortMessage ();
 		uint8_t * buf = m->GetPayload ();
 		memcpy (buf, key, 32); // key
 		buf += 32;
@@ -148,7 +148,7 @@ namespace i2p
 		const std::set<i2p::data::IdentHash>& excludedFloodfills,
 		const i2p::tunnel::InboundTunnel * replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag)
 	{
-		I2NPMessage * m = NewI2NPMessage ();
+		I2NPMessage * m = NewI2NPShortMessage ();
 		uint8_t * buf = m->GetPayload ();
 		memcpy (buf, dest, 32); // key
 		buf += 32;
@@ -405,7 +405,7 @@ namespace i2p
 
 	I2NPMessage * CreateTunnelDataMsg (const uint8_t * buf)
 	{
-		I2NPMessage * msg = NewI2NPMessage ();
+		I2NPMessage * msg = NewI2NPShortMessage ();
 		memcpy (msg->GetPayload (), buf, i2p::tunnel::TUNNEL_DATA_MSG_SIZE);
 		msg->len += i2p::tunnel::TUNNEL_DATA_MSG_SIZE; 
 		FillI2NPMessageHeader (msg, eI2NPTunnelData);
@@ -414,7 +414,7 @@ namespace i2p
 
 	I2NPMessage * CreateTunnelDataMsg (uint32_t tunnelID, const uint8_t * payload)	
 	{
-		I2NPMessage * msg = NewI2NPMessage ();
+		I2NPMessage * msg = NewI2NPShortMessage ();
 		memcpy (msg->GetPayload () + 4, payload, i2p::tunnel::TUNNEL_DATA_MSG_SIZE - 4);
 		htobe32buf (msg->GetPayload (), tunnelID);
 		msg->len += i2p::tunnel::TUNNEL_DATA_MSG_SIZE; 
diff --git a/I2NPProtocol.h b/I2NPProtocol.h
index 5bb94062..4f426b9f 100644
--- a/I2NPProtocol.h
+++ b/I2NPProtocol.h
@@ -106,7 +106,7 @@ namespace tunnel
 }
 
 	const size_t I2NP_MAX_MESSAGE_SIZE = 32768; 
-	const size_t I2NP_MAX_SHORT_MESSAGE_SIZE = 2400; 
+	const size_t I2NP_MAX_SHORT_MESSAGE_SIZE = 4096; 
 	struct I2NPMessage
 	{	
 		uint8_t * buf;	
diff --git a/Tunnel.cpp b/Tunnel.cpp
index 5a0a96a9..f04c7f05 100644
--- a/Tunnel.cpp
+++ b/Tunnel.cpp
@@ -32,7 +32,7 @@ namespace tunnel
 		CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
 		auto numHops = m_Config->GetNumHops ();
 		int numRecords = numHops <= STANDARD_NUM_RECORDS ? STANDARD_NUM_RECORDS : numHops; 
-		I2NPMessage * msg = NewI2NPMessage ();
+		I2NPMessage * msg = NewI2NPShortMessage ();
 		*msg->GetPayload () = numRecords;
 		msg->len += numRecords*TUNNEL_BUILD_RECORD_SIZE + 1;		
 
diff --git a/TunnelGateway.cpp b/TunnelGateway.cpp
index 561a1068..fbef1208 100644
--- a/TunnelGateway.cpp
+++ b/TunnelGateway.cpp
@@ -138,7 +138,7 @@ namespace tunnel
 
 	void TunnelGatewayBuffer::CreateCurrentTunnelDataMessage ()
 	{
-		m_CurrentTunnelDataMsg = NewI2NPMessage ();
+		m_CurrentTunnelDataMsg = NewI2NPShortMessage ();
 		m_CurrentTunnelDataMsg->Align (12);
 		// we reserve space for padding
 		m_CurrentTunnelDataMsg->offset += TUNNEL_DATA_MSG_SIZE + I2NP_HEADER_SIZE;