コード例 #1
0
        public async Task add_should_save_a_new_static_node_and_trigger_an_event()
        {
            var eventRaised = false;

            _staticNodesManager.NodeAdded += (s, e) => { eventRaised = true; };
            _staticNodesManager.Nodes.Count().Should().Be(0);
            await _staticNodesManager.AddAsync(Enode, false);

            _staticNodesManager.Nodes.Count().Should().Be(1);
            eventRaised.Should().BeTrue();
        }
コード例 #2
0
        public async Task <ResultWrapper <string> > admin_addPeer(string enode)
        {
            var added = await _staticNodesManager.AddAsync(enode);

            return(added
                ? ResultWrapper <string> .Success(enode)
                : ResultWrapper <string> .Fail("Static node already exists."));
        }
コード例 #3
0
        public async Task <ResultWrapper <string> > admin_addPeer(string enode, bool addToStaticNodes = false)
        {
            bool added;

            if (addToStaticNodes)
            {
                added = await _staticNodesManager.AddAsync(enode);
            }
            else
            {
                added = _peerManager.AddPeer(new NetworkNode(enode));
            }

            return(added
                ? ResultWrapper <string> .Success(enode)
                : ResultWrapper <string> .Fail("Failed to add peer."));
        }