public static Friend addFriend(Friend new_friend) { if (friends.Find(x => x.walletAddress.SequenceEqual(new_friend.walletAddress)) != null) { // Already in the list return(null); } // Add new friend to the friendlist friends.Add(new_friend); Node.shouldRefreshContacts = true; if (new_friend.approved) { lock (friendMatcher) { if (friendMatcher.Add(new_friend.walletAddress) == Cuckoo.CuckooStatus.NotEnoughSpace) { // rebuild cuckoo filter with a larger size friendMatcher = new Cuckoo(friendMatcher.numItems * 2); foreach (Friend f in friends) { friendMatcher.Add(f.walletAddress); } } } ProtocolMessage.resubscribeEvents(); } sortFriends(); return(new_friend); }
public static Friend addFriend(byte[] wallet_address, byte[] public_key, string name, byte[] aes_key, byte[] chacha_key, long key_generated_time, bool approved = true) { foreach (Friend friend in friends) { if (friend.walletAddress.SequenceEqual(wallet_address)) { // Already in the list return(null); } } Friend new_friend = new Friend(wallet_address, public_key, name, aes_key, chacha_key, key_generated_time, approved); // Add new friend to the friendlist friends.Add(new_friend); if (approved) { cachedHiddenMatchAddresses = null; ProtocolMessage.resubscribeEvents(); } sortFriends(); return(new_friend); }
public static void sendAcceptAdd(Friend friend) { if (friend.handshakeStatus > 1) { return; } friend.aesKey = null; friend.chachaKey = null; friend.generateKeys(); SpixiMessage spixi_message = new SpixiMessage(new byte[] { 1 }, SpixiMessageCode.acceptAdd, friend.aesKey); StreamMessage message = new StreamMessage(); message.type = StreamMessageCode.info; message.recipient = friend.walletAddress; message.sender = Node.walletStorage.getPrimaryAddress(); message.transaction = new byte[1]; message.sigdata = new byte[1]; message.data = spixi_message.getBytes(); message.encryptionType = StreamMessageEncryptionCode.rsa; StreamProcessor.sendMessage(friend, message); ProtocolMessage.resubscribeEvents(); }
public static Friend addFriend(Friend new_friend) { if (friends.Find(x => x.walletAddress.SequenceEqual(new_friend.walletAddress)) != null) { // Already in the list return(null); } // Add new friend to the friendlist friends.Add(new_friend); if (new_friend.approved) { cachedHiddenMatchAddresses = null; ProtocolMessage.resubscribeEvents(); } sortFriends(); return(new_friend); }