private void ImportBlocks(Stream stream, bool read_start = false) { TR.Enter(); LevelDBBlockchain blockchain = (LevelDBBlockchain)Blockchain.Default; using (BinaryReader r = new BinaryReader(stream)) { uint start = read_start ? r.ReadUInt32() : 0; uint count = r.ReadUInt32(); uint end = start + count - 1; if (end <= blockchain.Height) { return; } for (uint height = start; height <= end; height++) { byte[] array = r.ReadBytes(r.ReadInt32()); if (height > blockchain.Height) { Block block = array.AsSerializable <Block>(); blockchain.AddBlockDirectly(block); } } } TR.Exit(); }
private void ImportBlocks(Stream stream) { LevelDBBlockchain blockchain = (LevelDBBlockchain)Blockchain.Default; using (BinaryReader r = new BinaryReader(stream)) { uint count = r.ReadUInt32(); for (int height = 0; height < count; height++) { byte[] array = r.ReadBytes(r.ReadInt32()); if (height > blockchain.Height) { Block block = array.AsSerializable <Block>(); blockchain.AddBlockDirectly(block); } } } }