aboutsummaryrefslogtreecommitdiffstats
path: root/dex/app.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-04-01 18:01:26 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commitbde4a6cc02c6806093d2a49a86463f81358ca3d8 (patch)
treebc3d617f8ff755f6cca5c4fc1dff7b5457845c9f /dex/app.go
parent3c0372165e723de9f1bd3ea8dacd579810463f6d (diff)
downloadgo-tangerine-bde4a6cc02c6806093d2a49a86463f81358ca3d8.tar
go-tangerine-bde4a6cc02c6806093d2a49a86463f81358ca3d8.tar.gz
go-tangerine-bde4a6cc02c6806093d2a49a86463f81358ca3d8.tar.bz2
go-tangerine-bde4a6cc02c6806093d2a49a86463f81358ca3d8.tar.lz
go-tangerine-bde4a6cc02c6806093d2a49a86463f81358ca3d8.tar.xz
go-tangerine-bde4a6cc02c6806093d2a49a86463f81358ca3d8.tar.zst
go-tangerine-bde4a6cc02c6806093d2a49a86463f81358ca3d8.zip
vendor: sync to latest core (#320)
* vendor: sync to latest core * dex, core: fix conflict x
Diffstat (limited to 'dex/app.go')
-rw-r--r--dex/app.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/dex/app.go b/dex/app.go
index 9a72d7795..5a268a09d 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -162,9 +162,9 @@ func (d *DexconApp) preparePayload(ctx context.Context, position coreTypes.Posit
default:
}
- // deliver height = position height + 1
- if d.deliveredHeight+d.undeliveredNum != position.Height {
- return nil, fmt.Errorf("expected height %d but get %d", d.deliveredHeight+d.undeliveredNum, position.Height)
+ // deliver height + 1 = position height
+ if d.deliveredHeight+d.undeliveredNum+1 != position.Height {
+ return nil, fmt.Errorf("expected height %d but get %d", d.deliveredHeight+d.undeliveredNum+1, position.Height)
}
deliveredBlock := d.blockchain.GetBlockByNumber(d.deliveredHeight)
@@ -308,8 +308,8 @@ func (d *DexconApp) VerifyBlock(block *coreTypes.Block) coreTypes.BlockVerifySta
d.appMu.RLock()
defer d.appMu.RUnlock()
- // deliver height = position height + 1
- if d.deliveredHeight+d.undeliveredNum != block.Position.Height {
+ // deliver height + 1 = position height
+ if d.deliveredHeight+d.undeliveredNum+1 != block.Position.Height {
return coreTypes.VerifyRetryLater
}
@@ -414,10 +414,10 @@ func (d *DexconApp) VerifyBlock(block *coreTypes.Block) coreTypes.BlockVerifySta
func (d *DexconApp) BlockDelivered(
blockHash coreCommon.Hash,
blockPosition coreTypes.Position,
- result coreTypes.FinalizationResult) {
+ rand []byte) {
- log.Debug("DexconApp block deliver", "height", result.Height, "hash", blockHash, "position", blockPosition.String())
- defer log.Debug("DexconApp block delivered", "height", result.Height, "hash", blockHash, "position", blockPosition.String())
+ log.Debug("DexconApp block deliver", "hash", blockHash, "position", blockPosition.String())
+ defer log.Debug("DexconApp block delivered", "hash", blockHash, "position", blockPosition.String())
d.appMu.Lock()
defer d.appMu.Unlock()
@@ -428,7 +428,7 @@ func (d *DexconApp) BlockDelivered(
}
block.Payload = nil
- block.Finalization = result
+ block.Randomness = rand
dexconMeta, err := rlp.EncodeToBytes(block)
if err != nil {
panic(err)
@@ -445,14 +445,14 @@ func (d *DexconApp) BlockDelivered(
}
newBlock := types.NewBlock(&types.Header{
- Number: new(big.Int).SetUint64(result.Height),
- Time: big.NewInt(result.Timestamp.UnixNano() / 1000000),
+ Number: new(big.Int).SetUint64(block.Position.Height),
+ Time: uint64(block.Timestamp.UnixNano() / 1000000),
Coinbase: owner,
GasLimit: d.gov.DexconConfiguration(block.Position.Round).BlockGasLimit,
Difficulty: big.NewInt(1),
Round: block.Position.Round,
DexconMeta: dexconMeta,
- Randomness: result.Randomness,
+ Randomness: block.Randomness,
}, txs, nil, nil)
if block.IsEmpty() {
@@ -470,7 +470,7 @@ func (d *DexconApp) BlockDelivered(
}
d.removeConfirmedBlock(blockHash)
- d.deliveredHeight = result.Height
+ d.deliveredHeight = block.Position.Height
// New blocks are finalized, notify other components.
go d.finalizedBlockFeed.Send(core.NewFinalizedBlockEvent{Block: d.blockchain.CurrentBlock()})