/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="protoName">The protounit.</param> /// <param name="type">The item type.</param> /// <param name="item">The item name.</param> /// <param name="result">The result.</param> public PacketBResponseBuyItem(string protoName, InventoryItemTypes type, string item, byte result) { ProtoName = protoName; Type = type; Item = item; Result = result; }
public static InventoryItem decodeInventoryItem(byte[] bytes) { InventoryItemTypes type = (InventoryItemTypes)bytes.GetIxiVarInt(0).num; InventoryItem item = null; switch (type) { case InventoryItemTypes.block: item = new InventoryItemBlock(bytes); break; case InventoryItemTypes.transaction: item = new InventoryItem(bytes); break; case InventoryItemTypes.keepAlive: item = new InventoryItemKeepAlive(bytes); break; case InventoryItemTypes.blockSignature: item = new InventoryItemSignature(bytes); break; } return(item); }
private bool remove(InventoryItemTypes type, byte[] hash) { lock (inventory) { return(inventory[type].Remove(hash)); } }
public PendingInventoryItem get(InventoryItemTypes type, byte[] hash) { lock (inventory) { var inventory_types = inventory[type]; if (!inventory_types.ContainsKey(hash)) { return(null); } return(inventory_types[hash]); } }
public InventoryItem(byte[] bytes) { using (MemoryStream m = new MemoryStream(bytes)) { using (BinaryReader reader = new BinaryReader(m)) { type = (InventoryItemTypes)reader.ReadIxiVarInt(); int hash_len = (int)reader.ReadIxiVarUInt(); hash = reader.ReadBytes(hash_len); } } }
protected void truncateInventory(InventoryItemTypes type) { var inventory_list = inventory[type]; int max_items = 2000; InventoryTypeOptions options; if (typeOptions.TryGetValue(type, out options)) { max_items = options.maxItems; } if (inventory_list.Count() > max_items) { inventory_list.Remove(inventory_list.Keys.First()); } }
public PacketBRequestBuyItem(byte[] request) { using (MemoryStream Stream = new MemoryStream(request)) { using (BinaryReader Reader = new BinaryReader(Stream)) { int ProtoNameLength = Reader.ReadInt32(); ProtoName = Encoding.Unicode.GetString(Reader.ReadBytes(ProtoNameLength)); InventoryItemTypes Type = (InventoryItemTypes)Reader.ReadInt32(); int ItemLength = Reader.ReadInt32(); Item = Encoding.Unicode.GetString(Reader.ReadBytes(ItemLength)); } } }
virtual public bool setProcessedFlag(InventoryItemTypes type, byte[] hash, bool processed) { lock (inventory) { if (!inventory[type].ContainsKey(hash)) { if (processed) { var inventory_list = inventory[type]; inventory_list.Add(hash, new PendingInventoryItem(new InventoryItem(type, hash)) { processed = processed }); truncateInventory(type); } } else { inventory[type][hash].processed = processed; return(true); } } return(false); }
public void Post([FromBody] InventoryItemTypes value) { _context.InventoryItemTypes.Add(value); _context.SaveChanges(); }
public InventoryItem(InventoryItemTypes type, byte[] hash) { this.type = type; this.hash = hash; }
public bool processInventoryItem(InventoryItemTypes type, byte[] hash) { var pii = get(type, hash); return(processInventoryItem(pii)); }