kaspad/network/rpc/handle_get_block_dag_info.go
stasatdaglabs 8a4ece1101
[NOD-1223] Reorganize project (#868)
* [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.
2020-08-13 17:27:25 +03:00

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
}