/// <summary> /// Adds new nonce with Receiver state to table /// </summary> /// <param name="peerNodeId">Sender node id</param> /// <param name="receiverNonce">16 bytes receiver nonce</param> /// <param name="sequenceNumber">Sequence number</param> public void Add(InvariantPeerNodeId peerNodeId, byte[] receiverNonce, byte txSequenceNumber, byte rxSequenceNumber) { lock (_synchObject) { if (!_table.ContainsKey(peerNodeId)) { _table.Add(peerNodeId, new SpanContainer(receiverNonce, txSequenceNumber, rxSequenceNumber)); } else if (_table.ContainsKey(peerNodeId) && _table[peerNodeId].SpanState == SpanStates.None) { _table[peerNodeId].SetReceiversNonceState(receiverNonce); _table[peerNodeId].TxSequenceNumber = txSequenceNumber; _table[peerNodeId].RxSequenceNumber = rxSequenceNumber; } else { throw new InvalidOperationException("Nonce with specified peerNodeId already exists"); } BackupTxSequenceNumber(peerNodeId); } }
public MpanContainer AddOrReplace(NodeGroupId nodeGroupId, byte sequenceNumber, byte[] receiverGroupHandle, byte[] mpanState) { lock (_synchObject) { if (_table.ContainsKey(nodeGroupId)) { _table.Remove(nodeGroupId); } var mpanContainer = new MpanContainer(nodeGroupId, mpanState, sequenceNumber, receiverGroupHandle); _table.Add(nodeGroupId, mpanContainer); return(mpanContainer); } }
public byte GetTxSequenceNumber(InvariantPeerNodeId peerNodeId) { byte ret = 0; lock (_synchObject) { if (_table.ContainsKey(peerNodeId)) { ret = _table[peerNodeId].TxSequenceNumber; } else if (_txSequenceNumberTable.ContainsKey(peerNodeId)) { ret = ++_txSequenceNumberTable[peerNodeId]; } else { ret = 0x55; _txSequenceNumberTable.Add(peerNodeId, ret); } } return(ret); }
public void RegisterInternal(OrdinalPeerNodeId peerNodeId, byte[] nonceData) { NonceContainer n = new NonceContainer(nonceData); if (!_table.ContainsKey(peerNodeId)) { _table.Add(peerNodeId, n); } else { _table[peerNodeId] = n; } }