aboutsummaryrefslogtreecommitdiffstats
path: root/core/dexon_chain_makers.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:31:08 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-09-17 16:57:29 +0800
commitac088de6322fc16ebe75c2e5554be73754bf1fe2 (patch)
tree086b7827d46a4d07b834cd94be73beaabb77b734 /core/dexon_chain_makers.go
parent67d565f3f0e398e99bef96827f729e3e4b0edf31 (diff)
downloadgo-tangerine-ac088de6322fc16ebe75c2e5554be73754bf1fe2.tar
go-tangerine-ac088de6322fc16ebe75c2e5554be73754bf1fe2.tar.gz
go-tangerine-ac088de6322fc16ebe75c2e5554be73754bf1fe2.tar.bz2
go-tangerine-ac088de6322fc16ebe75c2e5554be73754bf1fe2.tar.lz
go-tangerine-ac088de6322fc16ebe75c2e5554be73754bf1fe2.tar.xz
go-tangerine-ac088de6322fc16ebe75c2e5554be73754bf1fe2.tar.zst
go-tangerine-ac088de6322fc16ebe75c2e5554be73754bf1fe2.zip
Rebrand as tangerine-network/go-tangerine
Diffstat (limited to 'core/dexon_chain_makers.go')
-rw-r--r--core/dexon_chain_makers.go82
1 files changed, 41 insertions, 41 deletions
diff --git a/core/dexon_chain_makers.go b/core/dexon_chain_makers.go
index 010b30c84..2fdee2eca 100644
--- a/core/dexon_chain_makers.go
+++ b/core/dexon_chain_makers.go
@@ -22,25 +22,25 @@ import (
"math/rand"
"time"
- coreTypes "github.com/dexon-foundation/dexon-consensus/core/types"
-
- "github.com/dexon-foundation/dexon/common"
- "github.com/dexon-foundation/dexon/consensus"
- "github.com/dexon-foundation/dexon/core/state"
- "github.com/dexon-foundation/dexon/core/types"
- "github.com/dexon-foundation/dexon/core/vm"
- "github.com/dexon-foundation/dexon/ethdb"
- "github.com/dexon-foundation/dexon/params"
- "github.com/dexon-foundation/dexon/rlp"
+ coreTypes "github.com/byzantine-lab/dexon-consensus/core/types"
+
+ "github.com/tangerine-network/go-tangerine/common"
+ "github.com/tangerine-network/go-tangerine/consensus"
+ "github.com/tangerine-network/go-tangerine/core/state"
+ "github.com/tangerine-network/go-tangerine/core/types"
+ "github.com/tangerine-network/go-tangerine/core/vm"
+ "github.com/tangerine-network/go-tangerine/ethdb"
+ "github.com/tangerine-network/go-tangerine/params"
+ "github.com/tangerine-network/go-tangerine/rlp"
)
func init() {
rand.Seed(time.Now().UTC().UnixNano())
}
-// DexonBlockGen creates blocks for testing.
+// TangerineBlockGen creates blocks for testing.
// See GenerateChain for a detailed explanation.
-type DexonBlockGen struct {
+type TangerineBlockGen struct {
i int
parent *types.Block
chain []*types.Block
@@ -61,7 +61,7 @@ type DexonBlockGen struct {
// SetCoinbase sets the coinbase of the generated block.
// It can be called at most once.
-func (b *DexonBlockGen) SetCoinbase(addr common.Address) {
+func (b *TangerineBlockGen) SetCoinbase(addr common.Address) {
if b.gasPool != nil {
if len(b.txs) > 0 {
panic("coinbase must be set before adding transactions")
@@ -73,16 +73,16 @@ func (b *DexonBlockGen) SetCoinbase(addr common.Address) {
}
// SetExtra sets the extra data field of the generated block.
-func (b *DexonBlockGen) SetExtra(data []byte) {
+func (b *TangerineBlockGen) SetExtra(data []byte) {
b.header.Extra = data
}
// SetNonce sets the nonce field of the generated block.
-func (b *DexonBlockGen) SetNonce(nonce types.BlockNonce) {
+func (b *TangerineBlockGen) SetNonce(nonce types.BlockNonce) {
b.header.Nonce = nonce
}
-func (b *DexonBlockGen) SetPosition(position coreTypes.Position) {
+func (b *TangerineBlockGen) SetPosition(position coreTypes.Position) {
b.position = position
}
@@ -94,16 +94,16 @@ func (b *DexonBlockGen) SetPosition(position coreTypes.Position) {
// further limitations on the content of transactions that can be
// added. If contract code relies on the BLOCKHASH instruction,
// the block in chain will be returned.
-func (b *DexonBlockGen) AddTx(tx *types.Transaction) {
+func (b *TangerineBlockGen) AddTx(tx *types.Transaction) {
// TODO: check nonce and maintain nonce.
b.txs = append(b.txs, tx)
}
-func (b *DexonBlockGen) PreparePayload() []byte {
+func (b *TangerineBlockGen) PreparePayload() []byte {
return nil
}
-func (b *DexonBlockGen) ProcessTransactions(c ChainContext) {
+func (b *TangerineBlockGen) ProcessTransactions(c ChainContext) {
if b.gasPool == nil {
b.SetCoinbase(common.Address{})
}
@@ -119,7 +119,7 @@ func (b *DexonBlockGen) ProcessTransactions(c ChainContext) {
}
// Number returns the block number of the block being generated.
-func (b *DexonBlockGen) Number() *big.Int {
+func (b *TangerineBlockGen) Number() *big.Int {
return new(big.Int).Set(b.header.Number)
}
@@ -128,13 +128,13 @@ func (b *DexonBlockGen) Number() *big.Int {
//
// AddUncheckedReceipt will cause consensus failures when used during real
// chain processing. This is best used in conjunction with raw block insertion.
-func (b *DexonBlockGen) AddUncheckedReceipt(receipt *types.Receipt) {
+func (b *TangerineBlockGen) AddUncheckedReceipt(receipt *types.Receipt) {
b.receipts = append(b.receipts, receipt)
}
// TxNonce returns the next valid transaction nonce for the
// account at addr. It panics if the account does not exist.
-func (b *DexonBlockGen) TxNonce(addr common.Address) uint64 {
+func (b *TangerineBlockGen) TxNonce(addr common.Address) uint64 {
if !b.statedb.Exist(addr) {
panic("account does not exist")
}
@@ -147,7 +147,7 @@ func (b *DexonBlockGen) TxNonce(addr common.Address) uint64 {
// PrevBlock returns a previously generated block by number. It panics if
// num is greater or equal to the number of the block being generated.
// For index -1, PrevBlock returns the parent block given to GenerateChain.
-func (b *DexonBlockGen) PrevBlock(index int) *types.Block {
+func (b *TangerineBlockGen) PrevBlock(index int) *types.Block {
if index >= b.i {
panic(fmt.Errorf("block index %d out of range (%d,%d)", index, -1, b.i))
}
@@ -157,7 +157,7 @@ func (b *DexonBlockGen) PrevBlock(index int) *types.Block {
return b.chain[index]
}
-func GenerateDexonChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, db ethdb.Database, n int, gen func(int, *DexonBlockGen)) ([]*types.Block, []types.Receipts) {
+func GenerateTangerineChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, db ethdb.Database, n int, gen func(int, *TangerineBlockGen)) ([]*types.Block, []types.Receipts) {
if config == nil {
config = params.TestChainConfig
}
@@ -165,7 +165,7 @@ func GenerateDexonChain(config *params.ChainConfig, parent *types.Block, engine
panic("engine is nil")
}
blocks, receipts := make(types.Blocks, n), make([]types.Receipts, n)
- chain := &fakeDexonChain{
+ chain := &fakeTangerineChain{
config: config,
engine: engine,
genesis: parent,
@@ -174,8 +174,8 @@ func GenerateDexonChain(config *params.ChainConfig, parent *types.Block, engine
roundHeight: make(map[uint64]uint64),
}
genblock := func(i int, parent *types.Block, statedb *state.StateDB) (*types.Block, types.Receipts) {
- b := &DexonBlockGen{i: i, chain: blocks, parent: parent, statedb: statedb, config: config, engine: engine}
- b.header = makeDexonHeader(chain, parent, statedb, b.engine)
+ b := &TangerineBlockGen{i: i, chain: blocks, parent: parent, statedb: statedb, config: config, engine: engine}
+ b.header = makeTangerineHeader(chain, parent, statedb, b.engine)
// Execute any user modifications to the block
if gen != nil {
@@ -218,7 +218,7 @@ func GenerateDexonChain(config *params.ChainConfig, parent *types.Block, engine
return blocks, receipts
}
-func makeDexonHeader(chain consensus.ChainReader, parent *types.Block, state *state.StateDB, engine consensus.Engine) *types.Header {
+func makeTangerineHeader(chain consensus.ChainReader, parent *types.Block, state *state.StateDB, engine consensus.Engine) *types.Header {
var time uint64
if parent.Time() == 0 {
time = 10
@@ -238,7 +238,7 @@ func makeDexonHeader(chain consensus.ChainReader, parent *types.Block, state *st
}
// Setup DexconMeata skeleton
-func makeDexconMeta(b *DexonBlockGen, parent *types.Block) []byte {
+func makeDexconMeta(b *TangerineBlockGen, parent *types.Block) []byte {
// Setup witness
h := parent.Number().Int64() - rand.Int63n(6)
if h < 0 {
@@ -269,7 +269,7 @@ func makeDexconMeta(b *DexonBlockGen, parent *types.Block) []byte {
return dexconMeta
}
-type fakeDexonChain struct {
+type fakeTangerineChain struct {
config *params.ChainConfig
engine consensus.Engine
db ethdb.Database
@@ -278,7 +278,7 @@ type fakeDexonChain struct {
roundHeight map[uint64]uint64
}
-func (f *fakeDexonChain) InsertBlock(block *types.Block) {
+func (f *fakeTangerineChain) InsertBlock(block *types.Block) {
f.headersByNumber[block.NumberU64()] = block.Header()
if _, exists := f.roundHeight[block.Round()]; !exists {
f.roundHeight[block.Round()] = block.NumberU64()
@@ -286,25 +286,25 @@ func (f *fakeDexonChain) InsertBlock(block *types.Block) {
}
// Config returns the chain configuration.
-func (f *fakeDexonChain) Config() *params.ChainConfig { return f.config }
-func (f *fakeDexonChain) Engine() consensus.Engine { return f.engine }
-func (f *fakeDexonChain) CurrentHeader() *types.Header { return nil }
-func (f *fakeDexonChain) GetHeaderByHash(hash common.Hash) *types.Header { return nil }
-func (f *fakeDexonChain) GetHeader(hash common.Hash, number uint64) *types.Header { return nil }
-func (f *fakeDexonChain) GetBlock(hash common.Hash, number uint64) *types.Block { return nil }
-
-func (f *fakeDexonChain) GetHeaderByNumber(number uint64) *types.Header {
+func (f *fakeTangerineChain) Config() *params.ChainConfig { return f.config }
+func (f *fakeTangerineChain) Engine() consensus.Engine { return f.engine }
+func (f *fakeTangerineChain) CurrentHeader() *types.Header { return nil }
+func (f *fakeTangerineChain) GetHeaderByHash(hash common.Hash) *types.Header { return nil }
+func (f *fakeTangerineChain) GetHeader(hash common.Hash, number uint64) *types.Header { return nil }
+func (f *fakeTangerineChain) GetBlock(hash common.Hash, number uint64) *types.Block { return nil }
+
+func (f *fakeTangerineChain) GetHeaderByNumber(number uint64) *types.Header {
if number == 0 {
return f.genesis.Header()
}
return f.headersByNumber[number]
}
-func (f *fakeDexonChain) StateAt(hash common.Hash) (*state.StateDB, error) {
+func (f *fakeTangerineChain) StateAt(hash common.Hash) (*state.StateDB, error) {
return state.New(hash, state.NewDatabase(f.db))
}
-func (f *fakeDexonChain) GetRoundHeight(round uint64) (uint64, bool) {
+func (f *fakeTangerineChain) GetRoundHeight(round uint64) (uint64, bool) {
if round == 0 {
return 0, true
}