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;
}
}
Aggregations