torrentfs

package
v1.9.54-beta Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: GPL-3.0, GPL-3.0 Imports: 42 Imported by: 0

README

fs

Include monitor, storage, fs, client modules

Documentation

Index

Constants

View Source
const (
	ProtocolName         = "nas"
	ProtocolVersion      = 1
	NumberOfMessageCodes = uint64(1048576)
	ProtocolVersionStr   = "1.0"
)

Variables

View Source
var BadFiles = map[string]bool{
	"3edcb8a793887d92db12d53124955681d5c20a43": true,
}
View Source
var DefaultConfig = Config{
	Port:            40401,
	DefaultTrackers: params.MainnetTrackers,
	BoostNodes:      params.TorrentBoostNodes,
	SyncMode:        "full",
	DisableUTP:      true,
	DisableDHT:      false,
	DisableTCP:      false,
	MaxSeedingNum:   1024,
	MaxActiveNum:    1024,
	FullSeed:        false,
	Boost:           false,
	Quiet:           true,
	UploadRate:      -1,
	DownloadRate:    -1,
}

DefaultConfig contains default settings for the storage.

View Source
var (
	ErrReadDataFromBoltDB = errors.New("bolt DB Read Error")
)
View Source
var GoodFiles = map[string]bool{
	"6dfc52c480a779dd3e2c9dce9772a5131ee1f4d7": true,
	"d31d1b0f588069aa6f36de5a7025a8d73a9a49f6": true,
	"9dbde0099a270c23d5dec0acb0ac537b0fb35c27": true,
	"3df6926c165db01330574fba8c23aa7b03311356": true,
	"c599d0fa8d816cf83c5018232453c6ae57db4ab3": true,
	"ae5a301ddfe1d4be9848adf8dde9f78d7ebba919": true,
	"6b3fd83c1fb05ae5145673218b53a1411460f3e0": true,
	"3101ac2c157ace6e4be72575758f7ba62b53e219": true,
	"b3d2f3d4f395924ca4cf5bd1843d49de043c959c": true,
	"ad3d77101866c0c7520aa41a5c41eee92500f809": true,
	"67b315aac2fbdbaf97ac8d40df0b9c435b65c4aa": true,
	"1fb97d6da1761ddc051446307bd915506359a17a": true,
	"b08e2c6103157ab99040cdc9ddfee05e93763f6c": true,
	"a83dc64f96494b6b6c4f5291196d0ddd2f1a0769": true,
	"3f1f6c007e8da3e16f7c3378a20a746e70f1c2b0": true,
	"1f1706fa53ce0723ba1c577418b222acbfa5a200": true,
	"ec6b1f5b5073c07dd35a53a3a13220c1a21e426d": true,
	"aea5584d0cd3865e90c80eace3bfcb062473d966": true,
	"9f222b4afa685d74d82e88972922cc9108a81791": true,
	"3145ad19228c1cd2d051314e72f26c1ce77b7f02": true,
	"04615009127a4829d32d22dddb45664a2aee8067": true,
}
View Source
var Str404NotFound []byte = []byte{} /* 178 elements not displayed */

Functions

This section is empty.

Types

type BlockContent added in v1.9.51

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

func (BlockContent) CalculateHash added in v1.9.51

func (t BlockContent) CalculateHash() ([]byte, error)

func (BlockContent) Equals added in v1.9.51

func (t BlockContent) Equals(other types.Content) (bool, error)

Equals tests for equality of two Contents

type BoostDataFetcher added in v1.0.0

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

func NewBoostDataFetcher added in v1.0.0

func NewBoostDataFetcher(nodes []string) *BoostDataFetcher

func (*BoostDataFetcher) GetFile added in v1.0.0

func (f *BoostDataFetcher) GetFile(ih, subpath string) ([]byte, error)

func (*BoostDataFetcher) GetTorrent added in v1.0.0

func (f *BoostDataFetcher) GetTorrent(ih string) ([]byte, error)

type CVMStorage added in v1.0.0

type CVMStorage interface {
	Available(infohash string, rawSize int64) (bool, error)
	GetFile(infohash string, path string) ([]byte, error)
	Stop() error
}

func GetStorage added in v1.0.0

func GetStorage() CVMStorage

type Config

type Config struct {
	// Host is the host interface on which to start the storage server. If this
	// field is empty, no storage will be started.
	Port            int      `toml:",omitempty"`
	DataDir         string   `toml:",omitempty"`
	RpcURI          string   `toml:",omitempty"`
	IpcPath         string   `toml:",omitempty"`
	DisableUTP      bool     `toml:",omitempty"`
	DisableTCP      bool     `toml:",omitempty"`
	DisableDHT      bool     `toml:",omitempty"`
	DefaultTrackers []string `toml:",omitempty"`
	BoostNodes      []string `toml:",omitempty"`
	SyncMode        string   `toml:",omitempty"`
	MaxSeedingNum   int      `toml:",omitempty"`
	MaxActiveNum    int      `toml:",omitempty"`
	FullSeed        bool
	Boost           bool
	Quiet           bool
	UploadRate      int
	DownloadRate    int
}

Config ...

func GetConfig added in v1.0.0

func GetConfig() *Config

type FileStorage

type FileStorage struct {
	CheckPoint            uint64
	LastListenBlockNumber uint64
	// contains filtered or unexported fields
}

func NewFileStorage

func NewFileStorage(config *Config) (*FileStorage, error)

func (*FileStorage) AddBlock

func (fs *FileStorage) AddBlock(b *types.Block) error

func (fs *FileStorage) addBlock(b *Block, record bool) error {

func (*FileStorage) Blocks added in v1.9.51

func (fs *FileStorage) Blocks() []*types.Block

func (*FileStorage) Close added in v1.0.0

func (fs *FileStorage) Close() error

func (*FileStorage) Files added in v1.9.51

func (fs *FileStorage) Files() []*types.FileInfo

func (*FileStorage) Flush added in v1.9.51

func (fs *FileStorage) Flush() error

func (*FileStorage) GetBlockByNumber added in v1.0.0

func (fs *FileStorage) GetBlockByNumber(blockNum uint64) *types.Block

func (*FileStorage) GetFileByAddr

func (fs *FileStorage) GetFileByAddr(addr common.Address) *types.FileInfo

func (*FileStorage) GetRootByNumber added in v1.9.51

func (fs *FileStorage) GetRootByNumber(number uint64) (root []byte)

func (*FileStorage) ID added in v1.9.51

func (fs *FileStorage) ID() uint64

func (*FileStorage) NewFileInfo added in v1.0.0

func (fs *FileStorage) NewFileInfo(Meta *types.FileMeta) *types.FileInfo

func (*FileStorage) Reset added in v1.9.51

func (fs *FileStorage) Reset() error

func (*FileStorage) Root added in v1.9.51

func (fs *FileStorage) Root() common.Hash

func (*FileStorage) Txs added in v1.9.51

func (fs *FileStorage) Txs() uint64

func (*FileStorage) UpdateFile added in v1.9.51

func (fs *FileStorage) UpdateFile(x *types.FileInfo) (uint64, bool, error)

func (fs *FileStorage) UpdateFile(x *FileInfo, b *Block, prog bool) (uint64, bool, error) {

func (*FileStorage) Version added in v1.9.51

func (fs *FileStorage) Version() string

type Monitor

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

Monitor observes the data changes on the blockchain and synchronizes. cl for ipc/rpc communication, dl for download manager, and fs for data storage.

func NewMonitor

func NewMonitor(flag *Config) (m *Monitor, e error)

NewMonitor creates a new instance of monitor. Once Ipcpath is settle, this method prefers to build socket connection in order to get higher communicating performance. IpcPath is unavailable on windows.

func (*Monitor) Start

func (m *Monitor) Start() error

Start ... start ListenOn on the rpc port of a blockchain full node

func (*Monitor) Stop added in v1.0.0

func (m *Monitor) Stop()

type Peer added in v1.9.54

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

func (*Peer) Start added in v1.9.54

func (p *Peer) Start() error

func (*Peer) Stop added in v1.9.54

func (p *Peer) Stop() error

type PublicTorrentAPI added in v1.9.54

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

func NewPublicTorrentAPI added in v1.9.54

func NewPublicTorrentAPI(w *TorrentFS) *PublicTorrentAPI

NewPublicWhisperAPI create a new RPC whisper service.

type Torrent

type Torrent struct {
	*torrent.Torrent
	// contains filtered or unexported fields
}

func (*Torrent) BoostOff added in v1.9.51

func (t *Torrent) BoostOff()

func (*Torrent) BytesLeft added in v1.0.0

func (t *Torrent) BytesLeft() int64

func (*Torrent) Finished added in v1.9.51

func (t *Torrent) Finished() bool

func (*Torrent) InfoHash added in v1.0.0

func (t *Torrent) InfoHash() string

func (*Torrent) IsAvailable added in v1.0.0

func (t *Torrent) IsAvailable() bool

func (*Torrent) Pause

func (t *Torrent) Pause()

func (*Torrent) Paused

func (t *Torrent) Paused() bool

func (*Torrent) Pending

func (t *Torrent) Pending() bool

func (*Torrent) ReloadFile added in v1.0.0

func (t *Torrent) ReloadFile(files []string, datas [][]byte, tm *TorrentManager)

func (*Torrent) ReloadTorrent added in v1.0.0

func (t *Torrent) ReloadTorrent(data []byte, tm *TorrentManager) error

func (*Torrent) Run

func (t *Torrent) Run(slot int)

func (*Torrent) Running

func (t *Torrent) Running() bool

func (*Torrent) Seed

func (t *Torrent) Seed()

func (*Torrent) SeedInQueue added in v1.0.0

func (t *Torrent) SeedInQueue()

func (*Torrent) Seeding

func (t *Torrent) Seeding() bool

func (*Torrent) WriteTorrent added in v1.0.0

func (t *Torrent) WriteTorrent() error

type TorrentFS

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

TorrentFS contains the torrent file system internals.

func New

func New(config *Config, commit string, cache, compress bool) (*TorrentFS, error)

New creates a new torrentfs instance with the given configuration.

func (*TorrentFS) APIs

func (tfs *TorrentFS) APIs() []rpc.API

APIs implements the node.Service interface.

func (*TorrentFS) Available added in v1.0.0

func (fs *TorrentFS) Available(infohash string, rawSize int64) (bool, error)

func (*TorrentFS) Config added in v1.0.0

func (t *TorrentFS) Config() *Config

func (*TorrentFS) GetFile added in v1.0.0

func (fs *TorrentFS) GetFile(infohash string, subpath string) ([]byte, error)

func (*TorrentFS) HandlePeer added in v1.9.54

func (tfs *TorrentFS) HandlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error

func (*TorrentFS) MaxMessageSize added in v1.9.54

func (tfs *TorrentFS) MaxMessageSize() uint64

func (*TorrentFS) Monitor added in v1.0.0

func (t *TorrentFS) Monitor() *Monitor

func (*TorrentFS) Protocols

func (tfs *TorrentFS) Protocols() []p2p.Protocol

Protocols implements the node.Service interface.

func (*TorrentFS) Start

func (tfs *TorrentFS) Start(server *p2p.Server) error

Start starts the data collection thread and the listening server of the dashboard. Implements the node.Service interface.

func (*TorrentFS) Stop

func (tfs *TorrentFS) Stop() error

Stop stops the data collection thread and the connection listener of the dashboard. Implements the node.Service interface.

func (*TorrentFS) Version added in v1.9.54

func (tfs *TorrentFS) Version() uint

type TorrentManager

type TorrentManager struct {
	DataDir    string
	TmpDataDir string
	// contains filtered or unexported fields
}

func NewTorrentManager

func NewTorrentManager(config *Config, fsid uint64) (error, *TorrentManager)

NewTorrentManager ...

func (*TorrentManager) AddInfoHash added in v1.0.0

func (tm *TorrentManager) AddInfoHash(ih metainfo.Hash, BytesRequested int64) *Torrent

func (*TorrentManager) AddTorrent

func (tm *TorrentManager) AddTorrent(filePath string, BytesRequested int64) *Torrent

func (*TorrentManager) Close added in v1.0.0

func (tm *TorrentManager) Close() error

func (*TorrentManager) CreateTorrent added in v1.0.0

func (tm *TorrentManager) CreateTorrent(t *torrent.Torrent, requested int64, status int, ih metainfo.Hash) *Torrent

func (*TorrentManager) GetLimitation added in v1.9.51

func (tm *TorrentManager) GetLimitation(value int64) int64

func (*TorrentManager) GetTorrent added in v1.0.0

func (tm *TorrentManager) GetTorrent(ih metainfo.Hash) *Torrent

func (*TorrentManager) SearchAndDownload added in v1.9.54

func (tm *TorrentManager) SearchAndDownload(hex string, request int64)

func (*TorrentManager) SetTorrent added in v1.0.0

func (tm *TorrentManager) SetTorrent(ih metainfo.Hash, torrent *Torrent)

func (*TorrentManager) SetTrackers

func (tm *TorrentManager) SetTrackers(trackers []string, disableTCP, boost bool)

func (*TorrentManager) Start added in v1.0.0

func (tm *TorrentManager) Start() error

func (*TorrentManager) UpdateDynamicTrackers added in v1.9.51

func (tm *TorrentManager) UpdateDynamicTrackers(trackers []string)

func (*TorrentManager) UpdateInfoHash added in v1.0.0

func (tm *TorrentManager) UpdateInfoHash(ih metainfo.Hash, BytesRequested int64)

UpdateInfoHash ...

func (*TorrentManager) UpdateTorrent

func (tm *TorrentManager) UpdateTorrent(input interface{}) error

type TorrentManagerAPI

type TorrentManagerAPI interface {
	Start() error
	Close() error
	//RemoveTorrent(metainfo.Hash) error
	UpdateTorrent(interface{}) error
	//UpdateDynamicTrackers(trackers []string)
	GetTorrent(ih metainfo.Hash) *Torrent
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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