mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
remove case after use
This commit is contained in:
parent
e526f6334a
commit
a210d7ad14
2 changed files with 35 additions and 30 deletions
|
|
@ -18,9 +18,9 @@ package posv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
// "strings"
|
// "strings"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
// "encoding/hex"
|
// "encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
@ -52,7 +52,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
inmemorySnapshots = 128 // Number of recent vote snapshots to keep in memory
|
inmemorySnapshots = 128 // Number of recent vote snapshots to keep in memory
|
||||||
blockSignersCacheLimit = 1800
|
blockSignersCacheLimit = 3600
|
||||||
M2ByteLength = 4
|
M2ByteLength = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -860,36 +860,40 @@ func (c *Posv) Finalize(chain consensus.ChainReader, header *types.Header, state
|
||||||
number := header.Number.Uint64()
|
number := header.Number.Uint64()
|
||||||
rCheckpoint := chain.Config().Posv.RewardCheckpoint
|
rCheckpoint := chain.Config().Posv.RewardCheckpoint
|
||||||
|
|
||||||
/*
|
/*
|
||||||
abiJSON := `[{"inputs":[{"name":"_blockNumber","type":"uint256"},{"name":"_blockHash","type":"bytes32"}],"name":"sign","type":"function"}]`
|
abiJSON := `[{"inputs":[{"name":"_blockNumber","type":"uint256"},{"name":"_blockHash","type":"bytes32"}],"name":"sign","type":"function"}]`
|
||||||
abiReader, err := abi.JSON(strings.NewReader(abiJSON))
|
abiReader, err := abi.JSON(strings.NewReader(abiJSON))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Abi parser error", err)
|
log.Error("Abi parser error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Sign struct {
|
type Sign struct {
|
||||||
BlockNumber *big.Int
|
BlockNumber *big.Int
|
||||||
BlockHash common.Hash
|
BlockHash common.Hash
|
||||||
}
|
}
|
||||||
var s Sign
|
var s Sign
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for _, tx := range txs {
|
for _, tx := range txs {
|
||||||
if tx.IsSigningTransaction() {
|
if tx.IsSigningTransaction() {
|
||||||
/*
|
/*
|
||||||
err = abiReader.Unpack(&s, "sign", tx.Data())
|
err = abiReader.Unpack(&s, "sign", tx.Data())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Abi unpack error", err)
|
log.Error("Abi unpack error", err)
|
||||||
}
|
}
|
||||||
blkHash := s.BlockHash
|
blkHash := s.BlockHash
|
||||||
*/
|
*/
|
||||||
blkHash := tx.Data()[len(tx.Data())-32:]
|
blkHash := common.BytesToHash(tx.Data()[len(tx.Data())-32:])
|
||||||
|
txHash := *tx.From()
|
||||||
|
|
||||||
if cached, ok := c.BlockSigners.Get(blkHash); ok {
|
var lAddr []common.Address
|
||||||
lAddr := cached.([]common.Address)
|
if cached, ok := c.BlockSigners.Get(blkHash); ok {
|
||||||
lAddr = append(lAddr, *tx.From())
|
lAddr = cached.([]common.Address)
|
||||||
c.BlockSigners.Add(blkHash, lAddr)
|
lAddr = append(lAddr, txHash)
|
||||||
}
|
} else {
|
||||||
|
lAddr = []common.Address{txHash}
|
||||||
|
}
|
||||||
|
c.BlockSigners.Add(blkHash, lAddr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,8 +217,8 @@ func GetSignersFromContract2(c *posv.Posv, addrBlockSigner common.Address, clien
|
||||||
log.Error("Fail get instance of blockSigner", "error", err)
|
log.Error("Fail get instance of blockSigner", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if caddrs, ok := c.GetBlockSigners().Get(blockHash); !ok {
|
if caddrs, ok := c.BlockSigners.Get(blockHash); !ok || c.BlockSigners.Len() < 1800 {
|
||||||
opts := new(bind.CallOpts)
|
opts := new(bind.CallOpts)
|
||||||
addrs, err := blockSigner.GetSigners(opts, blockHash)
|
addrs, err := blockSigner.GetSigners(opts, blockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail get block signers", "error", err)
|
log.Error("Fail get block signers", "error", err)
|
||||||
|
|
@ -226,6 +226,7 @@ func GetSignersFromContract2(c *posv.Posv, addrBlockSigner common.Address, clien
|
||||||
}
|
}
|
||||||
return addrs, nil
|
return addrs, nil
|
||||||
} else {
|
} else {
|
||||||
|
c.BlockSigners.Remove(blockHash)
|
||||||
return caddrs.([]common.Address), nil
|
return caddrs.([]common.Address), nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue