public void Can_get_all_on_empty() { IDbConfig config = new DbConfig(); DbOnTheRocks db = new BlocksRocksDb("testIterator", config); try { db.GetAll().ToList(); } finally { db.Clear(); db.Dispose(); } }
public void Init(string path) { var dbOnTheRocks = new BlocksRocksDb(path, new DbConfig(), LimboLogs.Instance); var blocksBytes = dbOnTheRocks.GetAll(); var blockDecoder = new BlockDecoder(); var blocks = blocksBytes .Select(b => blockDecoder.Decode(b.Value.AsRlpStream())) .OrderBy(b => b.Number) .ToList(); var window = new Window("Blocks") { X = 0, Y = 10, Width = Dim.Fill(), Height = Dim.Fill() }; if (!blocks.Any()) { MessageBox.Query(40, 7, "Info", "No data."); window.FocusPrev(); return; } var y = 1; foreach (var block in blocks) { var blockBtn = new Button(1, y++, $"Number: {block.Number}, Hash: {block.Hash}"); blockBtn.Clicked = () => { var blockDetailsWindow = new Window("Block details") { X = 0, Y = 10, Width = Dim.Fill(), Height = Dim.Fill() }; Application.Top.Add(blockDetailsWindow); var serializer = new EthereumJsonSerializer(); var blockLbl = new Label(1, 1, serializer.Serialize(block, true)); blockDetailsWindow.Add(blockLbl); Application.Run(blockDetailsWindow); }; window.Add(blockBtn); } Application.Top.Add(window); Application.Run(window); }