I2NP: Don't extend DataStructureImpl, to save space

Fixup test as required
This commit is contained in:
zzz
2020-11-16 14:51:35 +00:00
parent 8644eb431e
commit 595f8762ab
5 changed files with 50 additions and 7 deletions

View File

@ -1,3 +1,29 @@
2020-11-16 zzz
* GeoIP 2020-11-01
* I2NP: Don't extend DataStructureImpl, to save space
* Wrapper: Update to 3.5.44
2020-11-11 zzz
* Data: Store timestamps as longs, not Dates, to save space
* I2CP: Don't have I2CP Messages extend DataStructureImpl, to save space
2020-11-10 zzz
* Data: SDS no longer extends DataStructureImpl to save space
* i2psnark: Larger read buffer for large files
* Ratchet: Destroy HandshakeState after fatal NS/NSR errors
2020-11-07 zzz
* Tunnels: Simplify TunnelId and HopConfig to save space
2020-11-05 zzz
* NetDB: Ensure RI republish time is less than validation time
2020-11-04 zzz
* Util: ELiminate unneeded data copying in ByteArrayOutputStream
2020-11-03 zzz
* i2ptunnel: Add checks for offline expiration of alternate destination
2020-11-02 zzz 2020-11-02 zzz
* I2CP: Remove tunnels immediately on client disconnect * I2CP: Remove tunnels immediately on client disconnect
* i2psnark: Limit max size of embedded video * i2psnark: Limit max size of embedded video

View File

@ -15,9 +15,11 @@ import net.i2p.data.DataStructure;
/** /**
* Base interface for all I2NP messages * Base interface for all I2NP messages
* *
* Note: No longer extends DataStructure as of 0.9.48
*
* @author jrandom * @author jrandom
*/ */
public interface I2NPMessage extends DataStructure { public interface I2NPMessage {
/** 4 bytes unsigned */ /** 4 bytes unsigned */
public static final long MAX_ID_VALUE = (1l << 32) - 1l; public static final long MAX_ID_VALUE = (1l << 32) - 1l;
@ -102,6 +104,11 @@ public interface I2NPMessage extends DataStructure {
/** How large the raw message is with the short 5 byte header */ /** How large the raw message is with the short 5 byte header */
public int getRawMessageSize(); public int getRawMessageSize();
/**
* @since 0.9.48 from DataStructure
*/
public byte[] toByteArray();
/** /**
* Write the message to the buffer, returning the new offset (NOT the length). * Write the message to the buffer, returning the new offset (NOT the length).
* the data is formatted so as to be self contained, with the type, size, * the data is formatted so as to be self contained, with the type, size,

View File

@ -25,9 +25,11 @@ import net.i2p.util.SimpleByteCache;
/** /**
* Defines the base message implementation. * Defines the base message implementation.
* *
* Note: No longer extends DataStructureImpl as of 0.9.48
*
* @author jrandom * @author jrandom
*/ */
public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPMessage { public abstract class I2NPMessageImpl implements I2NPMessage {
protected final Log _log; protected final Log _log;
protected final I2PAppContext _context; protected final I2PAppContext _context;
protected long _expiration; protected long _expiration;
@ -214,7 +216,6 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM
return calculateWrittenLength()+5; return calculateWrittenLength()+5;
} }
@Override
public byte[] toByteArray() { public byte[] toByteArray() {
byte data[] = new byte[getMessageSize()]; byte data[] = new byte[getMessageSize()];
int written = toByteArray(data); int written = toByteArray(data);

View File

@ -18,10 +18,10 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 12; public final static long BUILD = 13;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "-rc";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + FULL_VERSION); System.out.println("I2P Router version: " + FULL_VERSION);

View File

@ -17,6 +17,7 @@ import org.junit.rules.ExpectedException;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.data.DataFormatException; import net.i2p.data.DataFormatException;
import net.i2p.data.DataStructure; import net.i2p.data.DataStructure;
import net.i2p.data.Hash;
import net.i2p.data.router.RouterInfo; import net.i2p.data.router.RouterInfo;
import net.i2p.data.router.RouterInfoTest; import net.i2p.data.router.RouterInfoTest;
import net.i2p.data.StructureTest; import net.i2p.data.StructureTest;
@ -33,7 +34,7 @@ public class DatabaseStoreMessageTest extends StructureTest {
public ExpectedException exception = ExpectedException.none(); public ExpectedException exception = ExpectedException.none();
public DataStructure createDataStructure() throws DataFormatException { public DataStructure createDataStructure() throws DataFormatException {
DatabaseStoreMessage msg = new DatabaseStoreMessage(I2PAppContext.getGlobalContext()); DSMStructure msg = new DSMStructure(I2PAppContext.getGlobalContext());
RouterInfo info = (RouterInfo)new RouterInfoTest().createDataStructure(); RouterInfo info = (RouterInfo)new RouterInfoTest().createDataStructure();
msg.setMessageExpiration(Clock.getInstance().now()); msg.setMessageExpiration(Clock.getInstance().now());
msg.setUniqueId(666); msg.setUniqueId(666);
@ -42,7 +43,7 @@ public class DatabaseStoreMessageTest extends StructureTest {
} }
public DataStructure createStructureToRead() { public DataStructure createStructureToRead() {
return new DatabaseStoreMessage(I2PAppContext.getGlobalContext()); return new DSMStructure(I2PAppContext.getGlobalContext());
} }
@Override @Override
@ -51,4 +52,12 @@ public class DatabaseStoreMessageTest extends StructureTest {
exception.expect(UnsupportedOperationException.class); exception.expect(UnsupportedOperationException.class);
super.testStructure(); super.testStructure();
} }
private static class DSMStructure extends DatabaseStoreMessage implements DataStructure {
public DSMStructure(I2PAppContext ctx) { super(ctx); }
public Hash calculateHash() { return null; }
public void fromByteArray(byte[] b) {}
public void fromBase64(String s) {}
public String toBase64() { return null; }
}
} }