diff --git a/indexer/cacheLogic.go b/indexer/cacheLogic.go index 39c73ea1..223040a5 100644 --- a/indexer/cacheLogic.go +++ b/indexer/cacheLogic.go @@ -213,8 +213,9 @@ func (cache *indexerCache) processOrphanedBlocks(processedEpoch int64) error { } cache.cacheMutex.RUnlock() - logger.Infof("processing %v non-canonical blocks (epoch <= %v)", len(cachedBlocks), processedEpoch) + logger.Infof("processing %v non-canonical blocks (epoch <= %v, lowest slot: %v)", len(cachedBlocks), processedEpoch, cache.lowestSlot) if len(cachedBlocks) == 0 { + cache.resetLowestSlot() return nil } diff --git a/rpctypes/basetypes.go b/rpctypes/basetypes.go index fc5490fe..a4e06fc3 100644 --- a/rpctypes/basetypes.go +++ b/rpctypes/basetypes.go @@ -2,6 +2,7 @@ package rpctypes import ( "encoding/hex" + "encoding/json" "errors" "fmt" "strconv" @@ -22,6 +23,44 @@ func (s *BytesHexStr) UnmarshalText(b []byte) error { return nil } +func (s *BytesHexStr) UnmarshalJSON(b []byte) error { + if s == nil { + return fmt.Errorf("cannot unmarshal bytes into nil") + } + var bytes []byte + var tmpStr string + if err := json.Unmarshal(b, &tmpStr); err == nil { + if len(tmpStr) >= 2 && tmpStr[0] == '0' && tmpStr[1] == 'x' { + tmpStr = tmpStr[2:] + } + bytes = make([]byte, len(tmpStr)/2) + hex.Decode(bytes, []byte(tmpStr)) + } else { + err := json.Unmarshal(b, &bytes) + if err != nil { + var tmpStrArr []string + err = json.Unmarshal(b, &tmpStrArr) + if err == nil { + bytes = make([]byte, len(tmpStrArr)) + for idx, str := range tmpStrArr { + n, e := strconv.ParseUint(str, 0, 64) + if e != nil { + err = e + break + } + bytes[idx] = uint8(n) + } + } + } + if err != nil { + fmt.Printf("err: %v\n", err) + return err + } + } + *s = bytes + return nil +} + func (s *BytesHexStr) MarshalJSON() ([]byte, error) { if s == nil { return nil, nil