Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ton.NewAPIClient error, json unmarshal error for liteclient.DHTConfig #241

Open
duktig666 opened this issue Aug 23, 2024 · 4 comments
Open

Comments

@duktig666
Copy link

err:

connection err:  json: cannot unmarshal array into Go struct field GlobalConfig.dht of type liteclient.DHTConfig

config.json

{
  "@type" : "engine.validator.config",
  "out_port" : 3278,
  "addrs" : [
    {
      "@type" : "engine.addr",
      "ip" : 771424127,
      "port" : 30001,
      "categories" : [
        0,
        1,
        2,
        3
      ],
      "priority_categories" : [
      ]
    }
  ],
  "adnl" : [
    {
      "@type" : "engine.adnl",
      "id" : "Ht9RX4NsXx60EHl8CCTX8mPQ5b8uuj5h4mp7Hm5oZh0=",
      "category" : 0
    },
    {
      "@type" : "engine.adnl",
      "id" : "ar6xN0U8MCMgdt2XnnY4wwqQC87pMSzMJtbC8mYYogw=",
      "category" : 1
    }
  ],
  "dht" : [
    {
      "@type" : "engine.dht",
      "id" : "Ht9RX4NsXx60EHl8CCTX8mPQ5b8uuj5h4mp7Hm5oZh0="
    }
  ],
  "validators" : [
  ],
  "fullnode" : "ar6xN0U8MCMgdt2XnnY4wwqQC87pMSzMJtbC8mYYogw=",
  "fullnodeslaves" : [
  ],
  "fullnodemasters" : [
  ],
  "liteservers" : [
    {
      "@type" : "engine.liteServer",
      "id" : "uSzHnRAseAEc9WXKqawaL5wKO5Tean0ROHKEo1F2GAA=",
      "port" : 30003
    }
  ],
  "control" : [
    {
      "@type" : "engine.controlInterface",
      "id" : "Z16z8zHF6ToTVTmuln9aacF7x2oWrsNi7TeaQw7oTEA=",
      "port" : 30002,
      "allowed" : [
        {
          "@type" : "engine.controlProcess",
          "id" : "GpjsAfZ00gQJtlYjHJomJ+1vBtnwjHtkcK7PrP2LkqU=",
          "permissions" : 15
        }
      ]
    }
  ],
  "gc" : {
    "@type" : "engine.gc",
    "ids" : [
    ]
  }
}

go

type GlobalConfig struct {
	Type        string             `json:"@type"`
	DHT         DHTConfig          `json:"dht"`
	Liteservers []LiteserverConfig `json:"liteservers"`
	Validator   ValidatorConfig    `json:"validator"`
}

type DHTConfig struct {
	Type        string   `json:"@type"`
	K           int      `json:"k"`
	A           int      `json:"a"`
	StaticNodes DHTNodes `json:"static_nodes"`
}
 "dht" : [
    {
      "@type" : "engine.dht",
      "id" : "Ht9RX4NsXx60EHl8CCTX8mPQ5b8uuj5h4mp7Hm5oZh0="
    }
  ],

The reason is that the latest configuration file dht is an array, in go sdk or struct

@duktig666
Copy link
Author

type LiteserverConfig struct {
	IP   int64    `json:"ip"`
	Port int      `json:"port"`
	ID   ServerID `json:"id"`
}

"liteservers" : [
{
"@type" : "engine.liteServer",
"id" : "uSzHnRAseAEc9WXKqawaL5wKO5Tean0ROHKEo1F2GAA=",
"port" : 30003
}
],

The liteservers' structure is also wrong

@xssnick
Copy link
Owner

xssnick commented Aug 23, 2024

Hi, this is not global config, it is engine.validator.config. To get global config for your node you should do installer and then clcf commands in mytonctrl, it will generate correct config

@duktig666
Copy link
Author

duktig666 commented Aug 23, 2024

Hi, this is not global config, it is engine.validator.config. To get global config for your node you should do installer and then clcf commands in mytonctrl, it will generate correct config

@xssnick

https://github.com/ton-blockchain/ton/tree/master/docker#deploy-on-premises-with-metallb-load-balancer-

I am running with docker, how do I get config.json?

@duktig666
Copy link
Author

/var/ton-work/db/config.json

I am now using this file in docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants