diff options
author | Wei-Ning Huang <w@cobinhood.com> | 2018-10-16 19:26:29 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 13:49:53 +0800 |
commit | b0d9fe6fa466b85aee325a36164ae2d7b5721602 (patch) | |
tree | df1a698c2c8a48d3fd30b0d43a13075198f093a8 /dex | |
parent | 0638a80a2e512e1ff1a89685f04ab0d50bae011c (diff) | |
download | dexon-b0d9fe6fa466b85aee325a36164ae2d7b5721602.tar dexon-b0d9fe6fa466b85aee325a36164ae2d7b5721602.tar.gz dexon-b0d9fe6fa466b85aee325a36164ae2d7b5721602.tar.bz2 dexon-b0d9fe6fa466b85aee325a36164ae2d7b5721602.tar.lz dexon-b0d9fe6fa466b85aee325a36164ae2d7b5721602.tar.xz dexon-b0d9fe6fa466b85aee325a36164ae2d7b5721602.tar.zst dexon-b0d9fe6fa466b85aee325a36164ae2d7b5721602.zip |
dex/core: misc bug fixes
Diffstat (limited to 'dex')
-rw-r--r-- | dex/api_backend.go | 3 | ||||
-rw-r--r-- | dex/app.go | 5 | ||||
-rw-r--r-- | dex/governance.go | 4 |
3 files changed, 10 insertions, 2 deletions
diff --git a/dex/api_backend.go b/dex/api_backend.go index 3c9be5f3d..4d0cdc9e9 100644 --- a/dex/api_backend.go +++ b/dex/api_backend.go @@ -79,6 +79,9 @@ func (b *DexAPIBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumb } func (b *DexAPIBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error) { + if blockNr == rpc.PendingBlockNumber { + blockNr = rpc.BlockNumber(b.dex.blockchain.CurrentBlock().Header().Number.Uint64()) + } header, err := b.HeaderByNumber(ctx, blockNr) if header == nil || err != nil { return nil, nil, err diff --git a/dex/app.go b/dex/app.go index 35a771460..85d7ea621 100644 --- a/dex/app.go +++ b/dex/app.go @@ -308,11 +308,12 @@ func (d *DexconApp) BlockDelivered(blockHash coreCommon.Hash, result coreTypes.F _, err = d.blockchain.InsertChain( []*types.Block{types.NewBlock(&types.Header{ - ParentHash: common.Hash(block.ParentHash), + ParentHash: d.blockchain.CurrentBlock().Hash(), Number: new(big.Int).SetUint64(result.Height), - Time: new(big.Int).SetInt64(result.Timestamp.Unix()), + Time: big.NewInt(result.Timestamp.Unix()), TxHash: types.DeriveSha(transactions), Coinbase: common.BytesToAddress(block.ProposerID.Hash[:]), + GasLimit: 800000, }, transactions, nil, nil)}) if err != nil { log.Error("insert chain", "error", err) diff --git a/dex/governance.go b/dex/governance.go index a78cf2d4f..19b9e578c 100644 --- a/dex/governance.go +++ b/dex/governance.go @@ -109,6 +109,10 @@ func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error { return err } + if nonce > 0 { + nonce += 1 + } + tx := types.NewTransaction( nonce, vm.GovernanceContractAddress, |