Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

fix(prover): change separator #469

Merged
merged 4 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions prover/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

var (
BlockKeyPrefix = "block-"
separator = "++"
)

type SignedBlockData struct {
Expand All @@ -34,11 +35,11 @@ func BuildBlockValue(hash []byte, signature []byte, blockID *big.Int) []byte {
hash,
signature,
blockID.Bytes(),
}, []byte("-"))
}, []byte(separator))
}

func SignedBlockDataFromValue(val []byte) SignedBlockData {
v := bytes.Split(val, []byte("-"))
v := bytes.Split(val, []byte(separator))

return SignedBlockData{
BlockID: new(big.Int).SetBytes(v[2]),
Expand Down
2 changes: 1 addition & 1 deletion prover/db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func Test_BuildBlockKey(t *testing.T) {

func Test_BuildBlockValue(t *testing.T) {
v := BuildBlockValue([]byte("hash"), []byte("sig"), big.NewInt(1))
spl := bytes.Split(v, []byte("-"))
spl := bytes.Split(v, []byte(separator))
assert.Equal(t, "hash", string(spl[0]))
assert.Equal(t, "sig", string(spl[1]))
assert.Equal(t, uint64(1), new(big.Int).SetBytes(spl[2]).Uint64())
Expand Down