summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c_src/permdb.c20
-rw-r--r--doc/permdb.md4
2 files changed, 12 insertions, 12 deletions
diff --git a/c_src/permdb.c b/c_src/permdb.c
index 218b8c8..ec540a5 100644
--- a/c_src/permdb.c
+++ b/c_src/permdb.c
@@ -153,7 +153,7 @@ static const uint64_t index_file_cookie = 0xb7e16b02ba8a6d1b;
static const uint64_t index_commit_cookie = 0x2fb1778c74a402e4;
static const uint64_t index_node_cookie = 0x2e0f555ad73210d1;
-static const uint64_t data_file_cookie = 0xd53551ba539a4252;
+static const uint64_t data_file_cookie = 0x99c99d588b1e7983;
static const uint64_t data_entry_cookie = 0xe7c1cdc2ba3dc77c;
static const uint64_t data_commit_start_cookie = 0x75c2e4b3d5f643a1;
static const uint64_t data_commit_end_cookie = 0x2b05eed61b5af550;
@@ -312,24 +312,24 @@ struct commit_info *
read_data_commit(buffered_file *file, node_offset *offset)
{
const size_t length =
- sizeof(uint32_t)
+ sizeof(uint64_t)
+ SHA256_DIGEST_SIZE
+ sizeof(data_commit_end_cookie);
unsigned char *data = bf_read(file, *offset, length, NULL);
if (data == NULL
- || (read_be64(data + sizeof(uint32_t) + SHA256_DIGEST_SIZE)
+ || (read_be64(data + sizeof(uint64_t) + SHA256_DIGEST_SIZE)
!= data_commit_end_cookie)) {
free(data);
return NULL;
}
- *offset += sizeof(uint32_t);
+ *offset += sizeof(uint64_t);
struct commit_info *commit = malloc(sizeof(struct commit_info));
dprintf(READ, (stderr, "read commit: %llu\n",
(long long unsigned) *offset));
- dprinthex(READ, data, sizeof(uint32_t) + SHA256_DIGEST_SIZE);
- commit->length = read_be32(data);
+ dprinthex(READ, data, sizeof(uint64_t) + SHA256_DIGEST_SIZE);
+ commit->length = read_be64(data);
commit->start = *offset - commit->length;
- memcpy(&commit->checksum, data + sizeof(uint32_t), SHA256_DIGEST_SIZE);
+ memcpy(&commit->checksum, data + sizeof(uint64_t), SHA256_DIGEST_SIZE);
*offset += SHA256_DIGEST_SIZE + sizeof(data_commit_end_cookie);
free(data);
return commit;
@@ -346,7 +346,7 @@ read_data_commit_forward(buffered_file *file, node_offset *offset)
struct commit_info *
read_data_commit_backward(buffered_file *file, node_offset *offset)
{
- *offset -= sizeof(uint32_t)
+ *offset -= sizeof(uint64_t)
+ SHA256_DIGEST_SIZE
+ sizeof(data_commit_end_cookie);
return read_data_commit(file, offset);
@@ -1111,10 +1111,10 @@ committree(permdb_object *state)
unsigned char data_commit_checksum[SHA256_DIGEST_SIZE];
bf_add_be64(state->datafile, data_commit_start_cookie);
bf_add(state->datafile, padding, data_commit_padding_size);
- bf_add_be32(state->datafile,
+ bf_add_be64(state->datafile,
bf_total_length(state->datafile)
- bf_lastcommit(state->datafile)
- + sizeof(uint32_t)); /* Including the length field. */
+ + sizeof(uint64_t)); /* Including the length field. */
bf_sha256(state->datafile, data_commit_checksum);
bf_add(state->datafile, data_commit_checksum, SHA256_DIGEST_SIZE);
bf_add_be64(state->datafile, data_commit_end_cookie);
diff --git a/doc/permdb.md b/doc/permdb.md
index 716d384..66184d2 100644
--- a/doc/permdb.md
+++ b/doc/permdb.md
@@ -44,7 +44,7 @@ bytes. Therefore, the data in an entry is chunked.
All values are in big-endian byte order.
- file
- - file cookie [64-bit] = 0xd53551ba539a4252
+ - file cookie [64-bit] = 0x99c99d588b1e7983
- parameters
- commits
- commit
@@ -58,7 +58,7 @@ All values are in big-endian byte order.
- ...
- commit start cookie [64-bit] = 0x75c2e4b3d5f643a1
- padding to 4-byte boundary
- - length [32-bit]
+ - length [64-bit]
- checksum = SHA-256 of whole commit except checksum and end cookie
- commit end cookie [64-bit] = 0x2b05eed61b5af550