mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
core/types: more extensible tx signing
Having just a single return point in methods that build signers makes it easier for forks of go ethereum to add their own signers that delegate to the underlying signer chain, since they can intercept the signer chain at a single point.
This commit is contained in:
parent
e9467eec1c
commit
4f6ffd0a48
1 changed files with 15 additions and 15 deletions
|
|
@ -64,21 +64,20 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int, blockTime uint
|
|||
// Use this in transaction-handling code where the current block number is unknown. If you
|
||||
// have the current block number available, use MakeSigner instead.
|
||||
func LatestSigner(config *params.ChainConfig) Signer {
|
||||
var signer Signer = HomesteadSigner{}
|
||||
if config.ChainID != nil {
|
||||
if config.CancunTime != nil {
|
||||
return NewCancunSigner(config.ChainID)
|
||||
}
|
||||
if config.LondonBlock != nil {
|
||||
return NewLondonSigner(config.ChainID)
|
||||
}
|
||||
if config.BerlinBlock != nil {
|
||||
return NewEIP2930Signer(config.ChainID)
|
||||
}
|
||||
if config.EIP155Block != nil {
|
||||
return NewEIP155Signer(config.ChainID)
|
||||
switch {
|
||||
case config.CancunTime != nil:
|
||||
signer = NewCancunSigner(config.ChainID)
|
||||
case config.LondonBlock != nil:
|
||||
signer = NewLondonSigner(config.ChainID)
|
||||
case config.BerlinBlock != nil:
|
||||
signer = NewEIP2930Signer(config.ChainID)
|
||||
case config.EIP155Block != nil:
|
||||
signer = NewEIP155Signer(config.ChainID)
|
||||
}
|
||||
}
|
||||
return HomesteadSigner{}
|
||||
return signer
|
||||
}
|
||||
|
||||
// LatestSignerForChainID returns the 'most permissive' Signer available. Specifically,
|
||||
|
|
@ -89,10 +88,11 @@ func LatestSigner(config *params.ChainConfig) Signer {
|
|||
// configuration are unknown. If you have a ChainConfig, use LatestSigner instead.
|
||||
// If you have a ChainConfig and know the current block number, use MakeSigner instead.
|
||||
func LatestSignerForChainID(chainID *big.Int) Signer {
|
||||
if chainID == nil {
|
||||
return HomesteadSigner{}
|
||||
var signer Signer = HomesteadSigner{}
|
||||
if chainID != nil {
|
||||
signer = NewCancunSigner(chainID)
|
||||
}
|
||||
return NewCancunSigner(chainID)
|
||||
return signer
|
||||
}
|
||||
|
||||
// SignTx signs the transaction using the given signer and private key.
|
||||
|
|
|
|||
Loading…
Reference in a new issue