github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/core/discovery/dhtdiscovery/repository.go (about)

     1  /*
     2   * Copyright (C) 2020 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package dhtdiscovery
    19  
    20  import (
    21  	"sync"
    22  
    23  	"github.com/mysteriumnetwork/node/core/discovery/proposal"
    24  	"github.com/mysteriumnetwork/node/market"
    25  )
    26  
    27  // Repository provides proposals from the DHT.
    28  type Repository struct {
    29  	stopOnce sync.Once
    30  	stopChan chan struct{}
    31  }
    32  
    33  // NewRepository constructs a new proposal repository (backed by the DHT).
    34  func NewRepository() *Repository {
    35  	return &Repository{
    36  		stopChan: make(chan struct{}),
    37  	}
    38  }
    39  
    40  // Proposal returns a single proposal by its ID.
    41  func (r *Repository) Proposal(id market.ProposalID) (*market.ServiceProposal, error) {
    42  	return nil, nil
    43  }
    44  
    45  // Proposals returns proposals matching the filter.
    46  func (r *Repository) Proposals(filter *proposal.Filter) ([]market.ServiceProposal, error) {
    47  	return []market.ServiceProposal{}, nil
    48  }
    49  
    50  // Countries returns proposals per country matching the filter.
    51  func (r *Repository) Countries(filter *proposal.Filter) (map[string]int, error) {
    52  	return nil, nil
    53  }
    54  
    55  // Start begins proposals synchronization to storage.
    56  func (r *Repository) Start() error {
    57  	return nil
    58  }
    59  
    60  // Stop ends proposals synchronization to storage.
    61  func (r *Repository) Stop() {
    62  	r.stopOnce.Do(func() {
    63  		close(r.stopChan)
    64  	})
    65  }