Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address history now properly reports with reorgs
- Loading branch information
1 parent
e6870e1
commit fb271f3
Showing
7 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package snowblossom.node; | ||
|
||
|
||
import java.util.TreeMap; | ||
import snowblossom.lib.ChainHash; | ||
|
||
public class BlockHeightCache | ||
{ | ||
private TreeMap<Integer, ChainHash> map = new TreeMap<>(); | ||
private SnowBlossomNode node; | ||
|
||
public BlockHeightCache(SnowBlossomNode node) | ||
{ | ||
this.node = node; | ||
} | ||
|
||
public synchronized void setHash(int height, ChainHash hash) | ||
{ | ||
map.put(height, hash); | ||
} | ||
|
||
public synchronized ChainHash getHash(int height) | ||
{ | ||
ChainHash hash = map.get(height); | ||
if (hash == null) | ||
{ | ||
hash = node.getDB().getBlockHashAtHeight(height); | ||
map.put(height, hash); | ||
} | ||
return hash; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters