func GlobalStateSeekKeyForPKIDReferralHashes(pkid *lib.PKID) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixPKIDReferralHashToIsActive...)
	key := append(prefixCopy, pkid[:]...)
	return key
}
Key for seeking the DB for all referral hashes with a specific PKID.
package routes
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"strings"
	"github.com/deso-protocol/core/lib"
	"github.com/dgraph-io/badger/v3"
	"github.com/nyaruka/phonenumbers"
	"github.com/pkg/errors"
)
const (
	GlobalStateSharedSecretParam = "shared_secret"
	RoutePathGlobalStatePutRemote      = "/api/v1/global-state/put"
	RoutePathGlobalStateGetRemote      = "/api/v1/global-state/get"
	RoutePathGlobalStateBatchGetRemote = "/api/v1/global-state/batch-get"
	RoutePathGlobalStateDeleteRemote   = "/api/v1/global-state/delete"
	RoutePathGlobalStateSeekRemote     = "/api/v1/global-state/seek"
)
func (fes *APIServer) GlobalStateRoutes() []Route {
	var GlobalStateRoutes = []Route{
		{
			"GlobalStatePutRemote",
			[]string{"POST", "OPTIONS"},
			RoutePathGlobalStatePutRemote,
			fes.GlobalStatePutRemote,
			AdminAccess,  
		},
		{
			"GlobalStateGetRemote",
			[]string{"POST", "OPTIONS"},
			RoutePathGlobalStateGetRemote,
			fes.GlobalStateGetRemote,
			AdminAccess,  
		},
		{
			"GlobalStateBatchGetRemote",
			[]string{"POST", "OPTIONS"},
			RoutePathGlobalStateBatchGetRemote,
			fes.GlobalStateBatchGetRemote,
			AdminAccess,  
		},
		{
			"GlobalStateDeleteRemote",
			[]string{"POST", "OPTIONS"},
			RoutePathGlobalStateDeleteRemote,
			fes.GlobalStateDeleteRemote,
			AdminAccess,  
		},
		{
			"GlobalStateSeekRemote",
			[]string{"POST", "OPTIONS"},
			RoutePathGlobalStateSeekRemote,
			fes.GlobalStateSeekRemote,
			AdminAccess,  
		},
	}
	return GlobalStateRoutes
}
var (
	_GlobalStatePrefixPublicKeyToUserMetadata = []byte{0}
	_GlobalStatePrefixTstampNanosPostHash = []byte{1}
	_GlobalStatePrefixPhoneNumberToPhoneNumberMetadata = []byte{2}
	_GlobalStatePrefixForVerifiedMap = []byte{3}
	_GlobalStatePrefixTstampNanosPinnedPostHash = []byte{4}
	_GlobalStatePrefixUsernameVerificationAuditLog = []byte{5}
	_GlobalStatePrefixPublicKeyToGraylistState = []byte{6}
	_GlobalStatePrefixPublicKeyToBlacklistState = []byte{7}
	_GlobalStatePrefixUserPublicKeyContactPublicKeyToMostRecentReadTstampNanos = []byte{8}
	_GlobalStatePrefixUserPublicKeyWyreOrderIdToWyreOrderMetadata = []byte{9}
	_GlobalStatePrefixWyreOrderIdProcessed = []byte{10}
	_GlobalStatePrefixWyreOrderId = []byte{11}
	_GlobalStatePrefixWhitelistAuditLog = []byte{12}
	_GlobalStatePrefixGraylistAuditLog = []byte{13}
	_GlobalStatePrefixBlacklistAuditLog = []byte{14}
	_GlobalStatePrefixUSDCentsToDeSoReserveExchangeRate = []byte{15}
	_GlobalStatePrefixBuyDeSoFeeBasisPoints = []byte{16}
	_GlobalStatePrefixNFTDropNumberToNFTDropEntry = []byte{17}
	_GlobalStatePrefixPKIDTstampNanosToJumioTransaction = []byte{20}
	_GlobalStatePrefixCountryIDDocumentTypeSubTypeDocumentNumber = []byte{19}
	_GlobalStatePrefixJumioDeSoNanos = []byte{21}
	_GlobalStateKeyWellKnownTutorialCreators = []byte{22}
	_GlobalStateKeyUpAndComingTutorialCreators = []byte{23}
	_GlobalStatePrefixReferralHashToReferralInfo = []byte{24}
	_GlobalStatePrefixPKIDReferralHashToIsActive = []byte{25}
	_GlobalStatePrefixPKIDReferralHashRefereePKID = []byte{26}
	_GlobalStatePrefixTimestampPKIDReferralHashRefereePKID = []byte{37}
	_GlobalStatePrefixForETHPurchases = []byte{27}
	_GlobalStatePrefixForHotFeedApprovedPostOps = []byte{31}
	_GlobalStatePrefixForHotFeedInteractionCap  = []byte{32}
	_GlobalStatePrefixForHotFeedTimeDecayBlocks = []byte{33}
	_GlobalStatePrefixTxnTypeToDeSoOutputs = []byte{34}
	_GlobalStatePrefixExemptPublicKeys = []byte{35}
	_GlobalStatePrefixForHotFeedPKIDMultiplierOps = []byte{36}
)
type HotFeedApprovedPostOp struct {
	IsRemoval  bool
	Multiplier float64  
}
type HotFeedPKIDMultiplierOp struct {
	InteractionMultiplier float64  
	PostsMultiplier       float64  
}
type ReferralInfo struct {
	ReferralHashBase58     string
	ReferrerPKID           *lib.PKID
	ReferrerAmountUSDCents uint64
	RefereeAmountUSDCents  uint64
	MaxReferrals           uint64  
	RequiresJumio          bool
	NumJumioAttempts       uint64
	NumJumioSuccesses      uint64
	TotalReferrals         uint64
	TotalReferrerDeSoNanos uint64
	TotalRefereeDeSoNanos  uint64
	DateCreatedTStampNanos uint64
}
type SimpleReferralInfo struct {
	ReferralHashBase58    string
	RefereeAmountUSDCents uint64
	MaxReferrals          uint64  
	TotalReferrals        uint64
}
type NFTDropEntry struct {
	IsActive        bool
	DropNumber      uint64
	DropTstampNanos uint64
	NFTHashes       []*lib.BlockHash
}
type UserMetadata struct {
	PublicKey []byte
	RemoveEverywhere bool
	RemoveFromLeaderboard bool
	Email string
	EmailVerified bool
	PhoneNumber string
	PhoneNumberCountryCode string
	MessageReadStateByContact map[string]int
	NotificationLastSeenIndex int64
	SatoshisBurnedSoFar uint64
	HasBurnedEnoughSatoshisToCreateProfile bool
	BlockedPublicKeys map[string]struct{}
	WhitelistPosts bool
	JumioInternalReference string
	JumioFinishedTime uint64
	JumioVerified bool
	JumioReturned bool
	JumioTransactionID string
	JumioDocumentKey []byte
	RedoJumio bool
	JumioStarterDeSoTxnHashHex string
	JumioShouldCompProfileCreation bool
	MustCompleteTutorial bool
	IsFeaturedTutorialWellKnownCreator bool
	IsFeaturedTutorialUpAndComingCreator bool
	TutorialStatus                  TutorialStatus
	CreatorPurchasedInTutorialPKID  *lib.PKID
	CreatorCoinsPurchasedInTutorial uint64
	ReferralHashBase58Check string
	ReferrerDeSoTxnHash string
}
type TutorialStatus string
const (
	EMPTY              TutorialStatus = ""
	STARTED            TutorialStatus = "TutorialStarted"
	SKIPPED            TutorialStatus = "TutorialSkipped"
	INVEST_OTHERS_BUY  TutorialStatus = "InvestInOthersBuyComplete"
	INVEST_OTHERS_SELL TutorialStatus = "InvestInOthersSellComplete"
	CREATE_PROFILE     TutorialStatus = "TutorialCreateProfileComplete"
	INVEST_SELF        TutorialStatus = "InvestInYourselfComplete"
	FOLLOW_CREATORS	   TutorialStatus = "FollowCreatorsComplete"
	DIAMOND            TutorialStatus = "GiveADiamondComplete"
	COMPLETE           TutorialStatus = "TutorialComplete"
)
type PhoneNumberMetadata struct {
	PublicKey []byte
	PhoneNumber string
	PhoneNumberCountryCode string
	ShouldCompProfileCreation bool
}
type WyreWalletOrderMetadata struct {
	LatestWyreWalletOrderWebhookPayload WyreWalletOrderWebhookPayload
	LatestWyreTrackWalletOrderResponse *WyreTrackOrderResponse
	DeSoPurchasedNanos uint64
	BasicTransferTxnBlockHash *lib.BlockHash
}
func GlobalStateKeyForNFTDropEntry(dropNumber uint64) []byte {
	dropNumBytes := lib.EncodeUint64(uint64(dropNumber))
	keyBytes := _GlobalStatePrefixNFTDropNumberToNFTDropEntry
	keyBytes = append(keyBytes, dropNumBytes...)
	return keyBytes
}
func GlobalStateKeyForPhoneNumberStringToPhoneNumberMetadata(phoneNumber string) (_key []byte, _err error) {
	parsedNumber, err := phonenumbers.Parse(phoneNumber, "")
	if err != nil {
		return nil, errors.Wrap(fmt.Errorf(
			"GlobalStateKeyForPhoneNumberStringToPhoneNumberMetadata: Problem with phonenumbers.Parse: %v", err), "")
	}
	formattedNumber := phonenumbers.Format(parsedNumber, phonenumbers.E164)
	return globalStateKeyForPhoneNumberBytesToPhoneNumberMetadata([]byte(formattedNumber)), nil
}
func globalStateKeyForPhoneNumberBytesToPhoneNumberMetadata(phoneNumberBytes []byte) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixPhoneNumberToPhoneNumberMetadata...)
	key := append(prefixCopy, phoneNumberBytes[:]...)
	return key
}
func GlobalStateKeyForPublicKeyToUserMetadata(profilePubKey []byte) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixPublicKeyToUserMetadata...)
	key := append(prefixCopy, profilePubKey[:]...)
	return key
}
func GlobalStateKeyForReferralHashToReferralInfo(referralHashBytes []byte) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixReferralHashToReferralInfo...)
	key := append(prefixCopy, referralHashBytes[:]...)
	return key
}
func GlobalStateKeyForPKIDReferralHashToIsActive(pkid *lib.PKID, referralHashBytes []byte) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixPKIDReferralHashToIsActive...)
	key := append(prefixCopy, pkid[:]...)
	key = append(key, referralHashBytes[:]...)
	return key
}
func GlobalStateSeekKeyForHotFeedApprovedPostOps(startTimestampNanos uint64) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixForHotFeedApprovedPostOps...)
	key := append(prefixCopy, lib.EncodeUint64(startTimestampNanos)...)
	return key
}
func GlobalStateKeyForHotFeedApprovedPostOp(
	opTimestampNanos uint64,
	postHash *lib.BlockHash,
) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixForHotFeedApprovedPostOps...)
	key := append(prefixCopy, lib.EncodeUint64(opTimestampNanos)...)
	key = append(key, postHash[:]...)
	return key
}
func GlobalStateSeekKeyForHotFeedPKIDMultiplierOps(startTimestampNanos uint64) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixForHotFeedPKIDMultiplierOps...)
	key := append(prefixCopy, lib.EncodeUint64(startTimestampNanos)...)
	return key
}
func GlobalStateKeyForHotFeedPKIDMultiplierOp(
	opTimestampNanos uint64,
	opPKID *lib.PKID,
) []byte {
	prefixCopy := append([]byte{}, _GlobalStatePrefixForHotFeedPKIDMultiplierOps...)
	key := append(prefixCopy, lib.EncodeUint64(opTimestampNanos)...)
	key = append(key, opPKID[:]...)
	return key
}