Documentation ¶
Index ¶
- Variables
- func Available(infohash string, rawSize int64) bool
- func Exist(infohash string) bool
- func ExistTorrent(infohash string) bool
- func GetFile(infohash string, path string) ([]byte, error)
- func GetMagnetURI(infohash metainfo.Hash) string
- func SetConnection(clientURI string) (*rpc.Client, error)
- type ActiveTorrentList
- type Block
- type BoostDataFetcher
- type CVMStorage
- type Config
- type FileInfo
- type FileMeta
- type FileStorage
- func (fs *FileStorage) AddCachedFile(x *FileInfo) error
- func (fs *FileStorage) AddFile(x *FileInfo) error
- func (fs *FileStorage) Close() error
- func (fs *FileStorage) GetBlockByNumber(blockNum uint64) *Block
- func (fs *FileStorage) GetFileByAddr(addr common.Address) *FileInfo
- func (fs *FileStorage) GetFileByNumber(index uint64) *FileInfo
- func (fs *FileStorage) NewFileInfo(Meta *FileMeta) *FileInfo
- func (fs *FileStorage) WriteBlock(b *Block) error
- func (fs *FileStorage) WriteFile(f *FileInfo) error
- type FlowControlMeta
- type GeneralMessage
- type HTTPMonitor
- type InfoHashFileSystem
- type Monitor
- type MutexCounter
- type Torrent
- func (t *Torrent) BytesLeft() int64
- func (t *Torrent) GetFile(subpath string) ([]byte, error)
- func (t *Torrent) HasTorrent() bool
- func (t *Torrent) InfoHash() string
- func (t *Torrent) IsAvailable() bool
- func (t *Torrent) Length() int64
- func (t *Torrent) NumPieces() int
- func (t *Torrent) Pause()
- func (t *Torrent) Paused() bool
- func (t *Torrent) Pending() bool
- func (t *Torrent) ReloadFile(files []string, datas [][]byte, tm *TorrentManager)
- func (t *Torrent) ReloadTorrent(data []byte, tm *TorrentManager)
- func (t *Torrent) Run()
- func (t *Torrent) Running() bool
- func (t *Torrent) Seed()
- func (t *Torrent) SeedInQueue()
- func (t *Torrent) Seeding() bool
- func (t *Torrent) WriteTorrent()
- type TorrentFS
- func (tfs *TorrentFS) APIs() []rpc.API
- func (fs TorrentFS) Available(infohash string, rawSize int64) bool
- func (t *TorrentFS) Config() *Config
- func (fs TorrentFS) GetFile(infohash string, subpath string) ([]byte, error)
- func (t *TorrentFS) Monitor() *Monitor
- func (tfs *TorrentFS) Protocols() []p2p.Protocol
- func (tfs *TorrentFS) Start(server *p2p.Server) error
- func (tfs *TorrentFS) Stop() error
- type TorrentManager
- func (tm *TorrentManager) AddInfoHash(ih metainfo.Hash, BytesRequested int64)
- func (tm *TorrentManager) AddTorrent(filePath string, BytesRequested int64)
- func (tm *TorrentManager) Close() error
- func (tm *TorrentManager) CreateTorrent(t *torrent.Torrent, requested int64, status int, ih metainfo.Hash) *Torrent
- func (tm *TorrentManager) DropMagnet(ih metainfo.Hash) bool
- func (tm *TorrentManager) GetTorrent(ih metainfo.Hash) *Torrent
- func (tm *TorrentManager) NewTorrent(input interface{}) error
- func (tm *TorrentManager) RemoveTorrent(input metainfo.Hash) error
- func (tm *TorrentManager) SetTorrent(ih metainfo.Hash, torrent *Torrent)
- func (tm *TorrentManager) SetTrackers(trackers []string)
- func (tm *TorrentManager) Start() error
- func (tm *TorrentManager) UpdateInfoHash(ih metainfo.Hash, BytesRequested int64)
- func (tm *TorrentManager) UpdateTorrent(input interface{}) error
- type TorrentManagerAPI
- type Transaction
- type TxReceipt
Constants ¶
This section is empty.
Variables ¶
var ( ErrBuildConn = errors.New("build internal-rpc connection failed") ErrGetLatestBlock = errors.New("get latest block failed") ErrNoRPCClient = errors.New("no rpc client") ErrBlockHash = errors.New("block or parent block hash invalid") )
Errors that are used throughout the Torrent API.
var DefaultConfig = Config{ Port: 30090, DefaultTrackers: params.MainnetTrackers, BoostNodes: params.TorrentBoostNodes, SyncMode: "full", DisableUTP: true, DisableDHT: false, MaxSeedingNum: 640, MaxActiveNum: 400, }
DefaultConfig contains default settings for the storage.
var (
ErrReadDataFromBoltDB = errors.New("Bolt DB Read Error")
)
var Str404NotFound []byte = []byte{} /* 178 elements not displayed */
var TorrentAPIAvailable sync.Mutex
Functions ¶
func ExistTorrent ¶ added in v1.0.0
func GetMagnetURI ¶ added in v1.0.0
Types ¶
type ActiveTorrentList ¶ added in v1.0.0
type ActiveTorrentList []*Torrent
func (ActiveTorrentList) Len ¶ added in v1.0.0
func (s ActiveTorrentList) Len() int
func (ActiveTorrentList) Less ¶ added in v1.0.0
func (s ActiveTorrentList) Less(i, j int) bool
func (ActiveTorrentList) Swap ¶ added in v1.0.0
func (s ActiveTorrentList) Swap(i, j int)
type Block ¶
type Block struct { Number uint64 `json:"number" gencodec:"required"` Hash common.Hash `json:"Hash" gencodec:"required"` ParentHash common.Hash `json:"parentHash" gencodec:"required"` Txs []Transaction `json:"Transactions" gencodec:"required"` }
gencodec -type Block -field-override blockMarshaling -out gen_block_json.go Block ... block struct
func (Block) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*Block) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
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 GetFile(infohash string, path string) ([]byte, error) }
var Torrentfs_handle CVMStorage
New creates a new dashboard instance with the given configuration.
func CreateStorage ¶ added in v1.0.0
func CreateStorage(storage_type string, config Config) CVMStorage
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"` DisableDHT bool `toml:",omitempty"` DefaultTrackers []string `toml:",omitempty"` BoostNodes []string `toml:",omitempty"` SyncMode string `toml:",omitempty"` MaxSeedingNum int `toml:",omitempty"` MaxActiveNum int `toml:",omitempty"` }
Config ...
func InitConfig ¶ added in v1.0.0
func InitConfig() *Config
type FileInfo ¶
type FileInfo struct { Meta *FileMeta // Transaction hash TxHash *common.Hash // Contract Address ContractAddr *common.Address LeftSize uint64 Index uint64 }
func (FileInfo) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*FileInfo) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
type FileMeta ¶
type FileMeta struct { InfoHash metainfo.Hash `json:"InfoHash" gencodec:"required"` Name string `json:"Name" gencodec:"required"` // The raw size of the file counted in bytes RawSize uint64 `json:"RawSize" gencodec:"required"` BlockNum uint64 `json:"BlockNum" gencodec:"required"` }
FileMeta ...
func (FileMeta) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*FileMeta) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
type FileStorage ¶
type FileStorage struct { LastListenBlockNumber uint64 LastFileIndex uint64 // contains filtered or unexported fields }
func NewFileStorage ¶
func NewFileStorage(config *Config) (*FileStorage, error)
func (*FileStorage) AddCachedFile ¶ added in v1.0.0
func (fs *FileStorage) AddCachedFile(x *FileInfo) error
func (*FileStorage) AddFile ¶
func (fs *FileStorage) AddFile(x *FileInfo) error
func (*FileStorage) Close ¶ added in v1.0.0
func (fs *FileStorage) Close() error
func (*FileStorage) GetBlockByNumber ¶ added in v1.0.0
func (fs *FileStorage) GetBlockByNumber(blockNum uint64) *Block
func (*FileStorage) GetFileByAddr ¶
func (fs *FileStorage) GetFileByAddr(addr common.Address) *FileInfo
func (*FileStorage) GetFileByNumber ¶ added in v1.0.0
func (fs *FileStorage) GetFileByNumber(index uint64) *FileInfo
func (*FileStorage) NewFileInfo ¶ added in v1.0.0
func (fs *FileStorage) NewFileInfo(Meta *FileMeta) *FileInfo
func (*FileStorage) WriteBlock ¶ added in v1.0.0
func (fs *FileStorage) WriteBlock(b *Block) error
func (*FileStorage) WriteFile ¶ added in v1.0.0
func (fs *FileStorage) WriteFile(f *FileInfo) error
type FlowControlMeta ¶
type GeneralMessage ¶
type HTTPMonitor ¶
type HTTPMonitor struct { Addr string // contains filtered or unexported fields }
HTTPMonitor ... Monitor for serving http services.
func NewHTTPMonitor ¶
func NewHTTPMonitor(addr string) *HTTPMonitor
NewHTTPMonitor ... Create a http monitor instance.
func (*HTTPMonitor) Finalize ¶
func (m *HTTPMonitor) Finalize()
func (*HTTPMonitor) Initilize ¶
func (m *HTTPMonitor) Initilize()
func (*HTTPMonitor) ServeHTTP ¶
func (m *HTTPMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*HTTPMonitor) Update ¶
func (m *HTTPMonitor) Update(path string, value interface{})
type InfoHashFileSystem ¶ added in v1.0.0
type InfoHashFileSystem struct {
DataDir 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 ¶
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.
type MutexCounter ¶ added in v1.0.0
type MutexCounter int32
func (*MutexCounter) Decrease ¶ added in v1.0.0
func (mc *MutexCounter) Decrease()
func (*MutexCounter) Increase ¶ added in v1.0.0
func (mc *MutexCounter) Increase()
func (*MutexCounter) IsZero ¶ added in v1.0.0
func (mc *MutexCounter) IsZero() bool
type Torrent ¶
Torrent ...
func (*Torrent) HasTorrent ¶ added in v1.0.0
func (*Torrent) IsAvailable ¶ added in v1.0.0
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)
func (*Torrent) SeedInQueue ¶ added in v1.0.0
func (t *Torrent) SeedInQueue()
func (*Torrent) WriteTorrent ¶ added in v1.0.0
func (t *Torrent) WriteTorrent()
type TorrentFS ¶
type TorrentFS struct {
// contains filtered or unexported fields
}
TorrentFS contains the torrent file system internals.
func GetTorrentInstance ¶ added in v1.0.0
func GetTorrentInstance() *TorrentFS
type TorrentManager ¶
type TorrentManager struct { DataDir string TmpDataDir string // contains filtered or unexported fields }
TorrentManager ...
var CurrentTorrentManager *TorrentManager = nil
func NewTorrentManager ¶
func NewTorrentManager(config *Config) *TorrentManager
NewTorrentManager ...
func (*TorrentManager) AddInfoHash ¶ added in v1.0.0
func (tm *TorrentManager) AddInfoHash(ih metainfo.Hash, BytesRequested int64)
func (*TorrentManager) AddTorrent ¶
func (tm *TorrentManager) AddTorrent(filePath string, BytesRequested int64)
func (*TorrentManager) Close ¶ added in v1.0.0
func (tm *TorrentManager) Close() error
func (*TorrentManager) CreateTorrent ¶ added in v1.0.0
func (*TorrentManager) DropMagnet ¶
func (tm *TorrentManager) DropMagnet(ih metainfo.Hash) bool
DropMagnet ...
func (*TorrentManager) GetTorrent ¶ added in v1.0.0
func (tm *TorrentManager) GetTorrent(ih metainfo.Hash) *Torrent
func (*TorrentManager) NewTorrent ¶
func (tm *TorrentManager) NewTorrent(input interface{}) error
func (*TorrentManager) RemoveTorrent ¶
func (tm *TorrentManager) RemoveTorrent(input metainfo.Hash) error
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)
func (*TorrentManager) Start ¶ added in v1.0.0
func (tm *TorrentManager) Start() error
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 Transaction ¶
type Transaction struct { Price *big.Int `json:"gasPrice" gencodec:"required"` Amount *big.Int `json:"value" gencodec:"required"` GasLimit uint64 `json:"gas" gencodec:"required"` Payload []byte `json:"input" gencodec:"required"` From *common.Address `json:"from" gencodec:"required"` Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation Hash *common.Hash `json:"hash" gencodec:"required"` Receipt *TxReceipt `json:"receipt" rlp:"nil"` }
Transaction ... Tx struct
func (Transaction) MarshalJSON ¶
func (t Transaction) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*Transaction) Parse ¶
func (t *Transaction) Parse() *FileMeta
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type TxReceipt ¶
type TxReceipt struct { // Contract Address ContractAddr *common.Address `json:"ContractAddress" gencodec:"required"` // Transaction Hash TxHash *common.Hash `json:"TransactionHash" gencodec:"required"` //Receipt *TxReceipt `json:"receipt" rlp:"nil"` GasUsed uint64 `json:"gasUsed" gencodec:"required"` Status uint64 `json:"status"` }
TxReceipt ...
func (TxReceipt) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*TxReceipt) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.