public DbCache(LTLightDB db, LTISnapShot snapshot, LTWriteTask batch, byte prefix) { this.db = db; this.snapshot = snapshot ?? db.UseSnapShot(); this.batch = batch; this.prefix = prefix; }
public DbMetaDataCache(LTLightDB db, LTISnapShot snapshot, LTWriteTask batch, byte prefix, Func <T> factory = null) : base(factory) { this.db = db; this.snapshot = snapshot ?? db.UseSnapShot(); this.batch = batch; this.prefix = prefix; }
public DbCache(DB db, LTISnapshot _snapshot, LTWriteTask batch, byte prefix) { this.db = db; snapshot = _snapshot ?? db.UseSnapShot(); this.options = options ?? ReadOptions.Default; this.batch = batch; this.prefix = prefix; }
public DbSnapshot(DB db) { this.db = db; this.snapshot = db.UseSnapShot(); this.batch = db.CreateWriteTask(); Blocks = new DbCache <UInt256, BlockState>(db, snapshot, batch, Prefixes.DATA_Block); Transactions = new DbCache <UInt256, TransactionState>(db, snapshot, batch, Prefixes.DATA_Transaction); Accounts = new DbCache <UInt160, AccountState>(db, snapshot, batch, Prefixes.ST_Account); UnspentCoins = new DbCache <UInt256, UnspentCoinState>(db, snapshot, batch, Prefixes.ST_Coin); SpentCoins = new DbCache <UInt256, SpentCoinState>(db, snapshot, batch, Prefixes.ST_SpentCoin); Validators = new DbCache <ECPoint, ValidatorState>(db, snapshot, batch, Prefixes.ST_Validator); Assets = new DbCache <UInt256, AssetState>(db, snapshot, batch, Prefixes.ST_Asset); Contracts = new DbCache <UInt160, ContractState>(db, snapshot, batch, Prefixes.ST_Contract); Storages = new DbCache <StorageKey, StorageItem>(db, snapshot, batch, Prefixes.ST_Storage); HeaderHashList = new DbCache <UInt32Wrapper, HeaderHashList>(db, snapshot, batch, Prefixes.IX_HeaderHashList); ValidatorsCount = new DbMetaDataCache <ValidatorsCountState>(db, snapshot, batch, Prefixes.IX_ValidatorsCount); BlockHashIndex = new DbMetaDataCache <HashIndexState>(db, snapshot, batch, Prefixes.IX_CurrentBlock); HeaderHashIndex = new DbMetaDataCache <HashIndexState>(db, snapshot, batch, Prefixes.IX_CurrentHeader); }
public static IEnumerable <T> Find <T>(this DB db, LTISnapshot snapshot, Slice prefix, Func <Slice, Slice, T> resultSelector) { LTIKeyIterator it = snapshot.CreateKeyIterator(new byte[] { }, prefix.buffer); { while (it.MoveNext()) { byte[] key = it.Current; byte[] y = prefix.ToArray(); if (key.Length < y.Length) { break; } if (!key.Take(y.Length).SequenceEqual(y)) { break; } byte[] value = snapshot.GetValue(new byte[] { }, key).value; yield return(resultSelector(new Slice(key), new Slice(value))); } } }
public static IEnumerable <T> Find <T>(this DB db, LTISnapshot snapshot, byte prefix) where T : class, ISerializable, new() { return(Find(db, snapshot, SliceBuilder.Begin(prefix), (k, v) => v.ToArray().AsSerializable <T>())); }