Skip to content
Snippets Groups Projects
Commit 4826cba6 authored by Miguel Montes's avatar Miguel Montes
Browse files

Cambio en la forma de detectar el sellador de un bloque

parent 27a8a2b2
No related branches found
No related tags found
No related merge requests found
......@@ -159,16 +159,23 @@ func (node *Node) HeaderByHash(hash common.Hash) (header Header) {
return
}
func (node *Node) BlockSigner(blockNumber int64) (signer Address) {
if blockNumber > 0 {
signer = node.SnapshotAtBlock(blockNumber).Recents[uint64(blockNumber)]
}
return
}
func (node *Node) BlockByNumber(blockNumber int64) (block Block) {
node.Call(&block, "eth_getBlockByNumber", hexBlockNumber(blockNumber), true)
block.Signer = block.GetSigner()
block.Signer = node.BlockSigner(blockNumber)
block.Hash = block.GetHash()
return
}
func (node *Node) BlockByHash(hash common.Hash) (block Block) {
node.Call(&block, "eth_getBlockByHash", hash, true)
block.Signer = block.GetSigner()
block.Signer = node.BlockSigner(block.Number.Int64())
block.Hash = block.GetHash()
return
}
......@@ -179,15 +186,7 @@ func (node *Node) BlockTransactionCount(blockNumber int64) (count int64) {
return int64(num)
}
func (node *Node) BlockSigner(blockNumber int64) (signer Address) {
if blockNumber == 0 { // we return an empty signer for genesis block
return
}
header := node.HeaderByNumber(blockNumber)
return header.GetSigner()
}
func (node *Node) GetSnapshot() (snapshot Snapshot) {
func (node *Node) Snapshot() (snapshot Snapshot) {
node.Call(&snapshot, "clique_getSnapshot", nil)
return
}
......@@ -241,7 +240,6 @@ func (node *Node) IsSealerAtBlock(address Address, blockNumber int64) bool {
func (node *Node) Propose(address Address, vote bool) {
node.Call(nil, "clique_propose", address.String(), vote)
return
}
func (node *Node) Votes(blockNumber int64) (votes Proposals) {
......@@ -249,7 +247,7 @@ func (node *Node) Votes(blockNumber int64) (votes Proposals) {
snapshot Snapshot
)
if blockNumber < 0 {
snapshot = node.GetSnapshot()
snapshot = node.Snapshot()
} else {
snapshot = node.SnapshotAtBlock(blockNumber)
}
......@@ -319,7 +317,10 @@ func (node *Node) SealersStatus(blockNumber int64) (status map[Address]*SealerSt
blockNumber = block.Number.Int64()
until := Max(1, blockNumber-SealerRounds*notSeen)
for notSeen > 0 {
signer := block.GetSigner()
signer := node.BlockSigner(blockNumber)
if _, ok := status[signer]; !ok {
panic("Unknown signer")
}
if status[signer].LastBlock == 0 {
status[signer].LastBlock = block.Number.Int64()
status[signer].Time = uint64(block.Time)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment