diff --git a/core/service/blockCoreService_test.go b/core/service/blockCoreService_test.go index 48a74b5e7..e66582ede 100644 --- a/core/service/blockCoreService_test.go +++ b/core/service/blockCoreService_test.go @@ -929,16 +929,16 @@ func TestBlockService_VerifySeed(t *testing.T) { } var mockBlocksmiths = &[]model.Blocksmith{ - { - NodePublicKey: bcsNodePubKey1, - NodeID: 2, - NodeOrder: new(big.Int).SetInt64(1000), - }, { NodePublicKey: bcsNodePubKey2, NodeID: 3, NodeOrder: new(big.Int).SetInt64(2000), }, + { + NodePublicKey: bcsNodePubKey1, + NodeID: 2, + NodeOrder: new(big.Int).SetInt64(1000), + }, } func TestBlockService_PushBlock(t *testing.T) { diff --git a/core/util/blockUtil.go b/core/util/blockUtil.go index dff62f951..583b6d90c 100644 --- a/core/util/blockUtil.go +++ b/core/util/blockUtil.go @@ -156,7 +156,9 @@ func IsBlockIDExist(blockIds []int64, expectedBlockID int64) bool { // CalculateSmithOrder calculate the blocksmith order parameter, used to sort/select the next blocksmith func CalculateSmithOrder(score, blockSeed *big.Int, nodeID int64) *big.Int { prn := crypto.PseudoRandomGenerator(uint64(nodeID), blockSeed.Uint64(), crypto.PseudoRandomSha3256) - return new(big.Int).Mul(score, new(big.Int).SetUint64(prn)) + // Currently score did'nt use , + // But when use score in calculating Smith Order, prn should multiply by score + return new(big.Int).SetUint64(prn) } // CalculateNodeOrder calculate the Node order parameter, used to sort/select the group of blocksmith rewarded for a given block diff --git a/core/util/blockUtil_test.go b/core/util/blockUtil_test.go index a84b369ca..bc3c1205d 100644 --- a/core/util/blockUtil_test.go +++ b/core/util/blockUtil_test.go @@ -355,7 +355,7 @@ func TestCalculateSmithOrder(t *testing.T) { blockSeed: new(big.Int).SetInt64(1000), nodeID: int64(1000), }, - want: "7357219233906154824000", + want: "7357219233906154824", }, { name: "CalculateSmithOrder:success2", @@ -364,7 +364,7 @@ func TestCalculateSmithOrder(t *testing.T) { blockSeed: new(big.Int).SetInt64(3000), nodeID: int64(10), }, - want: "9845301605531286876000", + want: "4922650802765643438", }, } for _, tt := range tests { diff --git a/main.go b/main.go index d1aa28553..03a5b4365 100644 --- a/main.go +++ b/main.go @@ -377,11 +377,7 @@ func startMainchain(mainchainSyncChannel chan bool) { loggerCoreService.Fatal(err) } - // Check computer/node local time. Comparing with last block timestamp - // NEXT: maybe can check timestamp from last block of blockchain network or network time protocol - if time.Now().Unix() < lastBlockAtStart.GetTimestamp() { - loggerCoreService.Fatal("Your computer clock is behind from the correct time") - } + // TODO: Check computer/node local time. Comparing with last block timestamp // initializing scrambled nodes heightToBuildScrambleNodes := nodeRegistrationService.GetBlockHeightToBuildScrambleNodes(lastBlockAtStart.GetHeight())