proto

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package proto is a generated GoMock package.

Index

Constants

View Source
const Version = 1

Version holds the number of the version of this protocol implementation.

Variables

View Source
var ErrMissingProtocolVersion = errors.New("missing protocol version")

ErrMissingProtocolVersion is used when a message is received without protocol version.

View Source
var ErrUnsupportedProtocolVersion = errors.New("unsupported protocol version")

ErrUnsupportedProtocolVersion is used when a message is received with an unsupported protocol version.

Functions

This section is empty.

Types

type HashSource

type HashSource interface {
	// Documents retrieves all documents in the HashSource.
	Documents() ([]model.DocumentDescriptor, error)
	// AddDocument adds a document.
	AddDocument(model.Document) error
	// HasContentsForDocument determines whether we have the contents for the specified document. If we have the contents,
	// true is returned. If we don't have the contents or don't know the hash at all, false is returned.
	HasContentsForDocument(hash model.Hash) (bool, error)
	// GetDocument retrieves the document given the specified hash. If the document is not known, ErrUnknownDocument is returned.
	GetDocument(hash model.Hash) (*model.DocumentDescriptor, error)
	// GetDocumentContents retrieves the contents of the document given the specified hash. If the document is not known or we don't have its contents, ErrMissingDocumentContents is returned.
	GetDocumentContents(hash model.Hash) (io.ReadCloser, error)
	// FindByContentsHash searches for documents which contents match the given SHA-1 hash.
	FindByContentsHash(hash model.Hash) ([]model.DocumentDescriptor, error)
	// AddDocumentWithContents adds a document including contents.
	AddDocumentWithContents(timestamp time.Time, documentType string, contents io.Reader) (*model.Document, error)
	// AddDocumentContents adds a contents to an already known document.
	AddDocumentContents(hash model.Hash, contents io.Reader) (*model.Document, error)
}

HashSource is an SPI (Service Provider Interface) defined by the Protocol layer which is used by Protocol. It exists to break the circular dependency between the Protocol and DocumentLog layer.

type MockHashSource

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

MockHashSource is a mock of HashSource interface

func NewMockHashSource

func NewMockHashSource(ctrl *gomock.Controller) *MockHashSource

NewMockHashSource creates a new mock instance

func (*MockHashSource) AddDocument

func (m *MockHashSource) AddDocument(arg0 model.Document) error

AddDocument mocks base method

func (*MockHashSource) AddDocumentContents

func (m *MockHashSource) AddDocumentContents(hash model.Hash, contents io.Reader) (*model.Document, error)

AddDocumentContents mocks base method

func (*MockHashSource) AddDocumentWithContents

func (m *MockHashSource) AddDocumentWithContents(timestamp time.Time, documentType string, contents io.Reader) (*model.Document, error)

AddDocumentWithContents mocks base method

func (*MockHashSource) Documents

func (m *MockHashSource) Documents() ([]model.DocumentDescriptor, error)

Documents mocks base method

func (*MockHashSource) EXPECT

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

func (*MockHashSource) GetDocument

func (m *MockHashSource) GetDocument(hash model.Hash) (*model.DocumentDescriptor, error)

GetDocument mocks base method

func (*MockHashSource) GetDocumentContents

func (m *MockHashSource) GetDocumentContents(hash model.Hash) (io.ReadCloser, error)

GetDocumentContents mocks base method

func (*MockHashSource) HasContentsForDocument

func (m *MockHashSource) HasContentsForDocument(hash model.Hash) (bool, error)

HasContentsForDocument mocks base method

type MockHashSourceMockRecorder

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

MockHashSourceMockRecorder is the mock recorder for MockHashSource

func (*MockHashSourceMockRecorder) AddDocument

func (mr *MockHashSourceMockRecorder) AddDocument(arg0 interface{}) *gomock.Call

AddDocument indicates an expected call of AddDocument

func (*MockHashSourceMockRecorder) AddDocumentContents

func (mr *MockHashSourceMockRecorder) AddDocumentContents(hash, contents interface{}) *gomock.Call

AddDocumentContents indicates an expected call of AddDocumentContents

func (*MockHashSourceMockRecorder) AddDocumentWithContents

func (mr *MockHashSourceMockRecorder) AddDocumentWithContents(timestamp, documentType, contents interface{}) *gomock.Call

AddDocumentWithContents indicates an expected call of AddDocumentWithContents

func (*MockHashSourceMockRecorder) Documents

func (mr *MockHashSourceMockRecorder) Documents() *gomock.Call

Documents indicates an expected call of Documents

func (*MockHashSourceMockRecorder) GetDocument

func (mr *MockHashSourceMockRecorder) GetDocument(hash interface{}) *gomock.Call

GetDocument indicates an expected call of GetDocument

func (*MockHashSourceMockRecorder) GetDocumentContents

func (mr *MockHashSourceMockRecorder) GetDocumentContents(hash interface{}) *gomock.Call

GetDocumentContents indicates an expected call of GetDocumentContents

func (*MockHashSourceMockRecorder) HasContentsForDocument

func (mr *MockHashSourceMockRecorder) HasContentsForDocument(hash interface{}) *gomock.Call

HasContentsForDocument indicates an expected call of HasContentsForDocument

type MockPeerHashQueue

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

MockPeerHashQueue is a mock of PeerHashQueue interface

func NewMockPeerHashQueue

func NewMockPeerHashQueue(ctrl *gomock.Controller) *MockPeerHashQueue

NewMockPeerHashQueue creates a new mock instance

func (*MockPeerHashQueue) EXPECT

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

func (*MockPeerHashQueue) Get

func (m *MockPeerHashQueue) Get() *PeerHash

Get mocks base method

type MockPeerHashQueueMockRecorder

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

MockPeerHashQueueMockRecorder is the mock recorder for MockPeerHashQueue

func (*MockPeerHashQueueMockRecorder) Get

Get indicates an expected call of Get

type MockProtocol

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

MockProtocol is a mock of Protocol interface

func NewMockProtocol

func NewMockProtocol(ctrl *gomock.Controller) *MockProtocol

NewMockProtocol creates a new mock instance

func (*MockProtocol) AdvertConsistencyHash

func (m *MockProtocol) AdvertConsistencyHash(hash model.Hash)

AdvertConsistencyHash mocks base method

func (*MockProtocol) Configure

func (m *MockProtocol) Configure(p2pNetwork p2p.P2PNetwork, source HashSource)

Configure mocks base method

func (*MockProtocol) EXPECT

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

func (*MockProtocol) QueryHashList

func (m *MockProtocol) QueryHashList(peer model.PeerID) error

QueryHashList mocks base method

func (*MockProtocol) ReceivedConsistencyHashes

func (m *MockProtocol) ReceivedConsistencyHashes() PeerHashQueue

ReceivedConsistencyHashes mocks base method

func (*MockProtocol) Start

func (m *MockProtocol) Start()

Start mocks base method

func (*MockProtocol) Statistics

func (m *MockProtocol) Statistics() []stats.Statistic

Statistics mocks base method

func (*MockProtocol) Stop

func (m *MockProtocol) Stop()

Stop mocks base method

type MockProtocolMockRecorder

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

MockProtocolMockRecorder is the mock recorder for MockProtocol

func (*MockProtocolMockRecorder) AdvertConsistencyHash

func (mr *MockProtocolMockRecorder) AdvertConsistencyHash(hash interface{}) *gomock.Call

AdvertConsistencyHash indicates an expected call of AdvertConsistencyHash

func (*MockProtocolMockRecorder) Configure

func (mr *MockProtocolMockRecorder) Configure(p2pNetwork, source interface{}) *gomock.Call

Configure indicates an expected call of Configure

func (*MockProtocolMockRecorder) QueryHashList

func (mr *MockProtocolMockRecorder) QueryHashList(peer interface{}) *gomock.Call

QueryHashList indicates an expected call of QueryHashList

func (*MockProtocolMockRecorder) ReceivedConsistencyHashes

func (mr *MockProtocolMockRecorder) ReceivedConsistencyHashes() *gomock.Call

ReceivedConsistencyHashes indicates an expected call of ReceivedConsistencyHashes

func (*MockProtocolMockRecorder) Start

func (mr *MockProtocolMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start

func (*MockProtocolMockRecorder) Statistics

func (mr *MockProtocolMockRecorder) Statistics() *gomock.Call

Statistics indicates an expected call of Statistics

func (*MockProtocolMockRecorder) Stop

func (mr *MockProtocolMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop

type PeerHash

type PeerHash struct {
	// Peer holds the ID of the peer we got the hash from.
	Peer model.PeerID
	// Hash holds the hash we received.
	Hash model.Hash
}

PeerHash describes a hash we received from a peer.

type PeerHashQueue

type PeerHashQueue interface {
	// Get blocks until there's an PeerHash available and returns it.
	Get() *PeerHash
}

PeerHashQueue is a queue which contains the hashes adverted by our peers. It's a FILO queue, since the hashes represent append-only data structures which means the last one is most recent.

type Protocol

type Protocol interface {
	stats.StatsProvider
	// Configure configures the Protocol. Must be called before Start().
	Configure(p2pNetwork p2p.P2PNetwork, source HashSource)
	// Starts the Protocol (sending and receiving of messages).
	Start()
	// Stops the Protocol.
	Stop()
	// ReceivedConsistencyHashes returns a queue with consistency hashes we received from our peers. It must be drained, because when its buffer is full the producer is blocked.
	ReceivedConsistencyHashes() PeerHashQueue
	// AdvertConsistencyHash is used to tell our peers of our last consistency hash, so they can match their DocumentLog with ours (so replication can occur).
	AdvertConsistencyHash(hash model.Hash)
	// QueryHashList is used to query a peer for their document hash list.
	QueryHashList(peer model.PeerID) error
}

Protocol defines the API for the protocol layer, which is a high-level interface to interact with the network. It responds from (peer) messages received through the P2P layer.

func NewProtocol

func NewProtocol() Protocol

Jump to

Keyboard shortcuts

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