mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
db type conversion
This commit is contained in:
parent
50fb0a24ff
commit
e232ba43a3
2 changed files with 27 additions and 32 deletions
|
|
@ -14,7 +14,6 @@
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
package lcp
|
package lcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -22,6 +21,7 @@ import (
|
||||||
"github.com/pavelkrolevets/go-ethereum/consensus"
|
"github.com/pavelkrolevets/go-ethereum/consensus"
|
||||||
"github.com/pavelkrolevets/go-ethereum/core/types"
|
"github.com/pavelkrolevets/go-ethereum/core/types"
|
||||||
"github.com/pavelkrolevets/go-ethereum/rpc"
|
"github.com/pavelkrolevets/go-ethereum/rpc"
|
||||||
|
"github.com/pavelkrolevets/go-ethereum/trie"
|
||||||
"math/big"
|
"math/big"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)
|
||||||
return nil, errUnknownBlock
|
return nil, errUnknownBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
epochTrie, err := types.NewEpochTrie(header.LCPContext.EpochHash, api.lcp.db)
|
epochTrie, err := types.NewEpochTrie(header.LCPContext.EpochHash, trie.NewDatabase(api.lcp.db))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package lcp
|
package lcp
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -8,6 +7,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"github.com/hashicorp/golang-lru"
|
||||||
"github.com/pavelkrolevets/go-ethereum/accounts"
|
"github.com/pavelkrolevets/go-ethereum/accounts"
|
||||||
"github.com/pavelkrolevets/go-ethereum/common"
|
"github.com/pavelkrolevets/go-ethereum/common"
|
||||||
"github.com/pavelkrolevets/go-ethereum/consensus"
|
"github.com/pavelkrolevets/go-ethereum/consensus"
|
||||||
|
|
@ -16,15 +18,12 @@ import (
|
||||||
"github.com/pavelkrolevets/go-ethereum/core/types"
|
"github.com/pavelkrolevets/go-ethereum/core/types"
|
||||||
"github.com/pavelkrolevets/go-ethereum/crypto"
|
"github.com/pavelkrolevets/go-ethereum/crypto"
|
||||||
"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/log"
|
"github.com/pavelkrolevets/go-ethereum/log"
|
||||||
"github.com/pavelkrolevets/go-ethereum/params"
|
"github.com/pavelkrolevets/go-ethereum/params"
|
||||||
"github.com/pavelkrolevets/go-ethereum/rlp"
|
"github.com/pavelkrolevets/go-ethereum/rlp"
|
||||||
"github.com/pavelkrolevets/go-ethereum/rpc"
|
"github.com/pavelkrolevets/go-ethereum/rpc"
|
||||||
"github.com/hashicorp/golang-lru"
|
|
||||||
"encoding/binary"
|
|
||||||
"fmt"
|
|
||||||
"github.com/pavelkrolevets/go-ethereum/trie"
|
"github.com/pavelkrolevets/go-ethereum/trie"
|
||||||
"github.com/pavelkrolevets/go-ethereum/ethdb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -32,8 +31,7 @@ const (
|
||||||
extraSeal = 65 // Fixed number of extra-data suffix bytes reserved for signer seal
|
extraSeal = 65 // Fixed number of extra-data suffix bytes reserved for signer seal
|
||||||
inmemorySignatures = 4096 // Number of recent block signatures to keep in memory
|
inmemorySignatures = 4096 // Number of recent block signatures to keep in memory
|
||||||
|
|
||||||
|
)
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
big0 = big.NewInt(0)
|
big0 = big.NewInt(0)
|
||||||
|
|
@ -43,15 +41,12 @@ var (
|
||||||
byzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
|
byzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
|
||||||
timeOfFirstBlock = int64(0)
|
timeOfFirstBlock = int64(0)
|
||||||
confirmedBlockHead = []byte("confirmed-block-head")
|
confirmedBlockHead = []byte("confirmed-block-head")
|
||||||
blockInterval = int64(params.LcpChainConfig.LCP.Period*2/3+1)
|
blockInterval = int64(params.LcpChainConfig.LCP.Period*2/3 + 1)
|
||||||
consensusSize = int(params.LcpChainConfig.LCP.MaxValidators*2/3+1)
|
consensusSize = int(params.LcpChainConfig.LCP.MaxValidators*2/3 + 1)
|
||||||
safeSize = int(params.LcpChainConfig.LCP.MaxValidators*2/3+1)
|
safeSize = int(params.LcpChainConfig.LCP.MaxValidators*2/3 + 1)
|
||||||
epochInterval = int64(params.LcpChainConfig.LCP.EpochInterval)
|
epochInterval = int64(params.LcpChainConfig.LCP.EpochInterval)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// errUnknownBlock is returned when the list of signers is requested for a block
|
// errUnknownBlock is returned when the list of signers is requested for a block
|
||||||
// that is not part of the local blockchain.
|
// that is not part of the local blockchain.
|
||||||
|
|
@ -240,7 +235,7 @@ func (d *LCP) verifySeal(chain consensus.ChainReader, header *types.Header, pare
|
||||||
} else {
|
} else {
|
||||||
parent = chain.GetHeader(header.ParentHash, number-1)
|
parent = chain.GetHeader(header.ParentHash, number-1)
|
||||||
}
|
}
|
||||||
dposContext, err := types.NewLCPContextFromProto(d.db, parent.LCPContext)
|
dposContext, err := types.NewLCPContextFromProto(trie.NewDatabase(d.db), parent.LCPContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -316,7 +311,7 @@ func (d *LCP) updateConfirmedBlockHeader(chain consensus.ChainReader) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LCP) loadConfirmedBlockHeader(chain consensus.ChainReader) (*types.Header, error) {
|
func (s *LCP) loadConfirmedBlockHeader(chain consensus.ChainReader) (*types.Header, error) {
|
||||||
key, err:= s.db.Get(confirmedBlockHead)
|
key, err := s.db.Get(confirmedBlockHead)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -406,7 +401,7 @@ func (d *LCP) CheckValidator(lastBlock *types.Block, now int64) error {
|
||||||
if err := d.checkDeadline(lastBlock, now); err != nil {
|
if err := d.checkDeadline(lastBlock, now); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dposContext, err := types.NewLCPContextFromProto(d.db, lastBlock.Header().LCPContext)
|
dposContext, err := types.NewLCPContextFromProto(trie.NewDatabase(d.db), lastBlock.Header().LCPContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue