public void AddBlock(Block block) { coder.Add(block.GetHash(), block.Serialize()); if (Height > 0) { topBlockOffset = coder.Lookup.NextOffset(topBlockOffset); } else { topBlockOffset = 0; } Height = block.Height; }
public void SerialDictionaryCoder() { var testDataPath = "serialDictionaryUnitTestData"; var testLookupPath = "serialDictionaryUnitTestLookup"; var testReverseLookupPath = "serialDictionaryUnitTestLookup_reverse"; if (File.Exists(testDataPath)) { File.Delete(testDataPath); } if (File.Exists(testLookupPath)) { File.Delete(testLookupPath); } if (File.Exists(testReverseLookupPath)) { File.Delete(testReverseLookupPath); } var serialDictionaryCoder = new SerialDictionaryEncoder(testDataPath, testLookupPath, 32, 2); var expectedDictionary = new Dictionary <byte[], byte[]>(); for (int i = 0; i < 50; i++) { var value = new byte[i + 1]; for (int j = 0; j < value.Length; j++) { value[j] = (byte)(40 + i); } var key = CryptographyHelper.Sha3256(value); serialDictionaryCoder.Add(key, value); expectedDictionary.Add(key, value); } }