stasatdaglabs 7b5720a155
Implement GHOST (#1819)
* Implement GHOST.

* Implement TestGHOST.

* Make GHOST() take arbitrary subDAGs.

* Hold RootHashes in SubDAG rather than one GenesisHash.

* Select which root the GHOST chain starts with instead of passing a lowHash.

* If two child hashes have the same future size, decide which one is larger using the block hash.

* Extract blockHashWithLargestFutureSize to a separate function.

* Calculate future size for each block individually.

* Make TestGHOST deterministic.

* Increase the timeout for connecting 128 connections in TestRPCMaxInboundConnections.

* Implement BenchmarkGHOST.

* Fix an infinite loop.

* Use much larger benchmark data.

* Optimize `futureSizes` using reverse merge sets.

* Temporarily make the benchmark data smaller while GHOST is being optimized.

* Fix a bug in futureSizes.

* Fix a bug in populateReverseMergeSet.

* Choose a selectedChild at random instead of the one with the largest reverse merge set size.

* Rename populateReverseMergeSet to calculateReverseMergeSet.

* Use reachability to resolve isDescendantOf.

* Extract heightMaps to a separate object.

* Iterate using height maps in futureSizes.

* Don't store reverse merge sets in memory.

* Change calculateReverseMergeSet to calculateReverseMergeSetSize.

* Fix bad initial reverseMergeSetSize.

* Optimize calculateReverseMergeSetSize.

* Enlarge the benchmark data to 86k blocks.
2021-08-19 13:59:43 +03:00

18 lines
499 B
Go

package model
import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
// SubDAG represents a context-free representation of a partial DAG
type SubDAG struct {
RootHashes []*externalapi.DomainHash
TipHashes []*externalapi.DomainHash
Blocks map[externalapi.DomainHash]*SubDAGBlock
}
// SubDAGBlock represents a block in a SubDAG
type SubDAGBlock struct {
BlockHash *externalapi.DomainHash
ParentHashes []*externalapi.DomainHash
ChildHashes []*externalapi.DomainHash
}