2022-10-11 12:54:46 +02:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2022-10-12 00:30:54 +02:00
|
|
|
type ServerFeatureService struct {
|
2022-10-11 12:54:46 +02:00
|
|
|
Args *Args
|
|
|
|
}
|
|
|
|
|
|
|
|
type ServerFeaturesReq struct{}
|
|
|
|
|
|
|
|
type ServerFeaturesRes struct {
|
|
|
|
Hosts map[string]string `json:"hosts"`
|
|
|
|
Pruning string `json:"pruning"`
|
|
|
|
ServerVersion string `json:"server_version"`
|
|
|
|
ProtocolMin string `json:"protocol_min"`
|
|
|
|
ProtocolMax string `json:"protocol_max"`
|
|
|
|
GenesisHash string `json:"genesis_hash"`
|
|
|
|
Description string `json:"description"`
|
|
|
|
PaymentAddress string `json:"payment_address"`
|
|
|
|
DonationAddress string `json:"donation_address"`
|
|
|
|
DailyFee string `json:"daily_fee"`
|
|
|
|
HashFunction string `json:"hash_function"`
|
|
|
|
TrendingAlgorithm string `json:"trending_algorithm"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Features is the json rpc endpoint for 'server.features'.
|
2022-10-12 00:30:54 +02:00
|
|
|
func (t *ServerFeatureService) Features(req *ServerFeaturesReq, res **ServerFeaturesRes) error {
|
2022-10-11 12:54:46 +02:00
|
|
|
log.Println("Features")
|
|
|
|
|
|
|
|
features := &ServerFeaturesRes{
|
|
|
|
Hosts: map[string]string{},
|
|
|
|
Pruning: "",
|
|
|
|
ServerVersion: HUB_PROTOCOL_VERSION,
|
|
|
|
ProtocolMin: PROTOCOL_MIN,
|
|
|
|
ProtocolMax: PROTOCOL_MAX,
|
|
|
|
GenesisHash: GENESIS_HASH,
|
2022-10-11 16:29:51 +02:00
|
|
|
Description: t.Args.ServerDescription,
|
|
|
|
PaymentAddress: t.Args.PaymentAddress,
|
|
|
|
DonationAddress: t.Args.DonationAddress,
|
|
|
|
DailyFee: t.Args.DailyFee,
|
2022-10-11 12:54:46 +02:00
|
|
|
HashFunction: "sha256",
|
|
|
|
TrendingAlgorithm: "fast_ar",
|
|
|
|
}
|
|
|
|
*res = features
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2022-10-11 16:29:51 +02:00
|
|
|
|
2022-10-12 00:30:54 +02:00
|
|
|
type ServerBannerService struct {
|
|
|
|
Args *Args
|
|
|
|
}
|
|
|
|
|
2022-10-11 16:29:51 +02:00
|
|
|
type ServerBannerReq struct{}
|
|
|
|
|
|
|
|
type ServerBannerRes string
|
|
|
|
|
|
|
|
// Banner is the json rpc endpoint for 'server.banner'.
|
2022-10-12 00:30:54 +02:00
|
|
|
func (t *ServerBannerService) Banner(req *ServerBannerReq, res **ServerBannerRes) error {
|
2022-10-11 16:29:51 +02:00
|
|
|
log.Println("Banner")
|
|
|
|
|
|
|
|
*res = (*ServerBannerRes)(t.Args.Banner)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2022-10-12 00:30:54 +02:00
|
|
|
|
|
|
|
type ServerVersionService struct {
|
|
|
|
Args *Args
|
|
|
|
}
|
|
|
|
|
|
|
|
type ServerVersionReq struct{}
|
|
|
|
|
|
|
|
type ServerVersionRes string
|
|
|
|
|
|
|
|
// Banner is the json rpc endpoint for 'server.version'.
|
|
|
|
// FIXME: This should return a struct with the version and the protocol version.
|
|
|
|
// <<-- that comment was written by github, scary shit because it's true
|
|
|
|
func (t *ServerVersionService) Version(req *ServerVersionReq, res **ServerVersionRes) error {
|
|
|
|
log.Println("Version")
|
|
|
|
|
|
|
|
*res = (*ServerVersionRes)(&t.Args.ServerVersion)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|