consensus/clique, core: API cleanup (#23100)
This removes some code: - The clique engine calculated the snapshot twice when verifying headers/blocks. - The method GetBlockHashesFromHash in Header/Block/Lightchain was only used by tests. It is now removed from the API. - The method GetTdByHash internally looked up the number before calling GetTd(hash, num). In many cases, callers already had the number, and used this method just because it has a shorter name. I have removed the method to make the API surface smaller.
This commit is contained in:
committed by
GitHub
parent
da3da7c0e7
commit
6289137827
@ -126,6 +126,12 @@ func testGetBlockHeaders(t *testing.T, protocol uint) {
|
||||
for i := range unknown {
|
||||
unknown[i] = byte(i)
|
||||
}
|
||||
getHashes := func(from, limit uint64) (hashes []common.Hash) {
|
||||
for i := uint64(0); i < limit; i++ {
|
||||
hashes = append(hashes, backend.chain.GetCanonicalHash(from-1-i))
|
||||
}
|
||||
return hashes
|
||||
}
|
||||
// Create a batch of tests for various scenarios
|
||||
limit := uint64(maxHeadersServe)
|
||||
tests := []struct {
|
||||
@ -183,7 +189,7 @@ func testGetBlockHeaders(t *testing.T, protocol uint) {
|
||||
// Ensure protocol limits are honored
|
||||
{
|
||||
&GetBlockHeadersPacket{Origin: HashOrNumber{Number: backend.chain.CurrentBlock().NumberU64() - 1}, Amount: limit + 10, Reverse: true},
|
||||
backend.chain.GetBlockHashesFromHash(backend.chain.CurrentBlock().Hash(), limit),
|
||||
getHashes(backend.chain.CurrentBlock().NumberU64(), limit),
|
||||
},
|
||||
// Check that requesting more than available is handled gracefully
|
||||
{
|
||||
|
Reference in New Issue
Block a user