private void DeleteBlockIndex(EsentBlockTxesCursor cursor, UInt256 blockHash) { Api.JetSetCurrentIndex(cursor.jetSession, cursor.blockIndexTableId, "IX_BlockHash"); Api.MakeKey(cursor.jetSession, cursor.blockIndexTableId, DbEncoder.EncodeUInt256(blockHash), MakeKeyGrbit.NewKey); if (Api.TrySeek(cursor.jetSession, cursor.blockIndexTableId, SeekGrbit.SeekEQ)) { Api.JetDelete(cursor.jetSession, cursor.blockIndexTableId); } else { throw new InvalidOperationException(); } }
private int AddBlockIndex(EsentBlockTxesCursor cursor, UInt256 blockHash) { int blockIndex; using (var jetUpdate = cursor.jetSession.BeginUpdate(cursor.blockIndexTableId, JET_prep.Insert)) { Api.SetColumn(cursor.jetSession, cursor.blockIndexTableId, cursor.blockIndexBlockHashColumnId, DbEncoder.EncodeUInt256(blockHash)); blockIndex = Api.RetrieveColumnAsInt32(cursor.jetSession, cursor.blockIndexTableId, cursor.blockIndexBlockIndexColumnId, RetrieveColumnGrbit.RetrieveCopy).Value; jetUpdate.Save(); } return(blockIndex); }
private bool TryGetBlockIndex(EsentBlockTxesCursor cursor, UInt256 blockHash, out int blockIndex) { Api.JetSetCurrentIndex(cursor.jetSession, cursor.blockIndexTableId, "IX_BlockHash"); Api.MakeKey(cursor.jetSession, cursor.blockIndexTableId, DbEncoder.EncodeUInt256(blockHash), MakeKeyGrbit.NewKey); if (Api.TrySeek(cursor.jetSession, cursor.blockIndexTableId, SeekGrbit.SeekEQ)) { blockIndex = Api.RetrieveColumnAsInt32(cursor.jetSession, cursor.blockIndexTableId, cursor.blockIndexBlockIndexColumnId).Value; return(true); } else { blockIndex = -1; return(false); } }
private void DeleteBlockIndex(EsentBlockTxesCursor cursor, UInt256 blockHash) { Api.JetSetCurrentIndex(cursor.jetSession, cursor.blockIndexTableId, "IX_BlockHash"); Api.MakeKey(cursor.jetSession, cursor.blockIndexTableId, DbEncoder.EncodeUInt256(blockHash), MakeKeyGrbit.NewKey); if (Api.TrySeek(cursor.jetSession, cursor.blockIndexTableId, SeekGrbit.SeekEQ)) Api.JetDelete(cursor.jetSession, cursor.blockIndexTableId); else throw new InvalidOperationException(); }
private int AddBlockIndex(EsentBlockTxesCursor cursor, UInt256 blockHash) { int blockIndex; using (var jetUpdate = cursor.jetSession.BeginUpdate(cursor.blockIndexTableId, JET_prep.Insert)) { Api.SetColumn(cursor.jetSession, cursor.blockIndexTableId, cursor.blockIndexBlockHashColumnId, DbEncoder.EncodeUInt256(blockHash)); blockIndex = Api.RetrieveColumnAsInt32(cursor.jetSession, cursor.blockIndexTableId, cursor.blockIndexBlockIndexColumnId, RetrieveColumnGrbit.RetrieveCopy).Value; jetUpdate.Save(); } return blockIndex; }
private bool TryGetBlockIndex(EsentBlockTxesCursor cursor, UInt256 blockHash, out int blockIndex) { Api.JetSetCurrentIndex(cursor.jetSession, cursor.blockIndexTableId, "IX_BlockHash"); Api.MakeKey(cursor.jetSession, cursor.blockIndexTableId, DbEncoder.EncodeUInt256(blockHash), MakeKeyGrbit.NewKey); if (Api.TrySeek(cursor.jetSession, cursor.blockIndexTableId, SeekGrbit.SeekEQ)) { blockIndex = Api.RetrieveColumnAsInt32(cursor.jetSession, cursor.blockIndexTableId, cursor.blockIndexBlockIndexColumnId).Value; return true; } else { blockIndex = -1; return false; } }
private void AddTransaction(int blockIndex, int txIndex, UInt256 txHash, byte[] txBytes, EsentBlockTxesCursor cursor) { using (var jetUpdate = cursor.jetSession.BeginUpdate(cursor.blocksTableId, JET_prep.Insert)) { Api.SetColumns(cursor.jetSession, cursor.blocksTableId, new Int32ColumnValue { Columnid = cursor.blockIndexColumnId, Value = blockIndex }, new Int32ColumnValue { Columnid = cursor.txIndexColumnId, Value = txIndex }, //TODO i'm using -1 depth to mean not pruned, this should be interpreted as depth 0 new Int32ColumnValue { Columnid = cursor.blockDepthColumnId, Value = -1 }, new BytesColumnValue { Columnid = cursor.blockTxHashColumnId, Value = DbEncoder.EncodeUInt256(txHash) }, new BytesColumnValue { Columnid = cursor.blockTxBytesColumnId, Value = txBytes }); jetUpdate.Save(); } }
public MerkleTreePruningCursor(int blockIndex, EsentBlockTxesCursor cursor) { this.blockIndex = blockIndex; this.cursor = cursor; Api.JetSetCurrentIndex(cursor.jetSession, cursor.blocksTableId, "IX_BlockIndexTxIndex"); }
public MerkleTreePruningCursor(int blockIndex, EsentBlockTxesCursor cursor) { this.blockIndex = blockIndex; this.cursor = cursor; Api.JetSetCurrentIndex(cursor.jetSession, cursor.blocksTableId, "IX_BlockIndexTxIndex"); }
private void AddTransaction(int blockIndex, int txIndex, UInt256 txHash, byte[] txBytes, EsentBlockTxesCursor cursor) { using (var jetUpdate = cursor.jetSession.BeginUpdate(cursor.blocksTableId, JET_prep.Insert)) { Api.SetColumns(cursor.jetSession, cursor.blocksTableId, new Int32ColumnValue { Columnid = cursor.blockIndexColumnId, Value = blockIndex }, new Int32ColumnValue { Columnid = cursor.txIndexColumnId, Value = txIndex }, //TODO i'm using -1 depth to mean not pruned, this should be interpreted as depth 0 new Int32ColumnValue { Columnid = cursor.blockDepthColumnId, Value = -1 }, new BytesColumnValue { Columnid = cursor.blockTxHashColumnId, Value = DbEncoder.EncodeUInt256(txHash) }, new BytesColumnValue { Columnid = cursor.blockTxBytesColumnId, Value = txBytes }); jetUpdate.Save(); } }