good morning!!!!

Skip to content
Snippets Groups Projects
Commit 10c4e89f authored by Shivam Sharma's avatar Shivam Sharma Committed by Victor Castell
Browse files

fix: added basic span read

parent 28963d5c
No related branches found
No related tags found
No related merge requests found
......@@ -1074,6 +1074,31 @@ func (c *Bor) fetchAndCommitSpan(
}
heimdallSpan = *s
} else {
var spanArray []*ResponseWithHeight
if err := json.Unmarshal([]byte(SPANS), &spanArray); err != nil {
return err
}
spanInJSON := false
for _, val := range spanArray {
var tempHeimdallSpan HeimdallSpan
if err := json.Unmarshal(val.Result, &tempHeimdallSpan); err != nil {
return err
}
if tempHeimdallSpan.ID == newSpanID {
heimdallSpan = tempHeimdallSpan
log.Info("Got span from local", "span", heimdallSpan.Span.ID)
spanInJSON = true
break
}
}
if !spanInJSON {
response, err := c.HeimdallClient.FetchWithRetry(fmt.Sprintf("bor/span/%d", newSpanID), "")
if err != nil {
return err
......@@ -1083,6 +1108,7 @@ func (c *Bor) fetchAndCommitSpan(
return err
}
}
}
// check if chain id matches with heimdall span
if heimdallSpan.ChainID != c.chainConfig.ChainID.String() {
......
package bor
import (
"encoding/json"
"math/big"
"testing"
......@@ -135,3 +136,27 @@ func TestEncodeSigHeaderJaipur(t *testing.T) {
hash = SealHash(h, &params.BorConfig{JaipurBlock: 10})
assert.Equal(t, hash, hashWithoutBaseFee)
}
func TestReadHardcodedSpan(t *testing.T) {
// t.Skip()
var spanArray []*ResponseWithHeight
if err := json.Unmarshal([]byte(SPANS), &spanArray); err != nil {
t.Fatal(err)
}
for i, val := range spanArray {
var tempHeimdallSpan HeimdallSpan
if err := json.Unmarshal(val.Result, &tempHeimdallSpan); err != nil {
t.Fatal(err)
}
t.Log(i, tempHeimdallSpan.ID)
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment