diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-03-17 09:12:50 +0800 |
---|---|---|
committer | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-17 09:12:50 +0800 |
commit | 6091c2de57fee155e5d7f512b326bde53c84c04e (patch) | |
tree | 7625cec0e792068b5945d3dda9bb4998457df7b4 /core/vm | |
parent | 8ff31f980a7e169dda85cd77f88f56d03788a135 (diff) | |
download | dexon-6091c2de57fee155e5d7f512b326bde53c84c04e.tar.gz dexon-6091c2de57fee155e5d7f512b326bde53c84c04e.tar.zst dexon-6091c2de57fee155e5d7f512b326bde53c84c04e.zip |
dex: implement recovery mechanism (#258)
* dex: implement recovery mechanism
The DEXON recovery protocol allows us to use the Ethereum blockchain as a
fallback consensus chain to coordinate recovery.
* fix
Diffstat (limited to 'core/vm')
-rw-r--r-- | core/vm/oracle_contracts.go | 8 | ||||
-rw-r--r-- | core/vm/oracle_contracts_test.go | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go index 37e734a5f..d983cdfc8 100644 --- a/core/vm/oracle_contracts.go +++ b/core/vm/oracle_contracts.go @@ -95,7 +95,7 @@ func publicKeyToNodeKeyAddress(pkBytes []byte) (common.Address, error) { return crypto.PubkeyToAddress(*pk), nil } -func idToAddress(id coreTypes.NodeID) common.Address { +func IdToAddress(id coreTypes.NodeID) common.Address { return common.BytesToAddress(id.Hash[12:]) } @@ -517,7 +517,7 @@ func (s *GovernanceState) DeleteNodeOffsets(n *nodeInfo) error { } func (s *GovernanceState) GetNodeByID(id coreTypes.NodeID) (*nodeInfo, error) { - offset := s.NodesOffsetByNodeKeyAddress(idToAddress(id)) + offset := s.NodesOffsetByNodeKeyAddress(IdToAddress(id)) if offset.Cmp(big.NewInt(0)) < 0 { return nil, errors.New("node not found") } @@ -630,7 +630,7 @@ func (s *GovernanceState) PutDKGMPKReady(addr common.Address, ready bool) { } func (s *GovernanceState) ClearDKGMPKReady(dkgSet map[coreTypes.NodeID]struct{}) { for id := range dkgSet { - s.PutDKGMPKReady(idToAddress(id), false) + s.PutDKGMPKReady(IdToAddress(id), false) } } @@ -661,7 +661,7 @@ func (s *GovernanceState) PutDKGFinalized(addr common.Address, finalized bool) { } func (s *GovernanceState) ClearDKGFinalized(dkgSet map[coreTypes.NodeID]struct{}) { for id := range dkgSet { - s.PutDKGFinalized(idToAddress(id), false) + s.PutDKGFinalized(IdToAddress(id), false) } } diff --git a/core/vm/oracle_contracts_test.go b/core/vm/oracle_contracts_test.go index 4539f0864..6e2a7fc7f 100644 --- a/core/vm/oracle_contracts_test.go +++ b/core/vm/oracle_contracts_test.go @@ -933,7 +933,7 @@ func (g *OracleContractsTestSuite) TestResetDKG() { dkgSets[round] = dkgSet for id := range dkgSet { - offset := g.s.NodesOffsetByNodeKeyAddress(idToAddress(id)) + offset := g.s.NodesOffsetByNodeKeyAddress(IdToAddress(id)) if offset.Cmp(big.NewInt(0)) < 0 { panic("DKG node does not exist") } |