public override void ResolveCollision(UTXOIndex tablePrimary) { KeyValuePair <byte[], uint[]> collisionItem = CollisionTable.First(k => BitConverter.ToInt32(k.Key, 0) == tablePrimary.PrimaryKey); CollisionTable.Remove(collisionItem.Key); if (!tablePrimary.AreCollisionBitsFull() || !HasCountCollisions(tablePrimary.PrimaryKey, COUNT_COLLISIONS_MAX)) { tablePrimary.DecrementCollisionBits(Address); } collisionItem.Value[0] |= tablePrimary.GetCollisionBits(); PrimaryTable.Add(tablePrimary.PrimaryKey, collisionItem.Value); }
void LoadCollisionData(byte[] buffer) { int index = 0; int uintLength; uint[] value; while (index < buffer.Length) { byte[] key = new byte[HASH_BYTE_SIZE]; Array.Copy(buffer, index, key, 0, HASH_BYTE_SIZE); index += HASH_BYTE_SIZE; int byteLength = VarInt.GetInt32(buffer, ref index); uintLength = byteLength >> 2; value = new uint[uintLength]; Buffer.BlockCopy(buffer, index, value, 0, byteLength); index += byteLength; CollisionTable.Add(key, value); } }
public override void Clear() { PrimaryTable.Clear(); CollisionTable.Clear(); }
protected override void RemoveCollision(byte[] key) { CollisionTable.Remove(key); }
protected override bool TryGetValueInCollisionTable(byte[] key) { return(CollisionTable.TryGetValue(key, out UTXOCollision)); }
public override void AddUTXOAsCollision(byte[] uTXOKey) { CollisionTable.Add(uTXOKey, UTXO); }