aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorWei-Ning Huang <w@cobinhood.com>2018-09-26 11:00:04 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:23:38 +0800
commit593c5d4c9efa80916cc4819797bfc42348a43502 (patch)
treeaa76753d1422ac664e9dd62b149458fdd294ada2 /dex
parent21cbe9d5b1630be351329a5715fd599030a00122 (diff)
downloadgo-tangerine-593c5d4c9efa80916cc4819797bfc42348a43502.tar
go-tangerine-593c5d4c9efa80916cc4819797bfc42348a43502.tar.gz
go-tangerine-593c5d4c9efa80916cc4819797bfc42348a43502.tar.bz2
go-tangerine-593c5d4c9efa80916cc4819797bfc42348a43502.tar.lz
go-tangerine-593c5d4c9efa80916cc4819797bfc42348a43502.tar.xz
go-tangerine-593c5d4c9efa80916cc4819797bfc42348a43502.tar.zst
go-tangerine-593c5d4c9efa80916cc4819797bfc42348a43502.zip
dex: update consensus core interface
Diffstat (limited to 'dex')
-rw-r--r--dex/app.go22
-rw-r--r--dex/backend.go9
-rw-r--r--dex/governance.go24
-rw-r--r--dex/network.go19
4 files changed, 38 insertions, 36 deletions
diff --git a/dex/app.go b/dex/app.go
index ab807e644..dee762540 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -26,37 +26,25 @@ import (
// DexconApp implementes the DEXON consensus core application interface.
type DexconApp struct {
txPool *core.TxPool
-
- witnessResultChan chan types.WitnessResult
}
func NewDexconApp(txPool *core.TxPool) *DexconApp {
return &DexconApp{
- txPool: txPool,
- witnessResultChan: make(chan types.WitnessResult),
+ txPool: txPool,
}
}
// PreparePayload is called when consensus core is preparing a block.
-func (d *DexconApp) PreparePayload(position types.Position) []byte {
- return nil
+func (d *DexconApp) PrepareBlock(position types.Position) (
+ payload []byte, witnessData []byte) {
+ return nil, nil
}
// VerifyPayload verifies if the payloads are valid.
-func (d *DexconApp) VerifyPayload(payload []byte) bool {
+func (d *DexconApp) VerifyBlock(block *types.Block) bool {
return true
}
// BlockDelivered is called when a block is add to the compaction chain.
func (d *DexconApp) BlockDelivered(block types.Block) {
}
-
-// BlockProcessedChan returns a channel to receive the block hashes that have
-// finished processing by the application.
-func (d *DexconApp) BlockProcessedChan() <-chan types.WitnessResult {
- return d.witnessResultChan
-}
-
-// WitnessAckDeliver is called when a notary ack is created.
-func (d *DexconApp) WitnessAckDelivered(notaryAck *types.WitnessAck) {
-}
diff --git a/dex/backend.go b/dex/backend.go
index 930d7886f..707b1abbb 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -20,15 +20,15 @@ package dex
import (
dexCore "github.com/dexon-foundation/dexon-consensus-core/core"
"github.com/dexon-foundation/dexon-consensus-core/core/blockdb"
- ethCrypto "github.com/dexon-foundation/dexon-consensus-core/crypto/eth"
+ "github.com/dexon-foundation/dexon-consensus-core/core/crypto/ecdsa"
- "github.com/dexon-foundation/dexon/internal/ethapi"
"github.com/dexon-foundation/dexon/accounts"
"github.com/dexon-foundation/dexon/consensus"
"github.com/dexon-foundation/dexon/core"
"github.com/dexon-foundation/dexon/core/bloombits"
"github.com/dexon-foundation/dexon/ethdb"
"github.com/dexon-foundation/dexon/event"
+ "github.com/dexon-foundation/dexon/internal/ethapi"
"github.com/dexon-foundation/dexon/node"
"github.com/dexon-foundation/dexon/p2p"
"github.com/dexon-foundation/dexon/params"
@@ -77,12 +77,11 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) {
network := NewDexconNetwork()
// TODO(w): replace this with node key.
- privKey, err := ethCrypto.NewPrivateKey()
+ privKey, err := ecdsa.NewPrivateKey()
if err != nil {
panic(err)
}
- consensus := dexCore.NewConsensus(
- app, gov, db, network, privKey, ethCrypto.SigToPub)
+ consensus := dexCore.NewConsensus(app, gov, db, network, privKey)
dex := &Dexon{
config: config,
diff --git a/dex/governance.go b/dex/governance.go
index fd52a8697..44df77361 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -1,6 +1,8 @@
package dex
import (
+ coreCommon "github.com/dexon-foundation/dexon-consensus-core/common"
+ "github.com/dexon-foundation/dexon-consensus-core/core/crypto"
"github.com/dexon-foundation/dexon-consensus-core/core/types"
)
@@ -13,15 +15,23 @@ func NewDexconGovernance() *DexconGovernance {
return &DexconGovernance{}
}
-// GetValidatorSet returns the current notary set.
-func (d *DexconGovernance) GetNotarySet(
- blockHeight uint64) map[types.NodeID]struct{} {
- return make(map[types.NodeID]struct{})
+// GetConfiguration return the total ordering K constant.
+func (d *DexconGovernance) GetConfiguration(round uint64) *types.Config {
+ return &types.Config{}
}
-// GetTotalOrderingK return the total ordering K constant.
-func (d *DexconGovernance) GetConfiguration(blockHeight uint64) *types.Config {
- return &types.Config{}
+// GetCRS returns the CRS for a given round.
+func (d *DexconGovernance) GetCRS(round uint64) coreCommon.Hash {
+ return coreCommon.Hash{}
+}
+
+// ProposeCRS send proposals of a new CRS
+func (d *DexconGovernance) ProposeCRS(round uint64, signedCRS []byte) {
+}
+
+// GetValidatorSet returns the current notary set.
+func (d *DexconGovernance) GetNodeSet(round uint64) []crypto.PublicKey {
+ return nil
}
// AddDKGComplaint adds a DKGComplaint.
diff --git a/dex/network.go b/dex/network.go
index a12e357eb..a186921a4 100644
--- a/dex/network.go
+++ b/dex/network.go
@@ -1,6 +1,9 @@
package dex
-import "github.com/dexon-foundation/dexon-consensus-core/core/types"
+import (
+ "github.com/dexon-foundation/dexon-consensus-core/core/crypto"
+ "github.com/dexon-foundation/dexon-consensus-core/core/types"
+)
type DexconNetwork struct {
receiveChan chan interface{}
@@ -20,18 +23,20 @@ func (n *DexconNetwork) BroadcastVote(vote *types.Vote) {
func (n *DexconNetwork) BroadcastBlock(block *types.Block) {
}
-// BroadcastWitnessAck broadcasts witnessAck to all nodes in DEXON network.
-func (n *DexconNetwork) BroadcastWitnessAck(witnessAck *types.WitnessAck) {
-}
-
// SendDKGPrivateShare sends PrivateShare to a DKG participant.
func (n *DexconNetwork) SendDKGPrivateShare(
- recv types.NodeID, prvShare *types.DKGPrivateShare) {
+ pub crypto.PublicKey, prvShare *types.DKGPrivateShare) {
}
// BroadcastDKGPrivateShare broadcasts PrivateShare to all DKG participants.
func (n *DexconNetwork) BroadcastDKGPrivateShare(
- prvShare *types.DKGPrivateShare) {
+ prvShare *types.DKGPrivateShare) {
+}
+
+// BroadcastDKGPartialSignature broadcasts partialSignature to all
+// DKG participants.
+func (n *DexconNetwork) BroadcastDKGPartialSignature(
+ psig *types.DKGPartialSignature) {
}
// ReceiveChan returns a channel to receive messages from DEXON network.