Skip to content

Commit 3c9bc68

Browse files
author
rian
committed
core.BlockHash
1 parent 289373e commit 3c9bc68

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

core/block.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,8 @@ func VerifyBlockHash(b *Block, network *utils.Network) (*BlockCommitments, error
125125
// BlockHash assumes block.SequencerAddress is not nil as this is called with post v0.12.0
126126
// and by then issues with unverifiable block hash were resolved.
127127
// In future, this may no longer be required.
128-
func BlockHash(b *Block) (*felt.Felt, error) {
129-
if b.SequencerAddress == nil {
130-
return nil, errors.New("block.SequencerAddress is nil")
131-
}
132-
133-
h, _, err := post07Hash(b, nil)
134-
return h, err
128+
func BlockHash(b *Block, network *utils.Network) (*felt.Felt, *BlockCommitments, error) {
129+
return blockHash(b, network, nil)
135130
}
136131

137132
// blockHash computes the block hash, with option to override sequence address

core/block_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func TestBlockHashP2P(t *testing.T) {
253253

254254
mainnetBlock1.SequencerAddress = nil
255255

256-
_, err = core.BlockHash(mainnetBlock1)
256+
_, _, err = core.BlockHash(mainnetBlock1, &utils.Mainnet)
257257
assert.EqualError(t, err, "block.SequencerAddress is nil")
258258
})
259259
}

p2p/sync.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ func (s *syncService) adaptAndSanityCheckBlock(ctx context.Context, header *spec
343343

344344
coreBlock.Header = &coreHeader
345345
coreBlock.EventsBloom = core.EventsBloom(coreBlock.Receipts)
346-
h, err := core.BlockHash(coreBlock)
346+
h, _, err := core.BlockHash(coreBlock, s.network)
347347
if err != nil {
348348
bodyCh <- blockBody{err: fmt.Errorf("block hash calculation error: %v", err)}
349349
return

0 commit comments

Comments
 (0)