Skip to content

Stopping in buying mode not safe #6

@bedeho

Description

@bedeho

Background

When stopping a session while in buying mode, all connections are closed, and the session is set to stopped, however the _buyingState variable is not inspected or touched. As a reminder, it is of type

    enum class BuyingState {

        // Inviting sellers:
        // Peers with good enough terms are invited, even when paused,
        sending_invitations,

        // Requesting and downloading pieces:
        // Contract has been announced and exchanges are ongoing.
        downloading,

        // Have all pieces
        download_completed
    };

Problem

If stopped when downloading, and then later started, then it has no way of recovering back tosending_invitations, and is effectively stuck. This analogous to this issue #5.

Solution

Reset _buyingState to sending_invitations if stopped while _buyingState == downloading.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions