torrentfs

package
v1.9.56 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: GPL-3.0, GPL-3.0 Imports: 41 Imported by: 0

README

fs

Include monitor, storage, fs, client modules

Documentation

Overview

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Copyright 2020 The CortexTheseus Authors This file is part of the CortexTheseus library.

The CortexTheseus library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The CortexTheseus library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the CortexTheseus library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	ProtocolName         = "nas"
	ProtocolVersion      = uint64(1)
	NumberOfMessageCodes = uint64(0)
	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,
	Metrics:         true,
}

DefaultConfig contains default settings for the storage.

View Source
var (
	ErrReadDataFromBoltDB = errors.New("bolt DB Read Error")
)
View Source
var GoodFiles = map[string]bool{
	"aea5584d0cd3865e90c80eace3bfcb062473d966": true,
	"3145ad19228c1cd2d051314e72f26c1ce77b7f02": true,
	"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,
	"9f222b4afa685d74d82e88972922cc9108a81791": true,
	"04615009127a4829d32d22dddb45664a2aee8067": true,
}
View Source
var Str404NotFound []byte = []byte{} /* 178 elements not displayed */

Functions

func ProgressBar added in v1.9.55

func ProgressBar(x, y int64, desc string) string

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 ChainIndex added in v1.9.55

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

func NewChainIndex added in v1.9.55

func NewChainIndex(config *Config) (*ChainIndex, error)

func (*ChainIndex) AddBlock added in v1.9.55

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

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

func (*ChainIndex) Blocks added in v1.9.55

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

func (*ChainIndex) Close added in v1.9.55

func (fs *ChainIndex) Close() error

func (*ChainIndex) Files added in v1.9.55

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

func (*ChainIndex) Flush added in v1.9.55

func (fs *ChainIndex) Flush() error

func (*ChainIndex) GetBlockByNumber added in v1.9.55

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

func (*ChainIndex) GetFileByAddr added in v1.9.55

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

func (*ChainIndex) GetRootByNumber added in v1.9.55

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

func (*ChainIndex) ID added in v1.9.55

func (fs *ChainIndex) ID() uint64

func (*ChainIndex) Metrics added in v1.9.55

func (fs *ChainIndex) Metrics() time.Duration

func (*ChainIndex) NewFileInfo added in v1.9.55

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

func (*ChainIndex) Reset added in v1.9.55

func (fs *ChainIndex) Reset() error

func (*ChainIndex) Root added in v1.9.55

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

func (*ChainIndex) Txs added in v1.9.55

func (fs *ChainIndex) Txs() uint64

func (*ChainIndex) UpdateFile added in v1.9.55

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

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

func (*ChainIndex) Version added in v1.9.55

func (fs *ChainIndex) Version() string

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     `toml:",omitempty"`
	Boost           bool     `toml:",omitempty"`
	Quiet           bool     `toml:",omitempty"`
	UploadRate      int      `toml:",omitempty"`
	DownloadRate    int      `toml:",omitempty"`
	Metrics         bool     `toml:",omitempty"`
}

Config ...

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, cache, compress bool) (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) ID added in v1.9.54

func (peer *Peer) ID() []byte

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 StorageAPI added in v1.9.55

type StorageAPI interface {
	//Start() error
	//Close() error
	//RemoveTorrent(metainfo.Hash) error
	//UpdateTorrent(interface{}) error
	//UpdateDynamicTrackers(trackers []string)
	//GetTorrent(ih metainfo.Hash) *Torrent
	Available(ih string, raw int64) (bool, error)
	GetFile(infohash string, subpath string) ([]byte, error)
}

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) 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) 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

	Updates time.Duration
	// contains filtered or unexported fields
}

func NewTorrentManager

func NewTorrentManager(config *Config, fsid uint64, cache, compress bool) (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) Available added in v1.9.55

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

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) GetFile added in v1.9.55

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

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) Metrics added in v1.9.55

func (fs *TorrentManager) Metrics() time.Duration

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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