aboutsummaryrefslogtreecommitdiffstats
path: root/blockdb
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-09-03 10:01:40 +0800
committerGitHub <noreply@github.com>2018-09-03 10:01:40 +0800
commitc8d3092208f73ee991a123052a71b7dbf7fffc27 (patch)
treefdcb3b90b859531e042dbbdd6bcd7b0cca40e86a /blockdb
parent9491ddae81640e04f8aed38e2cddeb64cc62d55b (diff)
downloadtangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar
tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.gz
tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.bz2
tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.lz
tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.xz
tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.zst
tangerine-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.zip
core: Add a new structure `Position` and move `ShardID`, `ChainID` and `Height` from `Block` (#89)
Diffstat (limited to 'blockdb')
-rw-r--r--blockdb/level-db_test.go10
-rw-r--r--blockdb/memory_test.go14
2 files changed, 17 insertions, 7 deletions
diff --git a/blockdb/level-db_test.go b/blockdb/level-db_test.go
index f6c14c5..d1c8146 100644
--- a/blockdb/level-db_test.go
+++ b/blockdb/level-db_test.go
@@ -55,7 +55,9 @@ func (s *LevelDBTestSuite) TestBasicUsage() {
block1 := types.Block{
ProposerID: validator1,
Hash: hash1,
- Height: 1,
+ Position: types.Position{
+ Height: 1,
+ },
}
err = db.Update(block1)
s.Equal(ErrBlockDoesNotExist, err)
@@ -102,7 +104,9 @@ func (s *LevelDBTestSuite) TestSyncIndex() {
block := types.Block{
ProposerID: types.ValidatorID{Hash: common.NewRandomHash()},
Hash: common.NewRandomHash(),
- Height: uint64(i),
+ Position: types.Position{
+ Height: uint64(i),
+ },
}
db.Put(block)
blocks[i] = block
@@ -121,7 +125,7 @@ func (s *LevelDBTestSuite) TestSyncIndex() {
queried, err := db.Get(block.Hash)
s.Nil(err)
s.Equal(block.ProposerID, queried.ProposerID)
- s.Equal(block.Height, queried.Height)
+ s.Equal(block.Position.Height, queried.Position.Height)
}
}
diff --git a/blockdb/memory_test.go b/blockdb/memory_test.go
index 9394c26..5c1261d 100644
--- a/blockdb/memory_test.go
+++ b/blockdb/memory_test.go
@@ -41,14 +41,18 @@ func (s *MemBackedBlockDBTestSuite) SetupSuite() {
ProposerID: s.v0,
ParentHash: genesisHash,
Hash: genesisHash,
- Height: 0,
- Acks: make(map[common.Hash]struct{}),
+ Position: types.Position{
+ Height: 0,
+ },
+ Acks: make(map[common.Hash]struct{}),
}
s.b01 = &types.Block{
ProposerID: s.v0,
ParentHash: s.b00.Hash,
Hash: common.NewRandomHash(),
- Height: 1,
+ Position: types.Position{
+ Height: 1,
+ },
Acks: map[common.Hash]struct{}{
s.b00.Hash: struct{}{},
},
@@ -57,7 +61,9 @@ func (s *MemBackedBlockDBTestSuite) SetupSuite() {
ProposerID: s.v0,
ParentHash: s.b01.Hash,
Hash: common.NewRandomHash(),
- Height: 2,
+ Position: types.Position{
+ Height: 2,
+ },
Acks: map[common.Hash]struct{}{
s.b01.Hash: struct{}{},
},