File tree Expand file tree Collapse file tree
internal/repository/cache Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ require (
1919 github.com/graph-gophers/graphql-transport-ws v0.0.0-20200904065757-c681d7e1b135
2020 github.com/jackpal/go-nat-pmp v1.0.2 // indirect
2121 github.com/karalabe/usb v0.0.0-20210518091819-4ea20957c210 // indirect
22- github.com/klauspost/compress v1.11.12 // indirect
22+ github.com/klauspost/compress v1.13.0 // indirect
2323 github.com/kr/text v0.2.0 // indirect
2424 github.com/magiconair/properties v1.8.4 // indirect
2525 github.com/mattn/go-runewidth v0.0.10 // indirect
Original file line number Diff line number Diff line change @@ -375,8 +375,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
375375github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 /go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4 =
376376github.com/klauspost/compress v1.4.0 /go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A =
377377github.com/klauspost/compress v1.9.5 /go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A =
378- github.com/klauspost/compress v1.11.12 h1:famVnQVu7QwryBN4jNseQdUKES71ZAOnB6UQQJPZvqk =
379- github.com/klauspost/compress v1.11.12 /go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs =
378+ github.com/klauspost/compress v1.13.0 h1:2T7tUoQrQT+fQWdaY5rjWztFGAFwbGD04iPJg90ZiOs =
379+ github.com/klauspost/compress v1.13.0 /go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg =
380380github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 /go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek =
381381github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6 /go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg =
382382github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada /go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs =
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ package cache
44import (
55 "fantom-api-graphql/internal/types"
66 "github.com/ethereum/go-ethereum/common"
7+ "github.com/klauspost/compress/s2"
78)
89
910// PullTransaction extracts transaction information from the in-memory cache if available.
@@ -15,6 +16,12 @@ func (b *MemBridge) PullTransaction(hash *common.Hash) *types.Transaction {
1516 return nil
1617 }
1718
19+ // decode compressed transaction data from Snappy S2
20+ data , err = s2 .Decode (nil , data )
21+ if err != nil {
22+ return nil
23+ }
24+
1825 // do we have the data?
1926 trx := new (types.Transaction )
2027 if err := trx .UnmarshalBSON (data ); err != nil {
@@ -39,8 +46,15 @@ func (b *MemBridge) PushTransaction(trx *types.Transaction) {
3946 return
4047 }
4148
49+ // recover from s2 encoder panic
50+ defer func () {
51+ if r := recover (); r != nil {
52+ b .log .Criticalf ("can not encode transaction" )
53+ }
54+ }()
55+
4256 // set the data to cache by block number
43- if err := b .cache .Set (trx .Hash .String (), data ); err != nil {
57+ if err := b .cache .Set (trx .Hash .String (), s2 . Encode ( nil , data ) ); err != nil {
4458 b .log .Criticalf ("can not cache transaction %s; %s" , trx .Hash .String (), err .Error ())
4559 }
4660}
You can’t perform that action at this time.
0 commit comments