Deprecate scanner.Block & File

This commit is contained in:
Jakob Borg
2014-07-12 23:06:48 +02:00
parent 91b35118d9
commit 655acb4cb2
21 changed files with 269 additions and 480 deletions

View File

@@ -4,6 +4,8 @@
package protocol
import "fmt"
type IndexMessage struct {
Repository string // max:64
Files []FileInfo // max:10000000
@@ -17,9 +19,34 @@ type FileInfo struct {
Blocks []BlockInfo // max:1000000
}
func (f FileInfo) String() string {
return fmt.Sprintf("File{Name:%q, Flags:0%o, Modified:%d, Version:%d, Size:%d, Blocks:%v}",
f.Name, f.Flags, f.Modified, f.Version, f.Size(), f.Blocks)
}
func (f FileInfo) Size() (bytes int64) {
for _, b := range f.Blocks {
bytes += int64(b.Size)
}
return
}
func (a FileInfo) Equals(b FileInfo) bool {
return a.Version == b.Version
}
func (a FileInfo) NewerThan(b FileInfo) bool {
return a.Version > b.Version
}
type BlockInfo struct {
Size uint32
Hash []byte // max:64
Offset int64 // noencode (cache only)
Size uint32
Hash []byte // max:64
}
func (b BlockInfo) String() string {
return fmt.Sprintf("Block{%d/%d/%x}", b.Offset, b.Size, b.Hash)
}
type RequestMessage struct {