mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-09-14 13:30:11 +00:00

* [NOD-1223] Move all network stuff into a new network package. * [NOD-1223] Delete the unused package testutil. * [NOD-1223] Move infrastructure stuff into a new instrastructure package. * [NOD-1223] Move domain stuff into a new domain package.
28 lines
895 B
Go
28 lines
895 B
Go
package rpc
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/network/rpc/model"
|
|
"github.com/kaspanet/kaspad/util/daghash"
|
|
)
|
|
|
|
// handleGetBlockDAGInfo implements the getBlockDagInfo command.
|
|
func handleGetBlockDAGInfo(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
|
// Obtain a snapshot of the current best known DAG state. We'll
|
|
// populate the response to this call primarily from this snapshot.
|
|
params := s.dag.Params
|
|
dag := s.dag
|
|
|
|
dagInfo := &model.GetBlockDAGInfoResult{
|
|
DAG: params.Name,
|
|
Blocks: dag.BlockCount(),
|
|
Headers: dag.BlockCount(),
|
|
TipHashes: daghash.Strings(dag.TipHashes()),
|
|
Difficulty: getDifficultyRatio(dag.CurrentBits(), params),
|
|
MedianTime: dag.CalcPastMedianTime().UnixMilliseconds(),
|
|
Pruned: false,
|
|
Bip9SoftForks: make(map[string]*model.Bip9SoftForkDescription),
|
|
}
|
|
|
|
return dagInfo, nil
|
|
}
|