Documentation ¶
Index ¶
- Variables
- func SetConnection(clientURI string) (*rpc.Client, error)
- type Block
- type Config
- type FileInfo
- type FileMeta
- type FileStorage
- type FlowControlMeta
- type GeneralMessage
- type HTTPMonitor
- type Monitor
- type MutexCounter
- type Torrent
- type TorrentFS
- type TorrentManager
- func (tm *TorrentManager) AddMagnet(uri string)
- func (tm *TorrentManager) AddTorrent(filePath string)
- func (tm *TorrentManager) Close() error
- func (tm *TorrentManager) DropMagnet(uri string) bool
- func (tm *TorrentManager) NewTorrent(input string) error
- func (tm *TorrentManager) RemoveTorrent(input string) error
- func (tm *TorrentManager) SetTrackers(trackers []string)
- func (tm *TorrentManager) Start() error
- func (tm *TorrentManager) UpdateMagnet(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{ Host: "localhost", Port: 8085, DefaultTrackers: "http://torrent.cortexlabs.ai:5008/announce", SyncMode: "full", TestMode: false, }
DefaultConfig contains default settings for the storage.
var (
ErrReadDataFromBoltDB = errors.New("Bolt DB Read Error")
)
Functions ¶
Types ¶
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 Config ¶
type Config struct { DataDir string `toml:",omitempty"` RpcURI string `toml:",omitempty"` IpcPath string `toml:",omitempty"` // Host is the host interface on which to start the storage server. If this // field is empty, no storage will be started. Host string `toml:",omitempty"` // Port is the TCP port number on which to start the storage server. The // default zero value is/ valid and will pick a port number randomly. Port int `toml:",omitempty"` DefaultTrackers string `toml:",omitempty"` SyncMode string `toml:",omitempty"` TestMode bool `toml:",omitempty"` }
Config ...
type FileInfo ¶
type FileInfo struct { Meta *FileMeta // Transaction hash TxHash *common.Hash // Contract Address ContractAddr *common.Address LeftSize uint64 }
func NewFileInfo ¶
func (FileInfo) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*FileInfo) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
type FileMeta ¶
type FileMeta struct { // Author Address AuthorAddr *common.Address // Download InfoHash, should be in magnetURI format URI string // The raw size of the file counted in bytes RawSize uint64 BlockNum uint64 }
FileMeta ...
func (FileMeta) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*FileMeta) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
type FileStorage ¶
type FileStorage struct { LastListenBlockNumber uint64 // contains filtered or unexported fields }
func NewFileStorage ¶
func NewFileStorage(config *Config) (*FileStorage, 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) WriteBlock ¶ added in v1.0.0
func (fs *FileStorage) WriteBlock(b *Block) 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 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 TorrentFS ¶
type TorrentFS struct {
// contains filtered or unexported fields
}
TorrentFS contains the torrent file system internals.
type TorrentManager ¶
type TorrentManager struct { DataDir string TmpDataDir string // contains filtered or unexported fields }
TorrentManager ...
func NewTorrentManager ¶
func NewTorrentManager(config *Config) *TorrentManager
NewTorrentManager ...
func (*TorrentManager) AddTorrent ¶
func (tm *TorrentManager) AddTorrent(filePath string)
func (*TorrentManager) Close ¶ added in v1.0.0
func (tm *TorrentManager) Close() error
func (*TorrentManager) DropMagnet ¶
func (tm *TorrentManager) DropMagnet(uri string) bool
DropMagnet ...
func (*TorrentManager) NewTorrent ¶
func (tm *TorrentManager) NewTorrent(input string) error
func (*TorrentManager) RemoveTorrent ¶
func (tm *TorrentManager) RemoveTorrent(input string) error
func (*TorrentManager) SetTrackers ¶
func (tm *TorrentManager) SetTrackers(trackers []string)
func (*TorrentManager) Start ¶ added in v1.0.0
func (tm *TorrentManager) Start() error
func (*TorrentManager) UpdateMagnet ¶
func (tm *TorrentManager) UpdateMagnet(ih metainfo.Hash, BytesRequested int64)
UpdateMagnet ...
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"` }
TxReceipt ...
func (TxReceipt) MarshalJSON ¶
MarshalJSON marshals as JSON.
func (*TxReceipt) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.