Skip to content

Commit

Permalink
add missing length on block data
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Oct 4, 2023
1 parent a6fe088 commit 2368cd5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
6 changes: 5 additions & 1 deletion accountresolver/bundlerreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package accountsresolver

import (
"context"
"encoding/binary"
"fmt"
"io"
"time"
Expand Down Expand Up @@ -57,10 +58,13 @@ func (r *BundleReader) PushBlock(block *bstream.Block) error {
return fmt.Errorf("unable to marshal proto block: %w", err)
}

length := make([]byte, 4)
binary.BigEndian.PutUint32(length, uint32(len(data)))

select {
case <-r.ctx.Done():
return nil
case r.blockData <- data:
case r.blockData <- append(length, data...):
return nil
}
}
Expand Down
42 changes: 42 additions & 0 deletions cmd/grrr/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"fmt"

"github.com/streamingfast/dbin"

pbbstream "github.com/streamingfast/pbgo/sf/bstream/v1"
"google.golang.org/protobuf/proto"
)

func main() {
//data, err := os.ReadFile("/Users/cbillett/devel/sf/0154667200.dbin")
//if err != nil {
// panic(err)
//}

fr, err := dbin.NewFileReader("/Users/cbillett/devel/sf/0154667200.dbin")
if err != nil {
panic(err)
}

contentType, version, err := fr.ReadHeader()
if err != nil {
panic(err)
}
fmt.Println("type:", contentType, "version:", version)

for {
data, err := fr.ReadMessage()
if err != nil {
panic(err)
}
b := &pbbstream.Block{}
err = proto.Unmarshal(data, b)
if err != nil {
panic(err)
}

fmt.Println(b.Number)
}
}

0 comments on commit 2368cd5

Please sign in to comment.