Documentation
¶
Index ¶
- Variables
- func NewBoltDB(filePath string) *boltDBClient
- type Block
- type Config
- type FileInfo
- type FileMeta
- type FileStorage
- func (fs *FileStorage) AddBlock(b *Block) error
- func (fs *FileStorage) AddFile(x *FileInfo) error
- func (fs *FileStorage) GetBlock(blockNum uint64) *Block
- func (fs *FileStorage) GetFileByAddr(addr common.Address) *FileInfo
- func (fs *FileStorage) GetFileByInfoHash(ih metainfo.Hash) *FileInfo
- func (fs *FileStorage) HasBlock(blockNum uint64) bool
- func (fs *FileStorage) IsBlockChecked(blockNum uint64) bool
- func (fs *FileStorage) SetBlockChecked(blockNum uint64) error
- type FlowControlMeta
- type GeneralMessage
- type HTTPMonitor
- type Monitor
- type Torrent
- type TorrentFS
- type TorrentManager
- func (tm *TorrentManager) AddMagnet(uri string)
- func (tm *TorrentManager) AddTorrent(filePath string)
- func (tm *TorrentManager) CloseAll(input struct{}) 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) 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") ErrNoDownloadManager = errors.New("no download manager") )
Errors that are used throughout the Torrent API.
var DefaultConfig = Config{ Host: "localhost", Port: 8085, DefaultTrackers: "http://47.52.39.170:5008/announce", SyncMode: "full", TestMode: false, }
DefaultConfig contains default settings for the storage.
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
}
FileInfo ...
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 {
LatestBlockNumber uint64
// contains filtered or unexported fields
}
FileStorage ...
func (*FileStorage) GetFileByAddr ¶
func (fs *FileStorage) GetFileByAddr(addr common.Address) *FileInfo
GetFileByAddr ...
func (*FileStorage) GetFileByInfoHash ¶
func (fs *FileStorage) GetFileByInfoHash(ih metainfo.Hash) *FileInfo
GetFileByInfoHash ...
func (*FileStorage) IsBlockChecked ¶
func (fs *FileStorage) IsBlockChecked(blockNum uint64) bool
IsBlockChecked ...
func (*FileStorage) SetBlockChecked ¶
func (fs *FileStorage) SetBlockChecked(blockNum uint64) error
SetBlockChecked ...
type FlowControlMeta ¶
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.
func (*Monitor) SetConnection ¶
SetConnection method builds connection to remote or local communicator.
func (*Monitor) SetDownloader ¶
func (m *Monitor) SetDownloader(dl TorrentManagerAPI) error
SetDownloader ...
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)
AddTorrent ...
func (*TorrentManager) CloseAll ¶
func (tm *TorrentManager) CloseAll(input struct{}) 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)
SetTrackers ...
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) 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.