store

package
v0.0.0-...-f6bc33c Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIndexEntryNotFound = errors.New("index entry not found")
View Source
var ErrSegmentNotFound = errors.New("segment not found")

Functions

func GenerateIdentityFromSeed

func GenerateIdentityFromSeed(seed []byte) (config.Identity, error)

Types

type Config

type Config struct {
	// Mandatory Setting, must be set
	PeerID  string `long:"peer-id" description:"the ipfs peer id of this node"`
	PrivKey string `long:"priv-key" description:"the ipfs priv key of this node"`

	// Optional Settings
	BootstrapPeers []string `` /* 145-byte string literal not displayed */
	SwarmPort      int      `long:"swarm-port" description:"ipfs swarm port"`

	// Without this there would be no way to isolate an environment if needed and process a given chains data (e.g. for dev)
	SwarmKeyOverride string `long:"swarm-key-override" description:"optional swarm key override, the default behaviour is to use the datanode's chain id'"`

	HistoryRetentionBlockSpan int64 `` /* 138-byte string literal not displayed */
}

func NewDefaultConfig

func NewDefaultConfig() Config

func (Config) GetSwarmKeySeed

func (c Config) GetSwarmKeySeed(log *logging.Logger, chainID string) string

type IpfsNode

type IpfsNode struct {
	IpfsId peer.ID
	Addr   ma.Multiaddr
}

func (IpfsNode) IpfsAddress

func (i IpfsNode) IpfsAddress() (ma.Multiaddr, error)

type LevelDbBackedIndex

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

func NewIndex

func NewIndex(dataDir string, log *logging.Logger) (*LevelDbBackedIndex, error)

func (LevelDbBackedIndex) Add

func (l LevelDbBackedIndex) Add(indexEntry segment.Full) error

func (LevelDbBackedIndex) Close

func (l LevelDbBackedIndex) Close() error

func (LevelDbBackedIndex) Get

func (l LevelDbBackedIndex) Get(height int64) (segment.Full, error)

func (LevelDbBackedIndex) GetHighestBlockHeightEntry

func (l LevelDbBackedIndex) GetHighestBlockHeightEntry() (segment.Full, error)

func (LevelDbBackedIndex) ListAllEntriesMostRecentFirst

func (l LevelDbBackedIndex) ListAllEntriesMostRecentFirst() (segment.Segments[segment.Full], error)

func (LevelDbBackedIndex) ListAllEntriesOldestFirst

func (l LevelDbBackedIndex) ListAllEntriesOldestFirst() (segment.Segments[segment.Full], error)

func (LevelDbBackedIndex) Remove

func (l LevelDbBackedIndex) Remove(indexEntry segment.Full) error

type PeerConnection

type PeerConnection struct {
	Local  IpfsNode
	Remote IpfsNode
}

type Store

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

func New

func New(ctx context.Context, log *logging.Logger, chainID string, cfg Config, networkHistoryHome string, maxMemoryPercent uint8,
) (*Store, error)

func (*Store) AddSnapshotData

func (p *Store) AddSnapshotData(ctx context.Context, s segment.Unpublished) (err error)

func (*Store) ConnectedToPeer

func (p *Store) ConnectedToPeer(peerIDStr string) (bool, error)

func (*Store) CopyHistorySegmentToFile

func (p *Store) CopyHistorySegmentToFile(ctx context.Context, historySegmentID string, targetFile string) error

func (*Store) FetchHistorySegment

func (p *Store) FetchHistorySegment(ctx context.Context, historySegmentID string) (segment.Full, error)

func (*Store) GetConnectedPeers

func (p *Store) GetConnectedPeers() []PeerConnection

func (*Store) GetHighestBlockHeightEntry

func (p *Store) GetHighestBlockHeightEntry() (segment.Full, error)

func (*Store) GetHistorySegmentReader

func (p *Store) GetHistorySegmentReader(ctx context.Context, historySegmentID string) (io.ReadSeekCloser, int64, error)

func (*Store) GetLocalNode

func (p *Store) GetLocalNode() (IpfsNode, error)

func (*Store) GetPeerID

func (p *Store) GetPeerID() string

func (*Store) GetPreviousHistorySegmentID

func (p *Store) GetPreviousHistorySegmentID(fromHeight int64) (string, error)

func (*Store) GetSegmentForHeight

func (p *Store) GetSegmentForHeight(toHeight int64) (segment.Full, error)

func (*Store) GetSwarmKey

func (p *Store) GetSwarmKey() string

func (*Store) GetSwarmKeySeed

func (p *Store) GetSwarmKeySeed() string

func (*Store) ListAllIndexEntriesMostRecentFirst

func (p *Store) ListAllIndexEntriesMostRecentFirst() (segment.Segments[segment.Full], error)

func (*Store) ListAllIndexEntriesOldestFirst

func (p *Store) ListAllIndexEntriesOldestFirst() (segment.Segments[segment.Full], error)

func (*Store) RemoveSegments

func (p *Store) RemoveSegments(ctx context.Context, segmentsToRemove []segment.Full) error

func (*Store) ResetIndex

func (p *Store) ResetIndex() error

func (*Store) StagedContiguousHistory

func (p *Store) StagedContiguousHistory(chunk segment.ContiguousHistory[segment.Full]) (segment.ContiguousHistory[segment.Staged], error)

func (*Store) StagedSegment

func (p *Store) StagedSegment(s segment.Full) (segment.Staged, error)

func (*Store) Stop

func (p *Store) Stop()

Jump to

Keyboard shortcuts

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