mirror of
https://github.com/jwetzell/psn-go.git
synced 2026-09-02 04:49:08 +00:00
cleanup function layout for decoders
This commit is contained in:
@@ -3,13 +3,19 @@ package decoders
|
||||
type DataTrackerListChunkData struct {
|
||||
Trackers []DataTrackerChunk
|
||||
}
|
||||
type DataTrackerListChunk struct {
|
||||
Chunk Chunk
|
||||
Data DataTrackerListChunkData
|
||||
}
|
||||
|
||||
func decodeDataTrackerListChunkData(dataTrackerListChunk Chunk) DataTrackerListChunkData {
|
||||
var trackers []DataTrackerChunk
|
||||
if dataTrackerListChunk.Header.HasSubchunks && dataTrackerListChunk.Header.DataLen > 0 {
|
||||
func DecodeDataTrackerListChunk(bytes []byte) DataTrackerListChunk {
|
||||
chunk := DecodeChunk(bytes)
|
||||
|
||||
trackers := []DataTrackerChunk{}
|
||||
if chunk.Header.HasSubchunks && chunk.Header.DataLen > 0 {
|
||||
offset := 0
|
||||
for offset < int(dataTrackerListChunk.Header.DataLen) {
|
||||
trackerChunk := DecodeDataTrackerChunk(dataTrackerListChunk.ChunkData[offset:])
|
||||
for offset < int(chunk.Header.DataLen) {
|
||||
trackerChunk := DecodeDataTrackerChunk(chunk.ChunkData[offset:])
|
||||
offset += 4
|
||||
if trackerChunk.Chunk.Header.DataLen > 0 {
|
||||
offset += int(trackerChunk.Chunk.Header.DataLen)
|
||||
@@ -18,19 +24,9 @@ func decodeDataTrackerListChunkData(dataTrackerListChunk Chunk) DataTrackerListC
|
||||
}
|
||||
}
|
||||
|
||||
return DataTrackerListChunkData{
|
||||
data := DataTrackerListChunkData{
|
||||
Trackers: trackers,
|
||||
}
|
||||
}
|
||||
|
||||
type DataTrackerListChunk struct {
|
||||
Chunk Chunk
|
||||
Data DataTrackerListChunkData
|
||||
}
|
||||
|
||||
func DecodeDataTrackerListChunk(bytes []byte) DataTrackerListChunk {
|
||||
chunk := DecodeChunk(bytes)
|
||||
data := decodeDataTrackerListChunkData(chunk)
|
||||
|
||||
return DataTrackerListChunk{
|
||||
Chunk: chunk,
|
||||
|
||||
Reference in New Issue
Block a user