From bee0893660e26bd9ee2abc739c146172244fff44 Mon Sep 17 00:00:00 2001 From: Svarog Date: Mon, 22 Feb 2021 11:33:39 +0200 Subject: [PATCH] Renamed BlueBlockWindow to just BlockWindow (#1547) * Renamed BlueBlockWindow to just BlockWindow * Update comment --- .../interface_processes_dagtraversalmanager.go | 2 +- .../processes/dagtraversalmanager/window.go | 8 ++++---- .../dagtraversalmanager/window_test.go | 8 ++++---- .../processes/difficultymanager/blockwindow.go | 17 +++++++++-------- .../difficultymanager/difficultymanager.go | 5 +++-- .../pastmediantimemanager.go | 2 +- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/domain/consensus/model/interface_processes_dagtraversalmanager.go b/domain/consensus/model/interface_processes_dagtraversalmanager.go index 9f06135d8..9101da297 100644 --- a/domain/consensus/model/interface_processes_dagtraversalmanager.go +++ b/domain/consensus/model/interface_processes_dagtraversalmanager.go @@ -11,7 +11,7 @@ type DAGTraversalManager interface { // from lowHash (exclusive) to highHash (inclusive) over highHash's selected parent chain SelectedChildIterator(highHash, lowHash *externalapi.DomainHash) (BlockIterator, error) Anticone(blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) - BlueWindow(highHash *externalapi.DomainHash, windowSize int) ([]*externalapi.DomainHash, error) + BlockWindow(highHash *externalapi.DomainHash, windowSize int) ([]*externalapi.DomainHash, error) NewDownHeap() BlockHeap NewUpHeap() BlockHeap CalculateChainPath( diff --git a/domain/consensus/processes/dagtraversalmanager/window.go b/domain/consensus/processes/dagtraversalmanager/window.go index a8d806a78..cff3f6906 100644 --- a/domain/consensus/processes/dagtraversalmanager/window.go +++ b/domain/consensus/processes/dagtraversalmanager/window.go @@ -4,11 +4,11 @@ import ( "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" ) -// blueBlockWindow returns a blockWindow of the given size that contains the -// blues in the past of startindNode, the sorting is unspecified. -// If the number of blues in the past of startingNode is less then windowSize, +// BlockWindow returns a blockWindow of the given size that contains the +// blocks in the past of startindNode, the sorting is unspecified. +// If the number of blocks in the past of startingNode is less then windowSize, // the window will be padded by genesis blocks to achieve a size of windowSize. -func (dtm *dagTraversalManager) BlueWindow(startingBlock *externalapi.DomainHash, windowSize int) ([]*externalapi.DomainHash, error) { +func (dtm *dagTraversalManager) BlockWindow(startingBlock *externalapi.DomainHash, windowSize int) ([]*externalapi.DomainHash, error) { currentHash := startingBlock currentGHOSTDAGData, err := dtm.ghostdagDataStore.Get(dtm.databaseContext, currentHash) if err != nil { diff --git a/domain/consensus/processes/dagtraversalmanager/window_test.go b/domain/consensus/processes/dagtraversalmanager/window_test.go index 399e434a7..5f4db12c2 100644 --- a/domain/consensus/processes/dagtraversalmanager/window_test.go +++ b/domain/consensus/processes/dagtraversalmanager/window_test.go @@ -13,7 +13,7 @@ import ( "github.com/pkg/errors" ) -func TestBlueBlockWindow(t *testing.T) { +func TestBlockWindow(t *testing.T) { tests := map[string][]*struct { parents []string id string //id is a virtual entity that is used only for tests so we can define relations between blocks without knowing their hash @@ -311,7 +311,7 @@ func TestBlueBlockWindow(t *testing.T) { testutils.ForAllNets(t, true, func(t *testing.T, params *dagconfig.Params) { params.K = 1 factory := consensus.NewFactory() - tc, tearDown, err := factory.NewTestConsensus(params, false, "TestBlueBlockWindow") + tc, tearDown, err := factory.NewTestConsensus(params, false, "TestBlockWindow") if err != nil { t.Fatalf("NewTestConsensus: %s", err) } @@ -340,9 +340,9 @@ func TestBlueBlockWindow(t *testing.T) { blockByIDMap[blockData.id] = block idByBlockMap[*block] = blockData.id - window, err := tc.DAGTraversalManager().BlueWindow(block, windowSize) + window, err := tc.DAGTraversalManager().BlockWindow(block, windowSize) if err != nil { - t.Fatalf("BlueWindow: %s", err) + t.Fatalf("BlockWindow: %s", err) } sort.Sort(testutils.NewTestGhostDAGSorter(window, tc, t)) if err := checkWindowIDs(window, blockData.expectedWindowWithGenesisPadding, idByBlockMap); err != nil { diff --git a/domain/consensus/processes/difficultymanager/blockwindow.go b/domain/consensus/processes/difficultymanager/blockwindow.go index d6c685c93..f73d4c14e 100644 --- a/domain/consensus/processes/difficultymanager/blockwindow.go +++ b/domain/consensus/processes/difficultymanager/blockwindow.go @@ -1,12 +1,13 @@ package difficultymanager import ( - "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" - "github.com/kaspanet/kaspad/util/difficulty" - "github.com/pkg/errors" "math" "math/big" "sort" + + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/util/difficulty" + "github.com/pkg/errors" ) type difficultyBlock struct { @@ -27,13 +28,13 @@ func (dm *difficultyManager) getDifficultyBlock(blockHash *externalapi.DomainHas }, nil } -// blueBlockWindow returns a blockWindow of the given size that contains the -// blues in the past of startindNode, the sorting is unspecified. -// If the number of blues in the past of startingNode is less then windowSize, +// blockWindow returns a blockWindow of the given size that contains the +// blocks in the past of startindNode, the sorting is unspecified. +// If the number of blocks in the past of startingNode is less then windowSize, // the window will be padded by genesis blocks to achieve a size of windowSize. -func (dm *difficultyManager) blueBlockWindow(startingNode *externalapi.DomainHash, windowSize int) (blockWindow, error) { +func (dm *difficultyManager) blockWindow(startingNode *externalapi.DomainHash, windowSize int) (blockWindow, error) { window := make(blockWindow, 0, windowSize) - windowHashes, err := dm.dagTraversalManager.BlueWindow(startingNode, windowSize) + windowHashes, err := dm.dagTraversalManager.BlockWindow(startingNode, windowSize) if err != nil { return nil, err } diff --git a/domain/consensus/processes/difficultymanager/difficultymanager.go b/domain/consensus/processes/difficultymanager/difficultymanager.go index 15a6c33ca..003c85969 100644 --- a/domain/consensus/processes/difficultymanager/difficultymanager.go +++ b/domain/consensus/processes/difficultymanager/difficultymanager.go @@ -1,10 +1,11 @@ package difficultymanager import ( - "github.com/kaspanet/kaspad/util/difficulty" "math/big" "time" + "github.com/kaspanet/kaspad/util/difficulty" + "github.com/kaspanet/kaspad/domain/consensus/model" "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" ) @@ -88,7 +89,7 @@ func (dm *difficultyManager) RequiredDifficulty(blockHash *externalapi.DomainHas } // Fetch window of dag.difficultyAdjustmentWindowSize + 1 so we can have dag.difficultyAdjustmentWindowSize block intervals - targetsWindow, err := dm.blueBlockWindow(bluestParent, dm.difficultyAdjustmentWindowSize+1) + targetsWindow, err := dm.blockWindow(bluestParent, dm.difficultyAdjustmentWindowSize+1) if err != nil { return 0, err } diff --git a/domain/consensus/processes/pastmediantimemanager/pastmediantimemanager.go b/domain/consensus/processes/pastmediantimemanager/pastmediantimemanager.go index a8b3e94bf..4fdd8ee71 100644 --- a/domain/consensus/processes/pastmediantimemanager/pastmediantimemanager.go +++ b/domain/consensus/processes/pastmediantimemanager/pastmediantimemanager.go @@ -57,7 +57,7 @@ func (pmtm *pastMedianTimeManager) PastMedianTime(blockHash *externalapi.DomainH return header.TimeInMilliseconds(), nil } - window, err := pmtm.dagTraversalManager.BlueWindow(selectedParentHash, 2*pmtm.timestampDeviationTolerance-1) + window, err := pmtm.dagTraversalManager.BlockWindow(selectedParentHash, 2*pmtm.timestampDeviationTolerance-1) if err != nil { return 0, err }