private void OnDataVerified(DataVerified data) { Notifications.Enqueue(new DataVerifiedNotification(data.Hash, data.Bitfield)); DataMap?.Handle(data); DataGet?.Handle(data); }
public void ShouldSentInterestedWhenPeerHasSomethingToOffer() { PeerHash other = PeerHash.Random(); Action <Action <PeerHash, Bitfield, PeerState> > handle = callback => { callback.Invoke(other, Bitfield.Complete(1), new PeerState()); }; using (DataGetFixture fixture = new DataGetFixture()) using (DataGetSession session = fixture.Start()) { DataVerified verified = new DataVerified { Hash = session.Service.Parameters.Hash, Bitfield = new Bitfield(1) }; A.CallTo(() => session.DataMap.Query(A <Action <PeerHash, Bitfield, PeerState> > .Ignored)).Invokes(handle); session.Service.Start(); session.Service.Handle(verified); session.Pipeline.Tick(); session.Pipeline.Process(); A.CallTo(() => session.Glue.SendInterested(other)).MustHaveHappened(); } }
public void Handle(DataVerified data) { context.Queue.Add(() => { context.Verified = true; }); context.Queue.Add(new DataShareTaskInterested()); }
public void Handle(DataVerified data) { context.Queue.Add(() => { context.Bitfield = data.Bitfield; context.Bitfields.Ranking.Complete(data.Bitfield); context.Cache = new OmnibusCache(data.Bitfield.Length); context.Pieces = new OmnibusPieceCollection(context); }); }
private void OnDataVerified(DataVerified data) { Notifications.Enqueue(new DataVerifiedNotification(data.Hash, data.Bitfield)); DataMap?.Handle(data); DataGet?.Handle(data); DataShare?.Handle(data); Coordinator?.Handle(data); TrackerGet.Announce(Hash); }
public void ShouldTriggerBlockReservedSequentialForNotCompletedPieces() { BitfieldChanged bitfieldChangedA = new BitfieldChanged { Peer = PeerHash.Random(), Bitfield = Bitfield.Sequence(true, true) }; BitfieldChanged bitfieldChangedB = new BitfieldChanged { Peer = PeerHash.Random(), Bitfield = Bitfield.Sequence(true, false) }; using (OmnibusFixture fixture = new OmnibusFixture()) using (OmnibusSession session = fixture.Start()) { DataVerified verified = new DataVerified { Hash = session.Hash, Bitfield = Bitfield.Sequence(true, false) }; Trigger trigger = Trigger.Bind(ref session.Hooks.OnBlockReserved, data => { data.Block.Should().NotBeNull(); data.Block.Piece.Index.Should().Be(1); }); session.Service.Start(); session.Service.HandleMetafileVerified(session.Metainfo); session.Service.Handle(verified); session.Service.Handle(bitfieldChangedA); session.Service.Handle(bitfieldChangedB); session.Pipeline.Process(); session.Service.Schedule(OmnibusStrategy.Sequential, bitfieldChangedA.Peer, 1); session.Pipeline.Process(); trigger.Wait().Should().BeTrue(); } }
public void Handle(DataVerified data) { mine = data.Bitfield; }
public void Handle(DataVerified data) { context.Facts.Handle(data); }