I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 531d520c authored by zzz's avatar zzz
Browse files

Blockfile:

 - Add block size to superblock
 - Add span size to skiplist block
 - Bump version to 1.2
parent 4e72e150
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,7 @@ import net.i2p.util.Log;
* free list start (unsigned int)
* is mounted (unsigned short) 0 = no, 1 = yes
* span size (unsigned short)
* block size (unsigned int)
*
* Metaindex skiplist is on page 2
*
......@@ -71,7 +72,9 @@ public class BlockFile {
public final RandomAccessInterface file;
private static final int MAJOR = 0x01;
private static final int MINOR = 0x01;
private static final int MINOR = 0x02;
private static final int MIN_MAJOR = 0x01;
private static final int MIN_MINOR = 0x01;
// I2P changed magic number, format changed, magic numbers now on all pages
private static final long MAGIC_BASE = 0x3141de4932500000L; // 0x3141de I 2 P 00 00
private static final long MAGIC = MAGIC_BASE | (MAJOR << 8) | MINOR;
......@@ -109,6 +112,8 @@ public class BlockFile {
file.writeInt( freeListStart);
file.writeShort(mounted);
file.writeShort(spanSize);
// added in version 1.2
file.writeInt(PAGESIZE);
}
private void readSuperBlock() throws IOException {
......@@ -118,6 +123,7 @@ public class BlockFile {
freeListStart = file.readUnsignedInt();
mounted = file.readUnsignedShort();
spanSize = file.readUnsignedShort();
// assume 1024 page size
}
/**
......@@ -293,9 +299,13 @@ public class BlockFile {
readSuperBlock();
if(magicBytes != MAGIC) {
if((magicBytes & MAGIC_BASE) == MAGIC_BASE) {
throw new IOException("Expected " + MAJOR + '.' + MINOR +
" but got " + (magicBytes >> 8 & 0xff) + '.' + (magicBytes & 0xff));
if ((magicBytes & MAGIC_BASE) == MAGIC_BASE) {
long major = (magicBytes >> 8) & 0xff;
long minor = magicBytes & 0xff;
if (major < MIN_MAJOR ||
(major == MIN_MAJOR && minor < MIN_MINOR))
throw new IOException("Expected " + MAJOR + '.' + MINOR +
" but got " + major + '.' + minor);
} else {
throw new IOException("Bad magic number");
}
......
......@@ -82,6 +82,8 @@ public class BSkipList extends SkipList {
size = bf.file.readUnsignedInt();
int spans = bf.file.readInt();
int levelCount = bf.file.readInt();
// two byte spansize as of version 1.2, ignore for now
// int ss = bf.file.readUnsignedShort(); if (ss > 0) ...
//System.out.println(size + " " + spans);
this.fileOnly = fileOnly;
......@@ -171,6 +173,8 @@ public class BSkipList extends SkipList {
bf.file.writeInt(0);
bf.file.writeInt(1);
bf.file.writeInt(1);
// added in version 1.2
bf.file.writeShort(spanSize);
BSkipSpan.init(bf, firstSpan, spanSize);
BSkipLevels.init(bf, firstLevel, firstSpan, 4);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment