aboutsummaryrefslogtreecommitdiffstats
path: root/simulation
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-01 18:19:52 +0800
committerGitHub <noreply@github.com>2018-10-01 18:19:52 +0800
commit9c33b9dc8aa59d414a6697f1e2d036e5581860ee (patch)
tree74a4a77b5c28fa9a550fe1ba40b5b2efac0e7630 /simulation
parent9b78db7a4744176070bf968d50dbebb191b28b69 (diff)
downloaddexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.gz
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.bz2
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.lz
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.xz
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.zst
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.zip
core: update data model to reflect new model (#157)
Update data model: 1) Remove witness ack. 2) Add round to block. 3) Update governance interface.
Diffstat (limited to 'simulation')
-rw-r--r--simulation/app.go29
-rw-r--r--simulation/marshaller.go8
-rw-r--r--simulation/network.go9
3 files changed, 6 insertions, 40 deletions
diff --git a/simulation/app.go b/simulation/app.go
index cb8c129..5f1a85a 100644
--- a/simulation/app.go
+++ b/simulation/app.go
@@ -40,7 +40,6 @@ type simApp struct {
unconfirmedBlocks map[types.NodeID]common.Hashes
blockByHash map[common.Hash]*types.Block
blockByHashMutex sync.RWMutex
- witnessResultChan chan types.WitnessResult
}
// newSimApp returns point to a new instance of simApp.
@@ -52,7 +51,6 @@ func newSimApp(id types.NodeID, netModule *network) *simApp {
blockSeen: make(map[common.Hash]time.Time),
unconfirmedBlocks: make(map[types.NodeID]common.Hashes),
blockByHash: make(map[common.Hash]*types.Block),
- witnessResultChan: make(chan types.WitnessResult),
}
}
@@ -60,8 +58,8 @@ func newSimApp(id types.NodeID, netModule *network) *simApp {
func (a *simApp) BlockConfirmed(_ common.Hash) {
}
-// VerifyPayload implements core.Application.
-func (a *simApp) VerifyPayload(payload []byte) bool {
+// VerifyBlock implements core.Application.
+func (a *simApp) VerifyBlock(block *types.Block) bool {
return true
}
@@ -91,9 +89,9 @@ func (a *simApp) getAckedBlocks(ackHash common.Hash) (output common.Hashes) {
return
}
-// PreparePayload implements core.Application.
-func (a *simApp) PreparePayload(position types.Position) []byte {
- return []byte{}
+// PrepareBlock implements core.Application.
+func (a *simApp) PrepareBlock(position types.Position) ([]byte, []byte) {
+ return []byte{}, []byte{}
}
// StronglyAcked is called when a block is strongly acked by DEXON
@@ -150,21 +148,4 @@ func (a *simApp) BlockDelivered(block types.Block) {
Payload: jsonPayload,
}
a.netModule.report(msg)
-
- go func() {
- a.witnessResultChan <- types.WitnessResult{
- BlockHash: block.Hash,
- Data: []byte(fmt.Sprintf("Block %s", block.Hash)),
- }
- }()
-}
-
-// BlockProcessedChan returns a channel to receive the block hashes that have
-// finished processing by the application.
-func (a *simApp) BlockProcessedChan() <-chan types.WitnessResult {
- return a.witnessResultChan
-}
-
-// WitnessAckDelivered is called when a witness ack is created.
-func (a *simApp) WitnessAckDelivered(witnessAck *types.WitnessAck) {
}
diff --git a/simulation/marshaller.go b/simulation/marshaller.go
index f2d17af..cdf080b 100644
--- a/simulation/marshaller.go
+++ b/simulation/marshaller.go
@@ -57,12 +57,6 @@ func (m *jsonMarshaller) Unmarshal(
break
}
msg = block
- case "witness-ack":
- nAck := &types.WitnessAck{}
- if err = json.Unmarshal(payload, nAck); err != nil {
- break
- }
- msg = nAck
case "vote":
vote := &types.Vote{}
if err = json.Unmarshal(payload, vote); err != nil {
@@ -115,8 +109,6 @@ func (m *jsonMarshaller) Marshal(msg interface{}) (
msgType = "info-status"
case *types.Block:
msgType = "block"
- case *types.WitnessAck:
- msgType = "witness-ack"
case *types.Vote:
msgType = "vote"
case *types.DKGPrivateShare:
diff --git a/simulation/network.go b/simulation/network.go
index f1f586a..0faacf7 100644
--- a/simulation/network.go
+++ b/simulation/network.go
@@ -132,13 +132,6 @@ func (n *network) BroadcastBlock(block *types.Block) {
}
}
-// BroadcastWitnessAck implements core.Network interface.
-func (n *network) BroadcastWitnessAck(witnessAck *types.WitnessAck) {
- if err := n.trans.Broadcast(witnessAck); err != nil {
- panic(err)
- }
-}
-
// broadcast message to all other nodes in the network.
func (n *network) broadcast(message interface{}) {
if err := n.trans.Broadcast(message); err != nil {
@@ -205,7 +198,7 @@ func (n *network) run() {
// to consensus or node, that's the question.
disp := func(e *test.TransportEnvelope) {
switch e.Msg.(type) {
- case *types.Block, *types.Vote, *types.WitnessAck,
+ case *types.Block, *types.Vote,
*types.DKGPrivateShare, *types.DKGPartialSignature:
n.toConsensus <- e.Msg
default: