offers

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2023 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package offers is a generated GoMock package.

Package offers provides management of the offers being made by a swapd instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	PutOffer(offer *types.Offer) error
	DeleteOffer(id types.Hash) error
	GetOffer(id types.Hash) (*types.Offer, error)
	GetAllOffers() ([]*types.Offer, error)
	ClearAllOffers() error
}

Database contains the db functions used by the offer manager.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager synchronises access to the offers map.

func NewManager

func NewManager(dataDir string, db Database) (*Manager, error)

NewManager creates a new offer manager. The passed in dataDir is the directory where the recovery file is for each individual swap is stored.

func (*Manager) AddOffer

func (m *Manager) AddOffer(
	offer *types.Offer,
	useRelayer bool,
) (*types.OfferExtra, error)

AddOffer adds a new offer to the manager and returns its OffersExtra data

func (*Manager) ClearAllOffers

func (m *Manager) ClearAllOffers() error

ClearAllOffers clears all offers.

func (*Manager) ClearOfferIDs

func (m *Manager) ClearOfferIDs(ids []types.Hash) error

ClearOfferIDs clears the passed in offer IDs if they exist.

func (*Manager) DeleteOffer

func (m *Manager) DeleteOffer(id types.Hash) error

DeleteOffer deletes the offer with the given ID, if it exists. No error is returned if there was no matching offer to delete.

func (*Manager) GetOffer

func (m *Manager) GetOffer(id types.Hash) (*types.Offer, *types.OfferExtra, error)

GetOffer returns the offer data structures for the passed ID or nil for both values if the offer ID is not found.

func (*Manager) GetOffers

func (m *Manager) GetOffers() []*types.Offer

GetOffers returns all current offers. The returned slice is in random order and will not be the same from one invocation to the next.

func (*Manager) NumOffers

func (m *Manager) NumOffers() int

NumOffers returns the current number of offers.

func (*Manager) TakeOffer

func (m *Manager) TakeOffer(id types.Hash) (*types.Offer, *types.OfferExtra, error)

TakeOffer returns any offer with the matching id and removes the offer from the cache, but leaves it in the database (unlike the Clear/DeleteOffer methods.) Nil for both values is returned when the passed offer id is not currently managed.

type MockDatabase

type MockDatabase struct {
	// contains filtered or unexported fields
}

MockDatabase is a mock of Database interface.

func NewMockDatabase

func NewMockDatabase(ctrl *gomock.Controller) *MockDatabase

NewMockDatabase creates a new mock instance.

func (*MockDatabase) ClearAllOffers

func (m *MockDatabase) ClearAllOffers() error

ClearAllOffers mocks base method.

func (*MockDatabase) DeleteOffer

func (m *MockDatabase) DeleteOffer(arg0 common.Hash) error

DeleteOffer mocks base method.

func (*MockDatabase) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDatabase) GetAllOffers

func (m *MockDatabase) GetAllOffers() ([]*types.Offer, error)

GetAllOffers mocks base method.

func (*MockDatabase) GetOffer

func (m *MockDatabase) GetOffer(arg0 common.Hash) (*types.Offer, error)

GetOffer mocks base method.

func (*MockDatabase) PutOffer

func (m *MockDatabase) PutOffer(arg0 *types.Offer) error

PutOffer mocks base method.

type MockDatabaseMockRecorder

type MockDatabaseMockRecorder struct {
	// contains filtered or unexported fields
}

MockDatabaseMockRecorder is the mock recorder for MockDatabase.

func (*MockDatabaseMockRecorder) ClearAllOffers

func (mr *MockDatabaseMockRecorder) ClearAllOffers() *gomock.Call

ClearAllOffers indicates an expected call of ClearAllOffers.

func (*MockDatabaseMockRecorder) DeleteOffer

func (mr *MockDatabaseMockRecorder) DeleteOffer(arg0 interface{}) *gomock.Call

DeleteOffer indicates an expected call of DeleteOffer.

func (*MockDatabaseMockRecorder) GetAllOffers

func (mr *MockDatabaseMockRecorder) GetAllOffers() *gomock.Call

GetAllOffers indicates an expected call of GetAllOffers.

func (*MockDatabaseMockRecorder) GetOffer

func (mr *MockDatabaseMockRecorder) GetOffer(arg0 interface{}) *gomock.Call

GetOffer indicates an expected call of GetOffer.

func (*MockDatabaseMockRecorder) PutOffer

func (mr *MockDatabaseMockRecorder) PutOffer(arg0 interface{}) *gomock.Call

PutOffer indicates an expected call of PutOffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL