mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
swarm/storage: fixup
This commit is contained in:
parent
2448dbee5c
commit
4b630d8221
1 changed files with 0 additions and 39 deletions
|
|
@ -185,7 +185,6 @@ func BytesToU64(data []byte) uint64 {
|
||||||
if len(data) < 8 {
|
if len(data) < 8 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
//return binary.LittleEndian.Uint64(data)
|
|
||||||
return binary.BigEndian.Uint64(data)
|
return binary.BigEndian.Uint64(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,7 +235,6 @@ func encodeData(chunk *Chunk) []byte {
|
||||||
func decodeIndex(data []byte, index *dpaDBIndex) error {
|
func decodeIndex(data []byte, index *dpaDBIndex) error {
|
||||||
dec := rlp.NewStream(bytes.NewReader(data), 0)
|
dec := rlp.NewStream(bytes.NewReader(data), 0)
|
||||||
return dec.Decode(index)
|
return dec.Decode(index)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeData(data []byte, chunk *Chunk) {
|
func decodeData(data []byte, chunk *Chunk) {
|
||||||
|
|
@ -249,43 +247,6 @@ func decodeOldData(data []byte, chunk *Chunk) {
|
||||||
chunk.Size = int64(binary.BigEndian.Uint64(data[0:8]))
|
chunk.Size = int64(binary.BigEndian.Uint64(data[0:8]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func gcListPartition(list []*gcItem, left int, right int, pivotIndex int) int {
|
|
||||||
pivotValue := list[pivotIndex].value
|
|
||||||
dd := list[pivotIndex]
|
|
||||||
list[pivotIndex] = list[right]
|
|
||||||
list[right] = dd
|
|
||||||
storeIndex := left
|
|
||||||
for i := left; i < right; i++ {
|
|
||||||
if list[i].value < pivotValue {
|
|
||||||
dd = list[storeIndex]
|
|
||||||
list[storeIndex] = list[i]
|
|
||||||
list[i] = dd
|
|
||||||
storeIndex++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dd = list[storeIndex]
|
|
||||||
list[storeIndex] = list[right]
|
|
||||||
list[right] = dd
|
|
||||||
return storeIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
func gcListSelect(list []*gcItem, left int, right int, n int) int {
|
|
||||||
if left == right {
|
|
||||||
return left
|
|
||||||
}
|
|
||||||
pivotIndex := (left + right) / 2
|
|
||||||
pivotIndex = gcListPartition(list, left, right, pivotIndex)
|
|
||||||
if n == pivotIndex {
|
|
||||||
return n
|
|
||||||
} else {
|
|
||||||
if n < pivotIndex {
|
|
||||||
return gcListSelect(list, left, pivotIndex-1, n)
|
|
||||||
} else {
|
|
||||||
return gcListSelect(list, pivotIndex+1, right, n)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *LDBStore) collectGarbage(ratio float32) {
|
func (s *LDBStore) collectGarbage(ratio float32) {
|
||||||
it := s.db.NewIterator()
|
it := s.db.NewIterator()
|
||||||
defer it.Release()
|
defer it.Release()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue