From ecb93a9882b0c75bc0a3502dea31f3cea1598605 Mon Sep 17 00:00:00 2001 From: Lutty Date: Sat, 19 Feb 2022 23:21:56 +0800 Subject: [PATCH] support rosetta tracer --- rosetta/services/block.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rosetta/services/block.go b/rosetta/services/block.go index 91f8afdec..436cf4b43 100644 --- a/rosetta/services/block.go +++ b/rosetta/services/block.go @@ -291,10 +291,10 @@ func init() { func (s *BlockAPI) getTransactionTrace( ctx context.Context, blk *hmytypes.Block, txInfo *transactionInfo, ) ([]*tracers.RosettaLogItem, *types.Error) { - //cacheKey := blk.Hash().String() + txInfo.tx.Hash().String() - //if value, ok := s.txTraceCache.Get(cacheKey); ok { - // return value.([]*tracers.RosettaLogItem), nil - //} + cacheKey := blk.Hash().String() + txInfo.tx.Hash().String() + if value, ok := s.txTraceCache.Get(cacheKey); ok { + return value.([]*tracers.RosettaLogItem), nil + } lock := &sync.Mutex{} if ok, _ := ttLock.ContainsOrAdd(blk.Hash().String(), lock); ok { @@ -310,9 +310,9 @@ func (s *BlockAPI) getTransactionTrace( defer lock.Unlock() } - //if value, ok := s.txTraceCache.Get(cacheKey); ok { - // return value.([]*tracers.RosettaLogItem), nil - //} + if value, ok := s.txTraceCache.Get(cacheKey); ok { + return value.([]*tracers.RosettaLogItem), nil + } var blockError *types.Error var foundResult []*tracers.RosettaLogItem