/// <summary> /// Initializes a new instance of <see cref="MessageManager"/> using the given parameters. /// </summary> /// <exception cref="ArgumentException"/> /// <exception cref="ArgumentOutOfRangeException"/> /// <param name="cs">Client settings</param> /// <param name="repMan">A reply manager to create appropriate response to a given message</param> /// <param name="ns">Node status</param> public MessageManager(IClientSettings cs, IReplyManager repMan, INodeStatus ns) { if (cs is null) { throw new ArgumentNullException(nameof(cs), "Client settings can not be null."); } if (repMan is null) { throw new ArgumentNullException(nameof(repMan), "Reply manager can not be null."); } if (ns is null) { throw new ArgumentNullException(nameof(ns), "Node status can not be null."); } netType = cs.Network; magicBytes = netType switch { NetworkType.MainNet => Base16.Decode(Constants.MainNetMagic), NetworkType.TestNet => Base16.Decode(Constants.TestNetMagic), NetworkType.RegTest => Base16.Decode(Constants.RegTestMagic), _ => throw new ArgumentException(Err.InvalidNetwork) }; replyManager = repMan; NodeStatus = ns; buffLen = cs.BufferLength; toSendQueue = new Queue <Message>(); IsReceiveCompleted = true; }
/// <summary> /// Initializes a new instance of <see cref="MessageManager"/> using the given parameters. /// </summary> /// <exception cref="ArgumentException"/> /// <exception cref="ArgumentOutOfRangeException"/> /// <param name="bufferLength">Size of the buffer used for each <see cref="SocketAsyncEventArgs"/> object</param> /// <param name="repMan">A reply manager to create appropriate response to a given message</param> /// <param name="ns">Node status</param> /// <param name="netType">[Default value = <see cref="NetworkType.MainNet"/>] Network type</param> public MessageManager(int bufferLength, IReplyManager repMan, INodeStatus ns, NetworkType netType = NetworkType.MainNet) { if (bufferLength <= 0) { throw new ArgumentOutOfRangeException(nameof(bufferLength), "Buffer length can not be negative or zero."); } if (repMan is null) { throw new ArgumentNullException(nameof(repMan), "Reply manager can not be null."); } magicBytes = netType switch { NetworkType.MainNet => Base16.Decode(Constants.MainNetMagic), NetworkType.TestNet => Base16.Decode(Constants.TestNetMagic), NetworkType.RegTest => Base16.Decode(Constants.RegTestMagic), _ => throw new ArgumentException(Err.InvalidNetwork) }; this.netType = netType; replyManager = repMan; NodeStatus = ns; buffLen = bufferLength; Init(); }
public bool ProcessBlock(IBlock block, INodeStatus nodeStatus) { Assert.NotNull(nodeStatus); Assert.Equal(expProcessBlk, block.GetBlockID(false)); return(blkProcessSuccess); }
public void SetMissingBlockHashes(INodeStatus nodeStatus) { Assert.NotNull(nodeStatus); }
/// <summary> /// Initializes a new instanse of <see cref="ReplyManager"/> using the given parameters. /// </summary> /// <param name="ns">Node status</param> /// <param name="bc">Blockchain database</param> /// <param name="cs">Client settings</param> public ReplyManager(INodeStatus ns, IBlockchain bc, IClientSettings cs) { nodeStatus = ns; settings = cs; blockchain = bc; }
/// <summary> /// Initializes a new instanse of <see cref="ReplyManager"/> using the given parameters. /// </summary> /// <param name="ns">Node status</param> /// <param name="cs">Client settings</param> public ReplyManager(INodeStatus ns, IClientSettings cs) { nodeStatus = ns; settings = cs; }
public void SetMissingBlockHashes(INodeStatus nodeStatus) { }
public bool ProcessBlock(IBlock block, INodeStatus nodeStatus) => true;