Add node ID field to file structure

This commit is contained in:
Kleissner
2021-09-28 19:55:30 +02:00
parent 608dbf6f47
commit 2c20fa950d
6 changed files with 22 additions and 10 deletions

View File

@@ -36,6 +36,7 @@ import (
// It has no upper size limit, although a soft limit of 64 KB - overhead is encouraged for efficiency.
type Block struct {
OwnerPublicKey *btcec.PublicKey // Owner Public Key, ECDSA (secp256k1) 257-bit
NodeID []byte // Node ID of the owner (derived from the public key)
LastBlockHash []byte // Hash of the last block. Blake3.
BlockchainVersion uint64 // Blockchain version
Number uint64 // Block number
@@ -67,6 +68,8 @@ func decodeBlock(raw []byte) (block *Block, err error) {
return nil, err
}
block.NodeID = PublicKey2NodeID(block.OwnerPublicKey)
block.LastBlockHash = make([]byte, hashSize)
copy(block.LastBlockHash, raw[65:65+hashSize])