Пример #1
0
        public override object Clone()
        {
            var clone = new TrackerBehavior(_Tracker, _ExplicitChain);

            clone.FalsePositiveRate = FalsePositiveRate;
            clone._SkipBefore       = _SkipBefore;
            clone._CurrentProgress  = _CurrentProgress;
            return(clone);
        }
Пример #2
0
            protected override void AttachCore()
            {
#pragma warning disable CS0612 // Type or member is obsolete
                _Tracker = AttachedNode.Behaviors.Find <TrackerBehavior>();
#pragma warning restore CS0612 // Type or member is obsolete
                if (_Tracker != null)
                {
                    AttachedNode.Disconnected += AttachedNode_Disconnected;
                    AttachedNode.StateChanged += AttachedNode_StateChanged;
                }
                _Broadcast = BroadcastHub.GetBroadcastHub(AttachedNode);
                if (_Broadcast != null)
                {
                    _Broadcast.TransactionBroadcasted += _Broadcast_TransactionBroadcasted;
                    _Broadcast.TransactionRejected    += _Broadcast_TransactionRejected;
                }
            }
Пример #3
0
        /// <summary>
        /// Configure the components of the wallet
        /// </summary>
        /// <param name="group">The group to use</param>
        public void Configure(NodesGroup group)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }

            var parameters = group.NodeConnectionParameters;

            group.Requirements.SupportSPV = true;

            var chain = parameters.TemplateBehaviors.Find <ChainBehavior>();

            if (chain == null)
            {
                chain = new ChainBehavior(new ConcurrentChain(_Parameters.Network));
                parameters.TemplateBehaviors.Add(chain);
            }
            if (chain.Chain.Genesis.HashBlock != _Parameters.Network.GetGenesis().GetHash())
            {
                throw new InvalidOperationException("ChainBehavior with invalid network chain detected");
            }

            var addrman = parameters.TemplateBehaviors.Find <AddressManagerBehavior>();

            if (addrman == null)
            {
                addrman = new AddressManagerBehavior(new AddressManager());
                parameters.TemplateBehaviors.Add(addrman);
            }

#pragma warning disable CS0612 // Type or member is obsolete
            var tracker = parameters.TemplateBehaviors.Find <TrackerBehavior>();
#pragma warning restore CS0612 // Type or member is obsolete
            if (tracker == null)
            {
#pragma warning disable CS0612 // Type or member is obsolete
#pragma warning disable CS0612 // Type or member is obsolete
                tracker = new TrackerBehavior(new Tracker(), chain.Chain);
#pragma warning restore CS0612 // Type or member is obsolete
#pragma warning restore CS0612 // Type or member is obsolete
                parameters.TemplateBehaviors.Add(tracker);
            }
            var wallet = FindWalletBehavior(parameters.TemplateBehaviors);
            if (wallet == null)
            {
                wallet = new WalletBehavior(this);
                parameters.TemplateBehaviors.Add(wallet);
            }
            var broadcast = parameters.TemplateBehaviors.Find <BroadcastHubBehavior>();
            if (broadcast == null)
            {
                broadcast = new BroadcastHubBehavior();
                parameters.TemplateBehaviors.Add(broadcast);
            }

            _Group = group;
            if (_ListenedTracker != null)
            {
                _ListenedTracker.NewOperation -= _ListenerTracked_NewOperation;
            }
            _ListenedTracker = tracker.Tracker;
            _ListenedTracker.NewOperation += _ListenerTracked_NewOperation;
        }