mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Merge branch 'master' of https://github.com/pavelkrolevets/go-ethereum
This commit is contained in:
commit
197fcd5445
1 changed files with 50 additions and 52 deletions
|
|
@ -5,12 +5,12 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"encoding/binary"
|
||||||
"github.com/pavelkrolevets/go-ethereum/common"
|
"github.com/pavelkrolevets/go-ethereum/common"
|
||||||
"github.com/pavelkrolevets/go-ethereum/crypto/sha3"
|
"github.com/pavelkrolevets/go-ethereum/crypto/sha3"
|
||||||
|
"github.com/pavelkrolevets/go-ethereum/ethdb"
|
||||||
"github.com/pavelkrolevets/go-ethereum/rlp"
|
"github.com/pavelkrolevets/go-ethereum/rlp"
|
||||||
"github.com/pavelkrolevets/go-ethereum/trie"
|
"github.com/pavelkrolevets/go-ethereum/trie"
|
||||||
"encoding/binary"
|
|
||||||
"github.com/pavelkrolevets/go-ethereum/ethdb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type LCPContext struct {
|
type LCPContext struct {
|
||||||
|
|
@ -264,8 +264,6 @@ type LCPContextProto struct {
|
||||||
periodBlockHash common.Hash `json:"periodBlockRoot" gencodec:"required"`
|
periodBlockHash common.Hash `json:"periodBlockRoot" gencodec:"required"`
|
||||||
maxValidatorsHash common.Hash `json:"maxValidatorRoot" gencodec:"required"`
|
maxValidatorsHash common.Hash `json:"maxValidatorRoot" gencodec:"required"`
|
||||||
epochIntervalHash common.Hash `json:"epochIntervalRoot" gencodec:"required"`
|
epochIntervalHash common.Hash `json:"epochIntervalRoot" gencodec:"required"`
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *LCPContext) ToProto() *LCPContextProto {
|
func (d *LCPContext) ToProto() *LCPContextProto {
|
||||||
|
|
@ -389,6 +387,7 @@ func (d *LCPContext) UnDelegate(delegatorAddr, candidateAddr common.Address) err
|
||||||
}
|
}
|
||||||
return d.voteTrie.TryDelete(delegator)
|
return d.voteTrie.TryDelete(delegator)
|
||||||
}
|
}
|
||||||
|
|
||||||
//function to write tries to memory
|
//function to write tries to memory
|
||||||
func (d *LCPContext) CommitTo(db ethdb.Database) (*LCPContextProto, error) {
|
func (d *LCPContext) CommitTo(db ethdb.Database) (*LCPContextProto, error) {
|
||||||
epochRoot, err := d.epochTrie.Commit(nil)
|
epochRoot, err := d.epochTrie.Commit(nil)
|
||||||
|
|
@ -451,7 +450,6 @@ func (dc *LCPContext) SetVote(vote *trie.Trie) { dc.voteTrie = vote }
|
||||||
func (dc *LCPContext) SetCandidate(candidate *trie.Trie) { dc.candidateTrie = candidate }
|
func (dc *LCPContext) SetCandidate(candidate *trie.Trie) { dc.candidateTrie = candidate }
|
||||||
func (dc *LCPContext) SetMintCnt(mintCnt *trie.Trie) { dc.mintCntTrie = mintCnt }
|
func (dc *LCPContext) SetMintCnt(mintCnt *trie.Trie) { dc.mintCntTrie = mintCnt }
|
||||||
|
|
||||||
|
|
||||||
func (dc *LCPContext) GetValidators() ([]common.Address, error) {
|
func (dc *LCPContext) GetValidators() ([]common.Address, error) {
|
||||||
var validators []common.Address
|
var validators []common.Address
|
||||||
key := []byte("validator")
|
key := []byte("validator")
|
||||||
|
|
@ -481,7 +479,7 @@ func (dc *LCPContext) SetPeriodBlock(period int64) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *LCPContext) GetPeriodBlock() (int64) {
|
func (dc *LCPContext) GetPeriodBlock() int64 {
|
||||||
key := []byte("BlockPeriod")
|
key := []byte("BlockPeriod")
|
||||||
periodRLP := dc.epochTrie.Get(key)
|
periodRLP := dc.epochTrie.Get(key)
|
||||||
period := int64(binary.LittleEndian.Uint64(periodRLP))
|
period := int64(binary.LittleEndian.Uint64(periodRLP))
|
||||||
|
|
@ -497,7 +495,7 @@ func (dc *LCPContext) SetMaxValidators(maxVal int64) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *LCPContext) GetMaxValidators() (int64) {
|
func (dc *LCPContext) GetMaxValidators() int64 {
|
||||||
key := []byte("MaxValidators")
|
key := []byte("MaxValidators")
|
||||||
maxValRLP := dc.epochTrie.Get(key)
|
maxValRLP := dc.epochTrie.Get(key)
|
||||||
maxVal := int64(binary.LittleEndian.Uint64(maxValRLP))
|
maxVal := int64(binary.LittleEndian.Uint64(maxValRLP))
|
||||||
|
|
@ -512,7 +510,7 @@ func (dc *LCPContext) SetEpochInterval(epochInt int64) error {
|
||||||
dc.epochTrie.Update(key, epochIntByte)
|
dc.epochTrie.Update(key, epochIntByte)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (dc *LCPContext) GetEpochInterval() (int64) {
|
func (dc *LCPContext) GetEpochInterval() int64 {
|
||||||
key := []byte("EpochInterval")
|
key := []byte("EpochInterval")
|
||||||
epochIntRLP := dc.epochTrie.Get(key)
|
epochIntRLP := dc.epochTrie.Get(key)
|
||||||
period := int64(binary.LittleEndian.Uint64(epochIntRLP))
|
period := int64(binary.LittleEndian.Uint64(epochIntRLP))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue