Documentation ¶
Overview ¶
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
Index ¶
- Constants
- Variables
- func BytesToU64(data []byte) uint64
- func IsZeroAddr(addr Address) bool
- func NewHasherStore(chunkStore ChunkStore, hashFunc SwarmHasher, toEncrypt bool) *hasherStore
- func Proximity(one, other []byte) (ret int)
- func PutChunks(store *LocalStore, chunks ...*Chunk)
- func U64ToBytes(val uint64) []byte
- type Address
- func PyramidAppend(ctx context.Context, addr Address, reader io.Reader, putter Putter, ...) (Address, func(context.Context) error, error)
- func PyramidSplit(ctx context.Context, reader io.Reader, putter Putter, getter Getter) (Address, func(context.Context) error, error)
- func TreeSplit(ctx context.Context, data io.Reader, size int64, putter Putter) (k Address, wait func(context.Context) error, err error)
- type AddressCollection
- type Chunk
- type ChunkData
- type ChunkStore
- type ChunkValidator
- type ChunkerParams
- type ContentAddressValidator
- type DBAPI
- func (d *DBAPI) CurrentBucketStorageIndex(po uint8) uint64
- func (d *DBAPI) Get(ctx context.Context, addr Address) (*Chunk, error)
- func (d *DBAPI) GetOrCreateRequest(ctx context.Context, addr Address) (*Chunk, bool)
- func (d *DBAPI) Iterator(from uint64, to uint64, po uint8, f func(Address, uint64) bool) error
- func (d *DBAPI) Put(ctx context.Context, chunk *Chunk)
- type FileStore
- type FileStoreParams
- type Getter
- type HashWithLength
- type Hasher
- type JoinerParams
- type LDBDatabase
- func (db *LDBDatabase) Close()
- func (db *LDBDatabase) Delete(key []byte) error
- func (db *LDBDatabase) Get(key []byte) ([]byte, error)
- func (db *LDBDatabase) LastKnownTD() []byte
- func (db *LDBDatabase) NewIterator() iterator.Iterator
- func (db *LDBDatabase) Put(key []byte, value []byte)
- func (db *LDBDatabase) Write(batch *leveldb.Batch) error
- type LDBStore
- func (s *LDBStore) Cleanup()
- func (s *LDBStore) Close()
- func (s *LDBStore) CurrentBucketStorageIndex(po uint8) uint64
- func (s *LDBStore) CurrentStorageIndex() uint64
- func (s *LDBStore) Export(out io.Writer) (int64, error)
- func (s *LDBStore) Get(ctx context.Context, addr Address) (chunk *Chunk, err error)
- func (s *LDBStore) Import(in io.Reader) (int64, error)
- func (s *LDBStore) Put(ctx context.Context, chunk *Chunk)
- func (s *LDBStore) ReIndex()
- func (s *LDBStore) Size() uint64
- func (s *LDBStore) SyncIterator(since uint64, until uint64, po uint8, f func(Address, uint64) bool) error
- type LDBStoreParams
- type LazyChunkReader
- func (r *LazyChunkReader) Context() context.Context
- func (r *LazyChunkReader) Read(b []byte) (read int, err error)
- func (r *LazyChunkReader) ReadAt(b []byte, off int64) (read int, err error)
- func (r *LazyChunkReader) Seek(offset int64, whence int) (int64, error)
- func (r *LazyChunkReader) Size(ctx context.Context, quitC chan bool) (n int64, err error)
- type LazySectionReader
- type LazyTestSectionReader
- type LocalStore
- func (ls *LocalStore) Close()
- func (ls *LocalStore) Get(ctx context.Context, addr Address) (chunk *Chunk, err error)
- func (ls *LocalStore) GetOrCreateRequest(ctx context.Context, addr Address) (chunk *Chunk, created bool)
- func (ls *LocalStore) Put(ctx context.Context, chunk *Chunk)
- func (ls *LocalStore) RequestsCacheLen() int
- type LocalStoreParams
- type MapChunkStore
- type MemStore
- type NetStore
- type Peer
- type Putter
- type PyramidChunker
- func (pc *PyramidChunker) Append(ctx context.Context) (k Address, wait func(context.Context) error, err error)
- func (pc *PyramidChunker) Join(addr Address, getter Getter, depth int) LazySectionReader
- func (pc *PyramidChunker) Split(ctx context.Context) (k Address, wait func(context.Context) error, err error)
- type PyramidSplitterParams
- type Reference
- type SplitterParams
- type StoreParams
- type SwarmHash
- type SwarmHasher
- type TreeChunker
- type TreeEntry
- type TreeSplitterParams
Constants ¶
View Source
const ( ErrInit = iota ErrNotFound ErrIO ErrInvalidValue ErrDataOverflow ErrNothingToReturn ErrCorruptData ErrInvalidSignature ErrNotSynced ErrPeriodDepth ErrCnt )
View Source
const ( DataChunk = 0 TreeChunk = 1 )
View Source
const ( BMTHash = "BMT" SHA3Hash = "SHA3" // DefaultHash = BMTHash )
View Source
const (
ChunkProcessors = 8
)
View Source
const KeyLength = 32
View Source
const MaxPO = 16
Variables ¶
View Source
var ( ErrChunkNotFound = errors.New("chunk not found") ErrFetching = errors.New("chunk still fetching") ErrChunkInvalid = errors.New("invalid chunk") ErrChunkForward = errors.New("cannot forward") ErrChunkTimeout = errors.New("timeout") )
View Source
var ZeroAddr = Address(common.Hash{}.Bytes())
Functions ¶
func BytesToU64 ¶
func IsZeroAddr ¶
func NewHasherStore ¶
func NewHasherStore(chunkStore ChunkStore, hashFunc SwarmHasher, toEncrypt bool) *hasherStore
func PutChunks ¶
func PutChunks(store *LocalStore, chunks ...*Chunk)
func U64ToBytes ¶
Types ¶
type Address ¶
type Address []byte
func PyramidAppend ¶
func PyramidSplit ¶
func (Address) MarshalJSON ¶
func (*Address) UnmarshalJSON ¶
type AddressCollection ¶
type AddressCollection []Address
func NewAddressCollection ¶
func NewAddressCollection(l int) AddressCollection
func (AddressCollection) Len ¶
func (c AddressCollection) Len() int
func (AddressCollection) Less ¶
func (c AddressCollection) Less(i, j int) bool
func (AddressCollection) Swap ¶
func (c AddressCollection) Swap(i, j int)
type Chunk ¶
type Chunk struct { Addr Address // SData []byte // Size int64 // C chan bool // ReqC chan bool // // contains filtered or unexported fields }
func GenerateRandomChunk ¶
func GenerateRandomChunks ¶
func (*Chunk) GetErrored ¶
func (*Chunk) SetErrored ¶
func (*Chunk) WaitToStore ¶
type ChunkStore ¶
type ChunkValidator ¶
type ChunkerParams ¶
type ChunkerParams struct {
// contains filtered or unexported fields
}
type ContentAddressValidator ¶
type ContentAddressValidator struct {
Hasher SwarmHasher
}
func NewContentAddressValidator ¶
func NewContentAddressValidator(hasher SwarmHasher) *ContentAddressValidator
type DBAPI ¶
type DBAPI struct {
// contains filtered or unexported fields
}
func NewDBAPI ¶
func NewDBAPI(loc *LocalStore) *DBAPI
func (*DBAPI) CurrentBucketStorageIndex ¶
func (*DBAPI) GetOrCreateRequest ¶
type FileStore ¶
type FileStore struct { ChunkStore // contains filtered or unexported fields }
func NewFileStore ¶
func NewFileStore(store ChunkStore, params *FileStoreParams) *FileStore
type FileStoreParams ¶
type FileStoreParams struct {
Hash string
}
func NewFileStoreParams ¶
func NewFileStoreParams() *FileStoreParams
type HashWithLength ¶
func (*HashWithLength) ResetWithLength ¶
func (h *HashWithLength) ResetWithLength(length []byte)
type JoinerParams ¶
type JoinerParams struct { ChunkerParams // contains filtered or unexported fields }
type LDBDatabase ¶
type LDBDatabase struct {
// contains filtered or unexported fields
}
func NewLDBDatabase ¶
func NewLDBDatabase(file string) (*LDBDatabase, error)
func (*LDBDatabase) Close ¶
func (db *LDBDatabase) Close()
func (*LDBDatabase) Delete ¶
func (db *LDBDatabase) Delete(key []byte) error
func (*LDBDatabase) LastKnownTD ¶
func (db *LDBDatabase) LastKnownTD() []byte
func (*LDBDatabase) NewIterator ¶
func (db *LDBDatabase) NewIterator() iterator.Iterator
func (*LDBDatabase) Put ¶
func (db *LDBDatabase) Put(key []byte, value []byte)
type LDBStore ¶
type LDBStore struct {
// contains filtered or unexported fields
}
func NewLDBStore ¶
func NewLDBStore(params *LDBStoreParams) (s *LDBStore, err error)
func NewMockDbStore ¶
func NewMockDbStore(params *LDBStoreParams, mockStore *mock.NodeStore) (s *LDBStore, err error)
func (*LDBStore) CurrentBucketStorageIndex ¶
func (*LDBStore) CurrentStorageIndex ¶
type LDBStoreParams ¶
type LDBStoreParams struct { *StoreParams Path string Po func(Address) uint8 }
func NewLDBStoreParams ¶
func NewLDBStoreParams(storeparams *StoreParams, path string) *LDBStoreParams
type LazyChunkReader ¶
func (*LazyChunkReader) Context ¶
func (r *LazyChunkReader) Context() context.Context
func (*LazyChunkReader) ReadAt ¶
func (r *LazyChunkReader) ReadAt(b []byte, off int64) (read int, err error)
type LazySectionReader ¶
type LazyTestSectionReader ¶
type LazyTestSectionReader struct {
*io.SectionReader
}
func (*LazyTestSectionReader) Context ¶
func (r *LazyTestSectionReader) Context() context.Context
type LocalStore ¶
type LocalStore struct { Validators []ChunkValidator DbStore *LDBStore // contains filtered or unexported fields }
func NewLocalStore ¶
func NewLocalStore(params *LocalStoreParams, mockStore *mock.NodeStore) (*LocalStore, error)
func NewTestLocalStoreForAddr ¶
func NewTestLocalStoreForAddr(params *LocalStoreParams) (*LocalStore, error)
func (*LocalStore) Close ¶
func (ls *LocalStore) Close()
func (*LocalStore) GetOrCreateRequest ¶
func (*LocalStore) RequestsCacheLen ¶
func (ls *LocalStore) RequestsCacheLen() int
type LocalStoreParams ¶
type LocalStoreParams struct { *StoreParams ChunkDbPath string Validators []ChunkValidator `toml:"-"` }
func NewDefaultLocalStoreParams ¶
func NewDefaultLocalStoreParams() *LocalStoreParams
func (*LocalStoreParams) Init ¶
func (p *LocalStoreParams) Init(path string)
type MapChunkStore ¶
type MapChunkStore struct {
// contains filtered or unexported fields
}
func NewMapChunkStore ¶
func NewMapChunkStore() *MapChunkStore
func (*MapChunkStore) Close ¶
func (m *MapChunkStore) Close()
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
func NewMemStore ¶
func NewMemStore(params *StoreParams, _ *LDBStore) (m *MemStore)
type NetStore ¶
type NetStore struct {
// contains filtered or unexported fields
}
func NewNetStore ¶
func (*NetStore) GetWithTimeout ¶
type PyramidChunker ¶
type PyramidChunker struct {
// contains filtered or unexported fields
}
func NewPyramidSplitter ¶
func NewPyramidSplitter(params *PyramidSplitterParams) (pc *PyramidChunker)
func (*PyramidChunker) Join ¶
func (pc *PyramidChunker) Join(addr Address, getter Getter, depth int) LazySectionReader
type PyramidSplitterParams ¶
type PyramidSplitterParams struct { SplitterParams // contains filtered or unexported fields }
type SplitterParams ¶
type SplitterParams struct { ChunkerParams // contains filtered or unexported fields }
type StoreParams ¶
type StoreParams struct { Hash SwarmHasher `toml:"-"` DbCapacity uint64 CacheCapacity uint ChunkRequestsCacheCapacity uint BaseKey []byte }
func NewDefaultStoreParams ¶
func NewDefaultStoreParams() *StoreParams
func NewStoreParams ¶
func NewStoreParams(ldbCap uint64, cacheCap uint, requestsCap uint, hash SwarmHasher, basekey []byte) *StoreParams
type SwarmHasher ¶
type SwarmHasher func() SwarmHash
func MakeHashFunc ¶
func MakeHashFunc(hash string) SwarmHasher
type TreeChunker ¶
type TreeChunker struct {
// contains filtered or unexported fields
}
func NewTreeJoiner ¶
func NewTreeJoiner(params *JoinerParams) *TreeChunker
func NewTreeSplitter ¶
func NewTreeSplitter(params *TreeSplitterParams) *TreeChunker
func (*TreeChunker) Append ¶
func (tc *TreeChunker) Append() (Address, func(), error)
func (*TreeChunker) Join ¶
func (tc *TreeChunker) Join(ctx context.Context) *LazyChunkReader
type TreeEntry ¶
type TreeEntry struct {
// contains filtered or unexported fields
}
func NewTreeEntry ¶
func NewTreeEntry(pyramid *PyramidChunker) *TreeEntry
type TreeSplitterParams ¶
type TreeSplitterParams struct { SplitterParams // contains filtered or unexported fields }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
|
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 |
Click to show internal directories.
Click to hide internal directories.