<commit_before>// Copyright 2016 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package factom

import (
	"encoding/json"
	"fmt"
)

type Authority struct {
	AuthorityChainID  string   `json:"identity_chainid"`
	ManagementChainID string   `json:"management_chaind"`
	MatryoshkaHash    string   `json:"matryoshka_hash"`
	SigningKey        string   `json:"signing_key"`
	Status            int      `json:"status"`
	Efficiency        int      `json:"efficiency"`
	CoinbaseAddress   string   `json:"coinbase_address"`
	AnchorKeys        []string `json:"anchor_keys"`
	KeyHistory        []string `json:"-"`
}

func (a *Authority) String() string {
	var s string

	s += fmt.Sprintln("AuthorityChainID:", a.AuthorityChainID)
	s += fmt.Sprintln("ManagementChainID:", a.ManagementChainID)
	s += fmt.Sprintln("MatryoshkaHash:", a.MatryoshkaHash)
	s += fmt.Sprintln("SigningKey:", a.SigningKey)
	s += fmt.Sprintln("Status:", a.Status)
	s += fmt.Sprintln("Efficiency:", a.Efficiency)
	s += fmt.Sprintln("CoinbaseAddress:", a.CoinbaseAddress)

	s += fmt.Sprintln("AnchorKeys {")
	for _, k := range a.AnchorKeys {
		s += fmt.Sprintln(" ", k)
	}
	s += fmt.Sprintln("}")

	s += fmt.Sprintln("KeyHisory {")
	for _, k := range a.KeyHistory {
		s += fmt.Sprintln(" ", k)
	}
	s += fmt.Sprintln("}")

	return s
}

func GetAuthorites() ([]*Authority, error) {
	req := NewJSON2Request("authorities", APICounter(), nil)
	resp, err := factomdRequest(req)
	if err != nil {
		return nil, err
	}
	if resp.Error != nil {
		return nil, resp.Error
	}

	// create a temporary type to unmarshal the json object
	a := new(struct {
		Authorities []*Authority `json:"authorities"`
	})

	// a := new(authorities)
	if err := json.Unmarshal(resp.JSONResult(), a); err != nil {
		return nil, err
	}

	return a.Authorities, nil
}<commit_msg>removed old code<commit_after>// Copyright 2016 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package factom

import (
	"encoding/json"
	"fmt"
)

type Authority struct {
	AuthorityChainID  string   `json:"identity_chainid"`
	ManagementChainID string   `json:"management_chaind"`
	MatryoshkaHash    string   `json:"matryoshka_hash"`
	SigningKey        string   `json:"signing_key"`
	Status            int      `json:"status"`
	Efficiency        int      `json:"efficiency"`
	CoinbaseAddress   string   `json:"coinbase_address"`
	AnchorKeys        []string `json:"anchor_keys"`
	KeyHistory        []string `json:"-"`
}

func (a *Authority) String() string {
	var s string

	s += fmt.Sprintln("AuthorityChainID:", a.AuthorityChainID)
	s += fmt.Sprintln("ManagementChainID:", a.ManagementChainID)
	s += fmt.Sprintln("MatryoshkaHash:", a.MatryoshkaHash)
	s += fmt.Sprintln("SigningKey:", a.SigningKey)
	s += fmt.Sprintln("Status:", a.Status)
	s += fmt.Sprintln("Efficiency:", a.Efficiency)
	s += fmt.Sprintln("CoinbaseAddress:", a.CoinbaseAddress)

	s += fmt.Sprintln("AnchorKeys {")
	for _, k := range a.AnchorKeys {
		s += fmt.Sprintln(" ", k)
	}
	s += fmt.Sprintln("}")

	s += fmt.Sprintln("KeyHisory {")
	for _, k := range a.KeyHistory {
		s += fmt.Sprintln(" ", k)
	}
	s += fmt.Sprintln("}")

	return s
}

func GetAuthorites() ([]*Authority, error) {
	req := NewJSON2Request("authorities", APICounter(), nil)
	resp, err := factomdRequest(req)
	if err != nil {
		return nil, err
	}
	if resp.Error != nil {
		return nil, resp.Error
	}

	// create a temporary type to unmarshal the json object
	a := new(struct {
		Authorities []*Authority `json:"authorities"`
	})

	if err := json.Unmarshal(resp.JSONResult(), a); err != nil {
		return nil, err
	}

	return a.Authorities, nil
}
{'fraction_non_alphanumeric': 0.15004033342296316, 'fraction_numerical': 0.0026888948642108095, 'mean_word_length': 3.856396866840731, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4842194', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1262, 'n_words': 326}