示例#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()
 {
     _Tracker = AttachedNode.Behaviors.Find <TrackerBehavior>();
     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("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);
            }

            var tracker = parameters.TemplateBehaviors.Find <TrackerBehavior>();

            if (tracker == null)
            {
                tracker = new TrackerBehavior(new Tracker(), chain.Chain);
                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;
        }