github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/externals/init.go (about)

     1  package externals
     2  
     3  import (
     4  	libkb "github.com/keybase/client/go/libkb"
     5  	"github.com/keybase/client/go/merklestore"
     6  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
     7  	"github.com/keybase/client/go/pvl"
     8  )
     9  
    10  // NewParamProofStore creates a new source and installs it into G.
    11  func NewParamProofStoreAndInstall(g *libkb.GlobalContext) libkb.MerkleStore {
    12  	supportedVersion := keybase1.MerkleStoreSupportedVersion(SupportedVersion)
    13  	tag := "paramproofs"
    14  	endpoint := "merkle/proof_params"
    15  	getHash := func(root libkb.MerkleRoot) string {
    16  		return root.ProofServicesHash()
    17  	}
    18  	kitFilename := g.Env.GetParamProofKitFilename()
    19  	s := merklestore.NewMerkleStore(g, tag, endpoint, kitFilename, supportedVersion, getHash)
    20  	g.SetParamProofStore(s)
    21  	return s
    22  }
    23  
    24  // NewExternalURLStoreAndInstall creates a new store and installs it into G.
    25  func NewExternalURLStoreAndInstall(g *libkb.GlobalContext) libkb.MerkleStore {
    26  	supportedVersion := keybase1.MerkleStoreSupportedVersion(SupportedVersion)
    27  	tag := "external_urls"
    28  	endpoint := "merkle/external_urls"
    29  	getHash := func(root libkb.MerkleRoot) string {
    30  		return root.ExternalURLHash()
    31  	}
    32  	kitFilename := g.Env.GetExternalURLKitFilename()
    33  	s := merklestore.NewMerkleStore(g, tag, endpoint, kitFilename, supportedVersion, getHash)
    34  	g.SetExternalURLStore(s)
    35  	return s
    36  }
    37  
    38  func NewGlobalContextInit() *libkb.GlobalContext {
    39  	g := libkb.NewGlobalContext().Init()
    40  	g.SetProofServices(NewProofServices(g))
    41  	_ = g.ConfigureMerkleClient()
    42  	pvl.NewPvlSourceAndInstall(g)
    43  	NewParamProofStoreAndInstall(g)
    44  	return g
    45  }