Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Jul 31, 2024
1 parent 026e397 commit e86a02d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
10 changes: 8 additions & 2 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@ func DecodeUint64[T ~uint64](dec *Decoder, n *T) {

// DecodeUint256 parses a uint256.
func DecodeUint256(dec *Decoder, n **uint256.Int) {
fmt.Println("REEEE")
if dec.err != nil {
return
}
fmt.Println("REEEE2")
if dec.inReader != nil {
_, dec.err = io.ReadFull(dec.inReader, dec.buf[:32])
if dec.err != nil {
Expand All @@ -201,16 +203,20 @@ func DecodeUint256(dec *Decoder, n **uint256.Int) {
*n = new(uint256.Int)
}
(*n).UnmarshalSSZ(dec.buf[:32])
fmt.Println("BET123", n)
} else {
if len(dec.inBuffer) < 32 {
dec.err = io.ErrUnexpectedEOF
return
}
if *n == nil {
*n = new(uint256.Int)
fmt.Println("BET1234", *n)
}
(*n).UnmarshalSSZ(dec.inBuffer[:32])
dec.inBuffer = dec.inBuffer[32:]

fmt.Println("ON THE OBJ", *n)
}
}

Expand All @@ -227,14 +233,14 @@ func DecodeUint256BigInt(dec *Decoder, n **big.Int) {
dec.inRead += 32

dec.bufInt.UnmarshalSSZ(dec.buf[:32])
*n = dec.bufInt.ToBig() // TODO(karalabe): make this alloc free (https://github.com/holiman/uint256/pull/177)
dec.bufInt.IntoBig(n)
} else {
if len(dec.inBuffer) < 32 {
dec.err = io.ErrUnexpectedEOF
return
}
dec.bufInt.UnmarshalSSZ(dec.inBuffer[:32])
*n = dec.bufInt.ToBig() // TODO(karalabe): make this alloc free (https://github.com/holiman/uint256/pull/177)
dec.bufInt.IntoBig(n)
dec.inBuffer = dec.inBuffer[32:]
}
}
Expand Down
1 change: 1 addition & 0 deletions example_dynamic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func ExampleEncodeDynamicObject() {
if err := ssz.EncodeToBytes(blob, obj); err != nil {
panic(err)
}

fmt.Printf("ssz: %#x\n", blob)
// Output:
// ssz: 0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000020000
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ go 1.21

require (
github.com/golang/snappy v0.0.4
github.com/holiman/uint256 v1.3.0
github.com/holiman/uint256 v1.3.1
github.com/prysmaticlabs/go-bitfield v0.0.0-20240618144021-706c95b2dd15
github.com/prysmaticlabs/gohashtree v0.0.4-beta
golang.org/x/sync v0.7.0
golang.org/x/tools v0.22.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/sync v0.7.0 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/holiman/uint256 v1.3.0 h1:4wdcm/tnd0xXdu7iS3ruNvxkWwrb4aeBQv19ayYn8F4=
github.com/holiman/uint256 v1.3.0/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs=
github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
Expand Down

0 comments on commit e86a02d

Please sign in to comment.