Skip to content

Commit

Permalink
core: 1.14.8 + misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeoneWeird committed Sep 25, 2024
1 parent 888df19 commit d251a15
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 31 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
Binary file added core/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 28 additions & 24 deletions core/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
"manifestVersion": 1,
"meta": {
"name": "Dogecoin Core",
"version": "0.0.3",
"logoPath": "",
"shortDescription": "",
"longDescription": "Dogecoin Core runs a full core node on your dogebox"
"version": "0.0.4",
"logoPath": "logo.png",
"shortDescription": "Run a full core node on your dogebox",
"longDescription": "This pup launches and configures a full Dogecoin Core node on your dogebox, allowing you to sync the blockchain and contribute to the network.",
"upstreamVersions": {
"Core": "v1.14.8"
}
},
"config": {
"sections": null
},
"container": {
"build": {
"nixFile": "pup.nix",
"nixFileSha256": "5588e722b7d7c8a2dfedeebbfbc3714e7f721607ddce8432e27aabd8dbd9fd7f"
"nixFileSha256": "aa786de8727a5a90a842caa84ef78bca2297befe15b0664883de067c01ced279"
},
"services": [
{
Expand Down Expand Up @@ -53,18 +56,21 @@
"name": "rpc",
"type": "http",
"port": 22555,
"interfaces": [
"core-rpc"
],
"interfaces": ["core-rpc"],
"listenOnHost": false
},
{
"name": "rpc-tcp",
"type": "tcp",
"port": 22555,
"interfaces": ["core-rpc"],
"listenOnHost": false
},
{
"name": "zmq",
"type": "tcp",
"port": 28332,
"interfaces": [
"core-zmq"
],
"interfaces": ["core-zmq"],
"listenOnHost": false
}
],
Expand All @@ -79,9 +85,7 @@
"name": "RPC",
"description": "Allows RPC access to the Dogecoin Core node",
"severity": 2,
"routes": [
"/*"
],
"routes": ["/*"],
"port": 0
}
]
Expand All @@ -104,13 +108,13 @@
"metrics": [
{
"name": "chain",
"label": "Name of the chain",
"label": "Chain",
"type": "string",
"history": 1
},
{
"name": "blocks",
"label": "Block height",
"label": "Block Height",
"type": "int",
"history": 30
},
Expand All @@ -129,20 +133,20 @@
{
"name": "verification_progress",
"label": "Verification progress",
"type": "float",
"history": 30
"type": "string",
"history": 1
},
{
"name": "initial_block_download",
"label": "Initial block download",
"label": "Initial Download",
"type": "string",
"history": 1
},
{
"name": "size_on_disk",
"label": "Size on disk in MB",
"type": "int",
"history": 30
"name": "chain_size_human",
"label": "Blockchain Size",
"type": "string",
"history": 1
}
]
}
}
37 changes: 32 additions & 5 deletions core/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type BlockchainInfo struct {
Blocks int `json:"blocks"`
Headers int `json:"headers"`
Difficulty float64 `json:"difficulty"`
VerificationProgress float64 `json:"verification_progress"`
InitialBlockDownload bool `json:"initial_block_download"`
VerificationProgress float64 `json:"verificationprogress"`
InitialBlockDownload bool `json:"initialblockdownload"`
SizeOnDisk int64 `json:"size_on_disk"`
}

Expand Down Expand Up @@ -78,14 +78,25 @@ func parseRawBlockchainInfo(rawInfo string) (BlockchainInfo, error) {

func submitMetrics(info BlockchainInfo) {
client := &http.Client{}

// Verification progress is 0..-1, so we make it pretty text
verificationProgress := fmt.Sprintf("%.2f%%", info.VerificationProgress*100)
initialBlockDownload := "No"

if info.InitialBlockDownload {
initialBlockDownload = "Yes"
}

chainSize := bytesToHuman(info.SizeOnDisk)

jsonData := map[string]interface{}{
"chain": map[string]interface{}{"value": info.Chain},
"blocks": map[string]interface{}{"value": info.Blocks},
"headers": map[string]interface{}{"value": info.Headers},
"difficulty": map[string]interface{}{"value": info.Difficulty},
"verification_progress": map[string]interface{}{"value": info.VerificationProgress},
"initial_block_download": map[string]interface{}{"value": fmt.Sprintf("%v", info.InitialBlockDownload)},
"size_on_disk": map[string]interface{}{"value": info.SizeOnDisk},
"verification_progress": map[string]interface{}{"value": verificationProgress},
"initial_block_download": map[string]interface{}{"value": initialBlockDownload},
"chain_size_human": map[string]interface{}{"value": chainSize},
}

marshalledData, err := json.Marshal(jsonData)
Expand All @@ -94,6 +105,8 @@ func submitMetrics(info BlockchainInfo) {
return
}

log.Printf("Submitting metrics: %v", jsonData)

url := fmt.Sprintf("http://%s:%s/dbx/metrics", os.Getenv("DBX_HOST"), os.Getenv("DBX_PORT"))

req, err := http.NewRequest("POST", url, bytes.NewBuffer(marshalledData))
Expand All @@ -120,6 +133,20 @@ func submitMetrics(info BlockchainInfo) {

log.Println("Metrics submitted successfully.")
}
func bytesToHuman(bytes int64) string {
const (
MB = 1024 * 1024
GB = 1024 * MB
)

if bytes < GB {
mb := float64(bytes) / MB
return fmt.Sprintf("%.2f MB", mb)
}

gb := float64(bytes) / GB
return fmt.Sprintf("%.2f GB", gb)
}

func main() {
log.Println("Sleeping to give dogecoind time to start..")
Expand Down
5 changes: 3 additions & 2 deletions core/pup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
let
storageDirectory = "/storage";
dogecoind_bin = pkgs.callPackage (pkgs.fetchurl {
url = "https://raw.githubusercontent.com/dogeorg/dogebox-nur-packages/f989575c285e6b7865c8185405a1abba54cc1964/pkgs/dogecoin-core/default.nix";
sha256 = "sha256-A3QVCK4OSIHIPZJNUShNsjTc+XffPdRBKeAzIvPeOPY=";
url = "https://raw.githubusercontent.com/dogeorg/dogebox-nur-packages/bbdaf135249b0641907c6d418d5e4e7d41968ff4/pkgs/dogecoin-core/default.nix";
sha256 = "sha256-dDA9KuEs51UCoS76b1NnE2uk2NOBWGsgJnbAnc1k6sg=";
}) {
disableWallet = true;
disableGUI = true;
disableTests = true;
enableZMQ = true;
};

dogecoind = pkgs.writeScriptBin "run.sh" ''
Expand Down

0 comments on commit d251a15

Please sign in to comment.