fulamobile

package
v1.54.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

Example (BlockchainCalls)
server := startMockServer("127.0.0.1:4004")
defer func() {
	// Shutdown the server after test
	if err := server.Shutdown(context.Background()); err != nil {
		log.Error("Error happened in server.Shutdown")
		panic(err) // Handle the error as you see fit
	}
}()

const poolName = "1"
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()

// Elevate log level to show internal communications.
if err := logging.SetLogLevel("*", "info"); err != nil {
	log.Error("Error happened in logging.SetLogLevel")
	panic(err)
}

// Use a deterministic random generator to generate deterministic
// output for the example.

// Instantiate the first node in the pool
h1, err := libp2p.New(libp2p.Identity(generateIdentity(1)))
if err != nil {
	log.Errorw("Error happened in libp2p.New", "err", err)
	panic(err)
}
n1, err := blox.New(
	blox.WithHost(h1),
	blox.WithPoolName("1"),
	blox.WithUpdatePoolName(updatePoolName),
	blox.WithBlockchainEndPoint("127.0.0.1:4004"),
	blox.WithPingCount(5),
	blox.WithExchangeOpts(
		exchange.WithIpniGetEndPoint("http://127.0.0.1:4004/cid/"),
	),
)
if err != nil {
	log.Errorw("Error happened in blox.New", "err", err)
	panic(err)
}
if err := n1.Start(ctx); err != nil {
	log.Errorw("Error happened in n1.Start", "err", err)
	panic(err)
}
defer n1.Shutdown(ctx)
fmt.Printf("Instantiated node in pool %s with ID: %s\n", poolName, h1.ID().String())

mcfg := fulamobile.NewConfig()
mcfg.AllowTransientConnection = true
bloxAddrString := ""
if len(h1.Addrs()) > 0 {
	// Convert the first multiaddr to a string
	bloxAddrString = h1.Addrs()[0].String()
	log.Infow("blox multiadddr is", "addr", bloxAddrString, "peerID", h1.ID().String())
} else {
	log.Errorw("Error happened in h1.Addrs", "err", "No addresses in slice")
	panic("No addresses in slice")
}
mcfg.BloxAddr = bloxAddrString + "/p2p/" + h1.ID().String()
mcfg.PoolName = "1"
mcfg.Exchange = bloxAddrString
mcfg.BlockchainEndpoint = "127.0.0.1:4004"
log.Infow("bloxAdd string created", "addr", bloxAddrString+"/p2p/"+h1.ID().String())

c1, err := fulamobile.NewClient(mcfg)
if err != nil {
	log.Errorw("Error happened in fulamobile.NewClient", "err", err)
	panic(err)
}
// Authorize exchange between the two nodes
mobilePeerIDString := c1.ID()
log.Infof("first client created with ID: %s", mobilePeerIDString)
mpid, err := peer.Decode(mobilePeerIDString)
if err != nil {
	log.Errorw("Error happened in peer.Decode", "err", err)
	panic(err)
}
if err := n1.SetAuth(ctx, h1.ID(), mpid, true); err != nil {
	log.Error("Error happened in n1.SetAuth")
	panic(err)
}

err = c1.ConnectToBlox()
if err != nil {
	log.Errorw("Error happened in c1.ConnectToBlox", "err", err)
	panic(err)
}
account, err := c1.GetAccount()
if err != nil {
	panic(err)
}
fmt.Printf("account is %s", account)
Output:

Instantiated node in pool 1 with ID: 12D3KooWQfGkPUkoLDEeJE3H3ZTmu9BZvAdbJpmhha8WpjeSLKMM
account is {"account":"5GEottBB4kGzpN6imRwpnhyVDtKMTSYHYZvT4Rq93dchjN45"}
Example (ListRecentCidsWithChildren)
// Elevate log level to show internal communications.
if err := logging.SetLogLevel("*", "debug"); err != nil {
	log.Error("Error happened in logging.SetLogLevel")
	panic(err)
}

mcfg := fulamobile.NewConfig()
mcfg.AllowTransientConnection = true
mcfg.BloxAddr = ""
mcfg.PoolName = "1"
mcfg.Exchange = "noop"
mcfg.BlockchainEndpoint = ""

c1, err := fulamobile.NewClient(mcfg)
if err != nil {
	log.Errorw("Error happened in fulamobile.NewClient", "err", err)
	panic(err)
}
// Authorize exchange between the two nodes
mobilePeerIDString := c1.ID()
log.Infof("first client created with ID: %s", mobilePeerIDString)
mpid, err := peer.Decode(mobilePeerIDString)
if err != nil {
	log.Errorw("Error happened in peer.Decode", "err", err)
	panic(err)
}
log.Infof("mpid is %s", mpid)

rawData := []byte("some raw data")
fmt.Printf("Original Val is: %s\n", string(rawData))
rawCodec := int64(0x55)
linkBytes, err := c1.Put(rawData, rawCodec)
if err != nil {
	fmt.Printf("Error storing the raw data: %v", err)
	return
}
c, err := cid.Cast(linkBytes)
if err != nil {
	fmt.Printf("Error casting bytes to CID: %v", err)
	return
}
fmt.Printf("Stored raw data link: %s\n", c.String())
log.Infof("Stored raw data link: %s", c.String())

recentCids, err := c1.ListRecentCidsAsStringWithChildren()
if err != nil {
	log.Errorw("Error happened in ListRecentCidsAsStringWithChildren", "err", err)
	panic(err)
}
for recentCids.HasNext() {
	cid, err := recentCids.Next()
	if err != nil {
		fmt.Printf("Error retrieving next CID: %v", err)
		log.Errorf("Error retrieving next CID: %v", err)
		// Decide if you want to break or continue based on your error handling strategy
		break
	}
	fmt.Printf("recentCid link: %s\n", cid) // Print each CID
	log.Infof("recentCid link: %s", cid)
}
Output:

Original Val is: some raw data
Stored raw data link: bafkr4ifmwbmdrkxep3mci37ionvgturlylvganap4ch7ouia2ui5tmr4iy
recentCid link: bafkr4ifmwbmdrkxep3mci37ionvgturlylvganap4ch7ouia2ui5tmr4iy
Example (PoolExchangeDagBetweenClientBlox)
server := startMockServer("127.0.0.1:4004")
defer func() {
	// Shutdown the server after test
	if err := server.Shutdown(context.Background()); err != nil {
		log.Error("Error happened in server.Shutdown")
		panic(err) // Handle the error as you see fit
	}
}()

const poolName = "1"
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()

// Elevate log level to show internal communications.
if err := logging.SetLogLevel("*", "debug"); err != nil {
	log.Error("Error happened in logging.SetLogLevel")
	panic(err)
}

// Use a deterministic random generator to generate deterministic
// output for the example.

// Instantiate the first node in the pool
h1, err := libp2p.New(libp2p.Identity(generateIdentity(1)))
if err != nil {
	log.Errorw("Error happened in libp2p.New", "err", err)
	panic(err)
}
n1, err := blox.New(
	blox.WithHost(h1),
	blox.WithPoolName("1"),
	blox.WithUpdatePoolName(updatePoolName),
	blox.WithBlockchainEndPoint("127.0.0.1:4004"),
	blox.WithPingCount(5),
	blox.WithExchangeOpts(
		exchange.WithIpniGetEndPoint("http://127.0.0.1:4004/cid/"),
	),
)
if err != nil {
	log.Errorw("Error happened in blox.New", "err", err)
	panic(err)
}
if err := n1.Start(ctx); err != nil {
	log.Errorw("Error happened in n1.Start", "err", err)
	panic(err)
}
defer n1.Shutdown(ctx)
fmt.Printf("Instantiated node in pool %s with ID: %s\n", poolName, h1.ID().String())

mcfg := fulamobile.NewConfig()
mcfg.AllowTransientConnection = true
bloxAddrString := ""
if len(h1.Addrs()) > 0 {
	// Convert the first multiaddr to a string
	bloxAddrString = h1.Addrs()[0].String()
	log.Infow("blox multiadddr is", "addr", bloxAddrString, "peerID", h1.ID().String())
} else {
	log.Errorw("Error happened in h1.Addrs", "err", "No addresses in slice")
	panic("No addresses in slice")
}
mcfg.BloxAddr = bloxAddrString + "/p2p/" + h1.ID().String()
mcfg.PoolName = "1"
mcfg.Exchange = bloxAddrString
mcfg.BlockchainEndpoint = "127.0.0.1:4004"
log.Infow("bloxAdd string created", "addr", bloxAddrString+"/p2p/"+h1.ID().String())

c1, err := fulamobile.NewClient(mcfg)
if err != nil {
	log.Errorw("Error happened in fulamobile.NewClient", "err", err)
	panic(err)
}
// Authorize exchange between the two nodes
mobilePeerIDString := c1.ID()
log.Infof("first client created with ID: %s", mobilePeerIDString)
mpid, err := peer.Decode(mobilePeerIDString)
if err != nil {
	log.Errorw("Error happened in peer.Decode", "err", err)
	panic(err)
}
if err := n1.SetAuth(ctx, h1.ID(), mpid, true); err != nil {
	log.Error("Error happened in n1.SetAuth")
	panic(err)
}

err = c1.ConnectToBlox()
if err != nil {
	log.Errorw("Error happened in c1.ConnectToBlox", "err", err)
	panic(err)
}
_, err = c1.BloxFreeSpace()
if err != nil {
	panic(err)
}

rawData := []byte("some raw data")
fmt.Printf("Original Val is: %s\n", string(rawData))
rawCodec := int64(0x55)
linkBytes, err := c1.Put(rawData, rawCodec)
if err != nil {
	fmt.Printf("Error storing the raw data: %v", err)
	return
}
c, err := cid.Cast(linkBytes)
if err != nil {
	fmt.Printf("Error casting bytes to CID: %v", err)
	return
}
fmt.Printf("Stored raw data link: %s\n", c.String())
log.Infof("Stored raw data link: %s", c.String())

recentCids, err := c1.ListRecentCidsAsStringWithChildren()
if err != nil {
	log.Errorw("Error happened in ListRecentCidsAsStringWithChildre", "err", err)
	panic(err)
}
for recentCids.HasNext() {
	cid, err := recentCids.Next()
	if err != nil {
		fmt.Printf("Error retrieving next CID: %v", err)
		log.Errorf("Error retrieving next CID: %v", err)
		// Decide if you want to break or continue based on your error handling strategy
		break
	}
	fmt.Printf("recentCid link: %s\n", cid) // Print each CID
	log.Infof("recentCid link: %s", cid)
}
fmt.Print("Waiting for 5 seconds\n")
time.Sleep(5 * time.Second)
fmt.Printf("Now fetching the link %x\n", linkBytes)
log.Infof("Now fetching the link %x", linkBytes)

c2, err := fulamobile.NewClient(mcfg)
if err != nil {
	log.Errorw("Error happened in fulamobile.NewClient2", "err", err)
	panic(err)
}
mobilePeerIDString2 := c2.ID()
log.Infof("second client created with ID: %s", mobilePeerIDString2)
mpid2, err := peer.Decode(mobilePeerIDString2)
if err != nil {
	log.Errorw("Error happened in peer.Decode2", "err", err)
	panic(err)
}
if err := n1.SetAuth(ctx, h1.ID(), mpid2, true); err != nil {
	log.Errorw("Error happened in n1.SetAuth2", "err", err)
	panic(err)
}

err = c2.ConnectToBlox()
if err != nil {
	log.Errorw("Error happened in c2.ConnectToBlox", "err", err)
	panic(err)
}
/*
	//If you uncomment this section, it just fetches the cid that blox stored and not with the key that mobile has
	ct, err := cid.Decode("bafyreibcwjmj25zyylzw36xaglokmmcbk7c4tqtouaz7qmw6nskx5iqgqi")
	if err != nil {
		fmt.Println("Error decoding CID:", err)
		return
	}
	linkBytes = ct.Bytes()
	//
*/
	//
*/
val, err := c2.Get(linkBytes)
if err != nil {
	log.Errorw("Error happened in c2.Get", "err", err)
	panic(err)
}
fmt.Printf("Fetched Val is: %s\n", string(val))
log.Infof("Fetched Val is: %v", val)
log.Infof("Original Val is: %v", rawData)
if !bytes.Equal(val, rawData) {
	panic(fmt.Sprintf("Original data is not equal to fetched data: [original] %s != [fetch] %s", string(val), string(rawData)))
}
Output:

Instantiated node in pool 1 with ID: 12D3KooWQfGkPUkoLDEeJE3H3ZTmu9BZvAdbJpmhha8WpjeSLKMM
Original Val is: some raw data
Stored raw data link: bafkr4ifmwbmdrkxep3mci37ionvgturlylvganap4ch7ouia2ui5tmr4iy
recentCid link: bafkr4ifmwbmdrkxep3mci37ionvgturlylvganap4ch7ouia2ui5tmr4iy
Waiting for 5 seconds
Now fetching the link 01551e20acb05838aae47ed8246fe8736a69d22bc2ea60340fe08ff75100d511d9b23c46
Fetched Val is: some raw data
Example (PoolExchangeLargeDagBetweenClientBlox)
server := startMockServer("127.0.0.1:4004")
defer func() {
	// Shutdown the server after test
	if err := server.Shutdown(context.Background()); err != nil {
		log.Error("Error happened in server.Shutdown")
		panic(err) // Handle the error as you see fit
	}
}()

const poolName = "1"
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()

// Elevate log level to show internal communications.
if err := logging.SetLogLevel("*", "debug"); err != nil {
	log.Error("Error happened in logging.SetLogLevel")
	panic(err)
}

// Use a deterministic random generator to generate deterministic
// output for the example.

// Instantiate the first node in the pool
h1, err := libp2p.New(libp2p.Identity(generateIdentity(1)))
if err != nil {
	log.Errorw("Error happened in libp2p.New", "err", err)
	panic(err)
}
n1, err := blox.New(
	blox.WithHost(h1),
	blox.WithPoolName("1"),
	blox.WithUpdatePoolName(updatePoolName),
	blox.WithBlockchainEndPoint("127.0.0.1:4004"),
	blox.WithPingCount(5),
	blox.WithExchangeOpts(
		exchange.WithIpniGetEndPoint("http://127.0.0.1:4004/cid/"),
	),
)
if err != nil {
	log.Errorw("Error happened in blox.New", "err", err)
	panic(err)
}
if err := n1.Start(ctx); err != nil {
	log.Errorw("Error happened in n1.Start", "err", err)
	panic(err)
}
defer n1.Shutdown(ctx)
fmt.Printf("Instantiated node in pool %s with ID: %s\n", poolName, h1.ID().String())

mcfg := fulamobile.NewConfig()
mcfg.AllowTransientConnection = true
bloxAddrString := ""
if len(h1.Addrs()) > 0 {
	// Convert the first multiaddr to a string
	bloxAddrString = h1.Addrs()[0].String()
	log.Infow("blox multiadddr is", "addr", bloxAddrString, "peerID", h1.ID().String())
} else {
	log.Errorw("Error happened in h1.Addrs", "err", "No addresses in slice")
	panic("No addresses in slice")
}
mcfg.BloxAddr = bloxAddrString + "/p2p/" + h1.ID().String()
mcfg.PoolName = "1"
mcfg.Exchange = bloxAddrString
mcfg.AllowTransientConnection = true
mcfg.DisableResourceManger = false
mcfg.StaticRelays = []string{}
mcfg.BlockchainEndpoint = "127.0.0.1:4004"
log.Infow("bloxAdd string created", "addr", bloxAddrString+"/p2p/"+h1.ID().String())

c1, err := fulamobile.NewClient(mcfg)
if err != nil {
	log.Errorw("Error happened in fulamobile.NewClient", "err", err)
	panic(err)
}
// Authorize exchange between the two nodes
mobilePeerIDString := c1.ID()
log.Infof("first client created with ID: %s", mobilePeerIDString)
mpid, err := peer.Decode(mobilePeerIDString)
if err != nil {
	log.Errorw("Error happened in peer.Decode", "err", err)
	panic(err)
}
if err := n1.SetAuth(ctx, h1.ID(), mpid, true); err != nil {
	log.Error("Error happened in n1.SetAuth")
	panic(err)
}

err = c1.ConnectToBlox()
if err != nil {
	log.Errorw("Error happened in c1.ConnectToBlox", "err", err)
	panic(err)
}
_, err = c1.BloxFreeSpace()
if err != nil {
	panic(err)
}

rawCodec := int64(0x55)
const totalSize = 200 * 1024 * 1024 // 50MB
const chunkSize = 256 * 1024        // 256KB
data := make([]byte, totalSize)     // replace with actual data if needed

// Fill the data with random values (or use actual data)
rand.Read(data)

var links [][]byte
var chunkedData [][]byte

for i := 0; i < totalSize; i += chunkSize {
	end := i + chunkSize
	if end > totalSize {
		end = totalSize
	}

	chunk := data[i:end]
	log.Debugf("Storing chunk %d to %d...\n", i, end)

	linkBytes, err := c1.Put(chunk, rawCodec)
	if err != nil {
		log.Errorf("Error storing chunk: %v\n", err)
		return
	}

	links = append(links, linkBytes)
	chunkedData = append(chunkedData, chunk)
}

fmt.Printf("Stored %d chunks\n", len(links))
log.Infof("Stored %d chunks\n", len(links))

recentCids, err := c1.ListRecentCidsAsString()
if err != nil {
	log.Errorw("Error happened in ListRecentCidsAsString", "err", err)
	panic(err)
}
var count = 0
for recentCids.HasNext() {
	count = count + 1
}
log.Infof("recentCids count: %d", count)
fmt.Printf("recentCids count: %d\n", count) // Print each CID

if count != len(links) {
	panic("recent cids count is not equal to put links count")
}
fmt.Print("Waiting for 5 seconds\n")
time.Sleep(5 * time.Second)
fmt.Printf("Now fetching the links\n")
log.Infof("Now fetching the links")

c2, err := fulamobile.NewClient(mcfg)
if err != nil {
	log.Errorw("Error happened in fulamobile.NewClient2", "err", err)
	panic(err)
}
mobilePeerIDString2 := c2.ID()
log.Infof("second client created with ID: %s", mobilePeerIDString2)
mpid2, err := peer.Decode(mobilePeerIDString2)
if err != nil {
	log.Errorw("Error happened in peer.Decode2", "err", err)
	panic(err)
}
if err := n1.SetAuth(ctx, h1.ID(), mpid2, true); err != nil {
	log.Errorw("Error happened in n1.SetAuth2", "err", err)
	panic(err)
}

err = c2.ConnectToBlox()
if err != nil {
	log.Errorw("Error happened in c2.ConnectToBlox", "err", err)
	panic(err)
}
/*
	//If you uncomment this section, it just fetches the cid that blox stored and not with the key that mobile has
	ct, err := cid.Decode("bafyreibcwjmj25zyylzw36xaglokmmcbk7c4tqtouaz7qmw6nskx5iqgqi")
	if err != nil {
		fmt.Println("Error decoding CID:", err)
		return
	}
	linkBytes = ct.Bytes()
	//
*/
	//
*/
count = 0
for _, link := range links {
	log.Debugf("Fetching link: %s\n", link)
	val, err := c2.Get(link)
	if err != nil {
		log.Fatal("Error fetching link", err)
		panic(err)
	}
	log.Debugf("Fetched chunk size: %d\n", len(val))
	if !bytes.Equal(val, chunkedData[count]) {
		c, err := cid.Cast(link)
		if err != nil {
			log.Errorf("Error casting bytes to CID: %v\n", err)
			panic(err)
		}
		panic(fmt.Sprintf("Original data is not equal to fetched data for count: %d for cid: %s: original data size:%d, retrieved data size:%d", count, c, len(chunkedData[count]), len(val)))
	}
	count = count + 1
}
fmt.Print("All chunks fetched")
Output:

Instantiated node in pool 1 with ID: 12D3KooWQfGkPUkoLDEeJE3H3ZTmu9BZvAdbJpmhha8WpjeSLKMM
Stored 800 chunks
recentCids count: 800
Waiting for 5 seconds
Now fetching the links
All chunks fetched

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateEd25519Key added in v0.5.2

func GenerateEd25519Key() ([]byte, error)

GenerateEd25519Key generates a random Ed25519 libp2p private key.

func GenerateEd25519KeyFromString added in v1.0.0

func GenerateEd25519KeyFromString(secret string) ([]byte, error)

Types

type AssetsBalanceResponse added in v1.54.8

type AssetsBalanceResponse struct {
	Amount uint64 `json:"amount"`
}

type Client added in v0.4.9

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.4.9

func NewClient(cfg *Config) (*Client, error)

func (*Client) AccountBalance added in v0.8.8

func (c *Client) AccountBalance(account string) ([]byte, error)

AccountBalance requests blox at Config.BloxAddr to get the balance of the account. the addr must be a valid multiaddr that includes peer ID.

func (*Client) AccountCreate added in v0.8.8

func (c *Client) AccountCreate() ([]byte, error)

AccountCreate requests blox at Config.BloxAddr to create a account.

func (*Client) AccountExists added in v0.8.8

func (c *Client) AccountExists(account string) ([]byte, error)

AccountExists requests blox at Config.BloxAddr to check if the account exists or not. the addr must be a valid multiaddr that includes peer ID.

func (*Client) AccountFund added in v0.8.8

func (c *Client) AccountFund(account string) ([]byte, error)

AccountFund requests blox at Config.BloxAddr to fund the account. the addr must be a valid multiaddr that includes peer ID.

func (*Client) AssetsBalance added in v1.18.0

func (c *Client) AssetsBalance(account string, assetId int, classId int) ([]byte, error)

AssetsBalance requests blox at Config.BloxAddr to get the balance of the account. the addr must be a valid multiaddr that includes peer ID.

func (*Client) BatchUploadManifest added in v1.53.0

func (c *Client) BatchUploadManifest(cidsBytes []byte, poolID int, replicationFactor int) ([]byte, error)

func (*Client) BloxFreeSpace added in v0.8.8

func (c *Client) BloxFreeSpace() ([]byte, error)

BloxFreeSpace requests the blox avail/used free space information.

func (*Client) ClearCidsFromRecent added in v1.15.0

func (c *Client) ClearCidsFromRecent(cidsBytes []byte) error

func (*Client) ConnectToBlox added in v0.8.0

func (c *Client) ConnectToBlox() error

ConnectToBlox attempts to connect to blox via the configured address. This function can be used to check if blox is currently accessible.

func (*Client) DeleteFulaConfig added in v1.14.0

func (c *Client) DeleteFulaConfig() ([]byte, error)

DeleteFulaConfig deletes config.yaml file

func (*Client) DeleteWifi added in v1.17.0

func (c *Client) DeleteWifi(name string) ([]byte, error)

Reboot requests the blox to reboot

func (*Client) DisconnectWifi added in v1.17.0

func (c *Client) DisconnectWifi(name string) ([]byte, error)

Reboot requests the blox to reboot

func (*Client) EraseBlData added in v1.30.0

func (c *Client) EraseBlData() ([]byte, error)

EraseBlData requests the blox to erase the data related to blockchain

func (*Client) FetchContainerLogs added in v1.44.0

func (c *Client) FetchContainerLogs(ContainerName string, TailCount string) ([]byte, error)

GetAccount requests blox at Config.BloxAddr to get the balance of the account. the addr must be a valid multiaddr that includes peer ID.

func (*Client) FindBestAndTargetInLogs added in v1.54.9

func (c *Client) FindBestAndTargetInLogs(NodeContainerName string, TailCount string) ([]byte, error)

GetAccount requests blox at Config.BloxAddr to get the balance of the account. the addr must be a valid multiaddr that includes peer ID.

func (*Client) Flush added in v0.8.1

func (c *Client) Flush() error

Flush guarantees that all values stored locally are synced to the baking local storage.

func (*Client) Get added in v0.4.9

func (c *Client) Get(key []byte) ([]byte, error)

Get gets the value corresponding to the given key from the local ipld.LinkSystem The key must be a valid ipld.Link and the value returned is encoded ipld.Node. If data is not found locally, an attempt is made to automatically fetch the data from blox at Config.BloxAddr address.

func (*Client) GetAccount added in v1.18.0

func (c *Client) GetAccount() ([]byte, error)

GetAccount requests blox at Config.BloxAddr to get the balance of the account. the addr must be a valid multiaddr that includes peer ID.

func (*Client) GetDatastoreSize added in v1.48.0

func (c *Client) GetDatastoreSize() ([]byte, error)

func (*Client) GetFolderSize added in v1.45.0

func (c *Client) GetFolderSize(folderPath string) ([]byte, error)

GetAccount requests blox at Config.BloxAddr to get the balance of the account. the addr must be a valid multiaddr that includes peer ID.

func (*Client) Has added in v0.4.9

func (c *Client) Has(key []byte) (bool, error)

Has checks whether the value corresponding to the given key is present in the local datastore. The key must be a valid ipld.Link.

func (*Client) ID added in v0.5.0

func (c *Client) ID() string

ID returns the libp2p peer ID of the client.

func (c *Client) IpniNotifyLink(l string)

func (*Client) ListFailedPushes added in v0.5.9

func (c *Client) ListFailedPushes() (*LinkIterator, error)

func (*Client) ListFailedPushesAsString added in v1.0.0

func (c *Client) ListFailedPushesAsString() (*StringIterator, error)

func (*Client) ListRecentCidsAsString added in v1.15.0

func (c *Client) ListRecentCidsAsString() (*StringIterator, error)

func (*Client) ListRecentCidsAsStringWithChildren added in v1.53.0

func (c *Client) ListRecentCidsAsStringWithChildren() (*StringIterator, error)

func (*Client) ManifestAvailable added in v0.8.8

func (c *Client) ManifestAvailable(poolID int) ([]byte, error)

ManifestAvailable requests blox at Config.BloxAddr to list manifests the addr must be a valid multiaddr that includes peer ID.

func (*Client) Partition added in v1.14.0

func (c *Client) Partition() ([]byte, error)

Partition requests the blox to partition ssd and nvme

func (*Client) PoolCancelJoin added in v0.8.8

func (c *Client) PoolCancelJoin(poolID int) ([]byte, error)

PoolJoin requests blox at Config.BloxAddr to cancel a join request for a pool with the id. the addr must be a valid multiaddr that includes peer ID. Note that this call is only allowed on a user's own blox

func (*Client) PoolJoin added in v0.8.8

func (c *Client) PoolJoin(poolID int) ([]byte, error)

PoolJoin requests blox at Config.BloxAddr to join a pool with the id. the addr must be a valid multiaddr that includes peer ID. Note that this call is only allowed on a user's own blox

func (*Client) PoolLeave added in v0.8.8

func (c *Client) PoolLeave(poolID int) ([]byte, error)

PoolLeave requests blox at Config.BloxAddr to leave a pool with the id. the addr must be a valid multiaddr that includes peer ID. Note that this call is only allowed on a user's own blox

func (*Client) PoolList added in v0.8.8

func (c *Client) PoolList() ([]byte, error)

PoolList requests blox at Config.BloxAddr to list the pools. the addr must be a valid multiaddr that includes peer ID.

func (*Client) PoolRequests added in v0.8.8

func (c *Client) PoolRequests(poolID int) ([]byte, error)

PoolListRequests requests blox at Config.BloxAddr to list the join request for a pool with the id. the addr must be a valid multiaddr that includes peer ID.

func (*Client) PoolUserList added in v0.8.8

func (c *Client) PoolUserList(poolID int) ([]byte, error)

PoolUserList requests blox at Config.BloxAddr to list the input pool users. the addr must be a valid multiaddr that includes peer ID.

func (*Client) Pull added in v0.4.9

func (c *Client) Pull(key []byte) error

Pull downloads the data corresponding to the given key from blox at Config.BloxAddr. The key must be a valid ipld.Link.

func (*Client) Push added in v0.4.9

func (c *Client) Push(key []byte) error

Push requests blox at Config.BloxAddr to download the given key from this node. The key must be a valid ipld.Link, and the addr must be a valid multiaddr that includes peer ID. The value corresponding to the given key must be stored in the local datastore prior to calling this function. See: Client.Put.

func (*Client) Put added in v0.4.9

func (c *Client) Put(value []byte, codec int64) ([]byte, error)

Put stores the given value onto the ipld.LinkSystem and returns its corresponding link. The value is decoded using the decoder that corresponds to the given codec. Therefore, the given value must be a valid ipld.Node. Upon successful local storage of the given value, it is automatically pushed to the blox at Config.BloxAddr address.

func (*Client) Reboot added in v1.0.0

func (c *Client) Reboot() ([]byte, error)

Reboot requests the blox to reboot

func (*Client) ReplicateInPool added in v1.53.0

func (c *Client) ReplicateInPool(cidsBytes []byte, account string, poolID int) []byte

func (*Client) RetryFailedPushes added in v0.8.1

func (c *Client) RetryFailedPushes() error

RetryFailedPushes retries pushing all links that failed to push. The retry is disrupted as soon as a failure occurs. See ListFailedPushes.

func (*Client) SetAuth added in v0.8.3

func (c *Client) SetAuth(on string, subject string, allow bool) error

SetAuth sets authorization on the given peer ID for the given subject.

func (*Client) Shutdown added in v0.4.9

func (c *Client) Shutdown() error

Shutdown closes all resources used by Client. After calling this function Client must be discarded.

func (*Client) TransferToFula added in v1.33.0

func (c *Client) TransferToFula(amountStr string, walletAccount string, chain string) ([]byte, error)

func (*Client) WifiRemoveall added in v1.0.0

func (c *Client) WifiRemoveall() ([]byte, error)

WifiRemoveall requests the blox to remove all saved wifis

type Config added in v0.4.9

type Config struct {
	Identity  []byte
	StorePath string
	// Exchange specifies the DAG exchange protocol for Fula mobile client. If left unspecified,
	// The default FxExchange protocol is used which will attempt to make remote connections
	// when links are stored and retrieved.
	//
	// For testing purposes, the value may be set to `noop`, in which case, no remote connections
	// will be made and the requested exchange is simply logged. When the value is set to `noop`
	// the BloxAddr may also be left empty.
	Exchange string
	BloxAddr string
	// StaticRelays specifies a list of static relays used by libp2p auto-relay.
	// Defaults to fx.land managed relay if unspecified.
	StaticRelays []string

	// ForceReachabilityPrivate configures weather the libp2p should always think that it is behind
	// NAT.
	ForceReachabilityPrivate bool

	// DisableResourceManger sets whether to disable the libp2p resource manager.
	DisableResourceManger bool

	// SyncWrites assures that writes to the local datastore are flushed to the backing store as
	// soon as they are written. By default, writes are not synchronized to disk until either the
	// client is shut down or Client.Flush is explicitly called.
	SyncWrites bool

	// AllowTransientConnection allows transient connectivity via relay when direct connection is
	// not possible. Defaults to enabled if unspecified.
	AllowTransientConnection bool
	PoolName                 string
	BlockchainEndpoint       string
}

func NewConfig added in v0.8.4

func NewConfig() *Config

NewConfig instantiates a new Config with default values.

type LinkIterator added in v0.8.0

type LinkIterator struct {
	// contains filtered or unexported fields
}

func (*LinkIterator) HasNext added in v0.8.0

func (i *LinkIterator) HasNext() bool

func (*LinkIterator) Next added in v0.8.0

func (i *LinkIterator) Next() ([]byte, error)

type StringIterator added in v1.0.0

type StringIterator struct {
	// contains filtered or unexported fields
}

func (*StringIterator) HasNext added in v1.0.0

func (i *StringIterator) HasNext() bool

func (*StringIterator) Next added in v1.0.0

func (i *StringIterator) Next() (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL