fix first block hash

This commit is contained in:
Larry Ruane 2020-05-20 15:21:55 -06:00 committed by Larry Ruane
parent 2f0b2054ba
commit 007dbbf13c
1 changed files with 5 additions and 2 deletions

View File

@ -118,7 +118,7 @@ func addBlockActive(blockBytes []byte) error {
// Set missing prev hashes of the blocks in the active chain
func setPrevhash() {
prevhash := make([]byte, 32)
var prevhash []byte
for _, blockBytes := range state.activeBlocks {
// Set this block's prevhash.
block := parser.NewBlock()
@ -129,8 +129,11 @@ func setPrevhash() {
if len(rest) != 0 {
Log.Fatal(errors.New("block is too long"))
}
copy(blockBytes[4:4+32], prevhash)
if prevhash != nil {
copy(blockBytes[4:4+32], prevhash)
}
prevhash = block.GetEncodableHash()
Log.Info("height ", block.GetHeight(), " hash ", hex.EncodeToString(block.GetDisplayHash()))
}
}