mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
removed check from consensus, handelling everything in api.go
This commit is contained in:
parent
de03f3fb6a
commit
473e09cd2d
3 changed files with 5 additions and 20 deletions
|
|
@ -288,10 +288,6 @@ func New(
|
||||||
// Author implements consensus.Engine, returning the Ethereum address recovered
|
// Author implements consensus.Engine, returning the Ethereum address recovered
|
||||||
// from the signature in the header's extra-data section.
|
// from the signature in the header's extra-data section.
|
||||||
func (c *Bor) Author(header *types.Header) (common.Address, error) {
|
func (c *Bor) Author(header *types.Header) (common.Address, error) {
|
||||||
if header.Number.Uint64() == 0 {
|
|
||||||
add := common.HexToAddress("0x0000000000000000000000000000000000000000")
|
|
||||||
return add, nil
|
|
||||||
}
|
|
||||||
return ecrecover(header, c.signatures, c.config)
|
return ecrecover(header, c.signatures, c.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -210,10 +210,6 @@ func New(config *params.CliqueConfig, db ethdb.Database) *Clique {
|
||||||
// Author implements consensus.Engine, returning the Ethereum address recovered
|
// Author implements consensus.Engine, returning the Ethereum address recovered
|
||||||
// from the signature in the header's extra-data section.
|
// from the signature in the header's extra-data section.
|
||||||
func (c *Clique) Author(header *types.Header) (common.Address, error) {
|
func (c *Clique) Author(header *types.Header) (common.Address, error) {
|
||||||
if header.Number.Uint64() == 0 {
|
|
||||||
add := common.HexToAddress("0x0000000000000000000000000000000000000000")
|
|
||||||
return add, nil
|
|
||||||
}
|
|
||||||
return ecrecover(header, c.signatures)
|
return ecrecover(header, c.signatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -815,17 +815,17 @@ func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.H
|
||||||
}
|
}
|
||||||
|
|
||||||
// getAuthor: returns the author of the Block
|
// getAuthor: returns the author of the Block
|
||||||
func (s *PublicBlockChainAPI) getAuthor(head *types.Header) (*common.Address, error) {
|
func (s *PublicBlockChainAPI) getAuthor(head *types.Header) *common.Address {
|
||||||
// get author using Author() function from: /consensus/clique/clique.go
|
// get author using Author() function from: /consensus/clique/clique.go
|
||||||
// In Production: get author using Author() function from: /consensus/bor/bor.go
|
// In Production: get author using Author() function from: /consensus/bor/bor.go
|
||||||
author, err := s.b.Engine().Author(head)
|
author, err := s.b.Engine().Author(head)
|
||||||
// make sure we don't send error to the user, return 0x0 instead
|
// make sure we don't send error to the user, return 0x0 instead
|
||||||
if err != nil {
|
if err != nil {
|
||||||
add := common.HexToAddress("0x0000000000000000000000000000000000000000")
|
add := common.HexToAddress("0x0000000000000000000000000000000000000000")
|
||||||
return &add, nil
|
return &add
|
||||||
}
|
}
|
||||||
// change the coinbase (0x0) with the miner address
|
// change the coinbase (0x0) with the miner address
|
||||||
return &author, nil
|
return &author
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockByNumber returns the requested canonical block.
|
// GetBlockByNumber returns the requested canonical block.
|
||||||
|
|
@ -846,10 +846,7 @@ func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.B
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil && number != rpc.PendingBlockNumber {
|
if err == nil && number != rpc.PendingBlockNumber {
|
||||||
author, err := s.getAuthor(block.Header())
|
author := s.getAuthor(block.Header())
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response["miner"] = author
|
response["miner"] = author
|
||||||
}
|
}
|
||||||
|
|
@ -872,11 +869,7 @@ func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Ha
|
||||||
response, err := s.rpcMarshalBlock(ctx, block, true, fullTx)
|
response, err := s.rpcMarshalBlock(ctx, block, true, fullTx)
|
||||||
// append marshalled bor transaction
|
// append marshalled bor transaction
|
||||||
if err == nil && response != nil {
|
if err == nil && response != nil {
|
||||||
|
author := s.getAuthor(block.Header())
|
||||||
author, err := s.getAuthor(block.Header())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response["miner"] = author
|
response["miner"] = author
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue