Search in sources :

Example 31 with TimeRecordAuto

use of duckutil.TimeRecordAuto in project snowblossom by snowblossomcoin.

the class ForgeInfo method getHeader.

public BlockHeader getHeader(ChainHash hash) {
    synchronized (block_header_cache) {
        BlockHeader h = block_header_cache.get(hash);
        if (h != null)
            return h;
    }
    try (TimeRecordAuto tra_blk = TimeRecord.openAuto("ForgeInfo.getHeader_miss")) {
        BlockHeader h = null;
        BlockSummary summary = getSummary(hash);
        if (summary != null) {
            h = summary.getHeader();
        }
        if (h == null) {
            h = node.getDB().getBlockHeaderMap().get(hash.getBytes());
        }
        if (h == null) {
            ImportedBlock ib = node.getShardUtxoImport().getImportBlock(hash);
            if (ib != null) {
                h = ib.getHeader();
            }
        }
        if (h != null) {
            try (TimeRecordAuto tra_save = TimeRecord.openAuto("ForgeInfo.getHeader_save")) {
                synchronized (block_header_cache) {
                    block_header_cache.put(hash, h);
                }
            }
        }
        return h;
    }
}
Also used : TimeRecordAuto(duckutil.TimeRecordAuto)

Aggregations

TimeRecordAuto (duckutil.TimeRecordAuto)31 ByteString (com.google.protobuf.ByteString)11 LinkedList (java.util.LinkedList)10 BigInteger (java.math.BigInteger)7 TreeMap (java.util.TreeMap)7 MessageDigest (java.security.MessageDigest)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 TreeSet (java.util.TreeSet)2 CodedInputStream (com.google.protobuf.CodedInputStream)1 MetricLog (duckutil.MetricLog)1 DecimalFormat (java.text.DecimalFormat)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 SplittableRandom (java.util.SplittableRandom)1 ValidationException (snowblossom.lib.ValidationException)1 HashedTrie (snowblossom.lib.trie.HashedTrie)1 TrieDBMem (snowblossom.lib.trie.TrieDBMem)1