github.com/linapex/ethereum-go-chinese@v0.0.0-20190316121929-f8b7a73c3fa1/swarm/storage/feed/cacheentry.go (about) 1 2 //<developer> 3 // <name>linapex 曹一峰</name> 4 // <email>linapex@163.com</email> 5 // <wx>superexc</wx> 6 // <qqgroup>128148617</qqgroup> 7 // <url>https://jsq.ink</url> 8 // <role>pku engineer</role> 9 // <date>2019-03-16 19:16:44</date> 10 //</624450118682152960> 11 12 13 package feed 14 15 import ( 16 "bytes" 17 "context" 18 "time" 19 20 "github.com/ethereum/go-ethereum/swarm/storage" 21 ) 22 23 const ( 24 hasherCount = 8 25 feedsHashAlgorithm = storage.SHA3Hash 26 defaultRetrieveTimeout = 100 * time.Millisecond 27 ) 28 29 //cacheEntry缓存特定群源的最后一次已知更新。 30 type cacheEntry struct { 31 Update 32 *bytes.Reader 33 lastKey storage.Address 34 } 35 36 //实现Storage.LazySectionReader 37 func (r *cacheEntry) Size(ctx context.Context, _ chan bool) (int64, error) { 38 return int64(len(r.Update.data)), nil 39 } 40 41 //返回源的主题 42 func (r *cacheEntry) Topic() Topic { 43 return r.Feed.Topic 44 } 45