Skip to content

Commit

Permalink
Remove BlockWithTrustedData method
Browse files Browse the repository at this point in the history
  • Loading branch information
someone235 committed Feb 18, 2022
1 parent f58aeb4 commit e1c982e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
8 changes: 0 additions & 8 deletions domain/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ func (s *consensus) PruningPointAndItsAnticone() ([]*externalapi.DomainHash, err
return s.pruningManager.PruningPointAndItsAnticone()
}

// TODO: Remove this method once v3 is obsolete
func (s *consensus) BlockWithTrustedData(blockHash *externalapi.DomainHash) (*externalapi.BlockWithTrustedData, error) {
s.lock.Lock()
defer s.lock.Unlock()

return s.pruningManager.BlockWithTrustedData(model.NewStagingArea(), blockHash)
}

// BuildBlock builds a block over the current state, with the transactions
// selected by the given transactionSelector
func (s *consensus) BuildBlock(coinbaseData *externalapi.DomainCoinbaseData,
Expand Down
1 change: 0 additions & 1 deletion domain/consensus/model/externalapi/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type Consensus interface {
PruningPoint() (*DomainHash, error)
PruningPointHeaders() ([]BlockHeader, error)
PruningPointAndItsAnticone() ([]*DomainHash, error)
BlockWithTrustedData(blockHash *DomainHash) (*BlockWithTrustedData, error)
ClearImportedPruningPointData() error
AppendImportedPruningPointUTXOs(outpointAndUTXOEntryPairs []*OutpointAndUTXOEntryPair) error
ValidateAndInsertImportedPruningPoint(newPruningPoint *DomainHash) error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,44 @@ func TestValidateAndInsertImportedPruningPoint(t *testing.T) {
}

for _, blockHash := range pruningPointAndItsAnticone {
blockWithTrustedData, err := tcSyncer.BlockWithTrustedData(blockHash)
block, err := tcSyncer.GetBlock(blockHash)
if err != nil {
return
t.Fatalf("GetBlock: %+v", err)
}

blockDAAWindowHashes, err := tcSyncer.BlockDAAWindowHashes(blockHash)
if err != nil {
t.Fatalf("BlockDAAWindowHashes: %+v", err)
}

ghostdagDataBlockHashes, err := tcSyncer.TrustedBlockAssociatedGHOSTDAGDataBlockHashes(blockHash)
if err != nil {
t.Fatalf("TrustedBlockAssociatedGHOSTDAGDataBlockHashes: %+v", err)
}

blockWithTrustedData := &externalapi.BlockWithTrustedData{
Block: block,
DAAWindow: make([]*externalapi.TrustedDataDataDAAHeader, 0, len(blockDAAWindowHashes)),
GHOSTDAGData: make([]*externalapi.BlockGHOSTDAGDataHashPair, 0, len(ghostdagDataBlockHashes)),
}

for i, daaBlockHash := range blockDAAWindowHashes {
trustedDataDataDAAHeader, err := tcSyncer.TrustedDataDataDAAHeader(blockHash, daaBlockHash, uint64(i))
if err != nil {
t.Fatalf("TrustedDataDataDAAHeader: %+v", err)
}
blockWithTrustedData.DAAWindow = append(blockWithTrustedData.DAAWindow, trustedDataDataDAAHeader)
}

for _, ghostdagDataBlockHash := range ghostdagDataBlockHashes {
data, err := tcSyncer.TrustedGHOSTDAGData(ghostdagDataBlockHash)
if err != nil {
t.Fatalf("TrustedGHOSTDAGData: %+v", err)
}
blockWithTrustedData.GHOSTDAGData = append(blockWithTrustedData.GHOSTDAGData, &externalapi.BlockGHOSTDAGDataHashPair{
Hash: ghostdagDataBlockHash,
GHOSTDAGData: data,
})
}

_, err = synceeStaging.ValidateAndInsertBlockWithTrustedData(blockWithTrustedData, false)
Expand Down

0 comments on commit e1c982e

Please sign in to comment.