blockchain

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)
View Source
const (
	FxBlockchainProtocolID = "/fx.land/blockchain/0.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalanceRequest

type AccountBalanceRequest struct {
	Account string `json:"account"`
}

type AccountBalanceResponse

type AccountBalanceResponse struct {
	Amount BigInt `json:"amount"`
}

type AccountCreateRequest

type AccountCreateRequest struct {
	Account string `json:"account"`
}

type AccountCreateResponse

type AccountCreateResponse struct {
	Account string `json:"account"`
}

type AccountExistsRequest

type AccountExistsRequest struct {
	Account string `json:"account"`
}

type AccountExistsResponse

type AccountExistsResponse struct {
	Account string `json:"account"`
	Exists  bool   `json:"exists"`
}

type AccountFundRequest

type AccountFundRequest struct {
	Amount BigInt `json:"amount"`
	To     string `json:"to"`
}

type AccountFundResponse

type AccountFundResponse struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Amount BigInt `json:"amount"`
}

type BigInt

type BigInt struct {
	big.Int
}

func (BigInt) MarshalJSON

func (b BigInt) MarshalJSON() ([]byte, error)

func (*BigInt) UnmarshalJSON

func (b *BigInt) UnmarshalJSON(p []byte) error

type Blockchain

type Blockchain interface {
	Seeded(context.Context, peer.ID, SeededRequest) ([]byte, error)
	AccountExists(context.Context, peer.ID, AccountExistsRequest) ([]byte, error)
	AccountCreate(context.Context, peer.ID) ([]byte, error)
	AccountFund(context.Context, peer.ID, AccountFundRequest) ([]byte, error)
	AccountBalance(context.Context, peer.ID, AccountBalanceRequest) ([]byte, error)
	PoolCreate(context.Context, peer.ID, PoolCreateRequest) ([]byte, error)
	PoolJoin(context.Context, peer.ID, PoolJoinRequest) ([]byte, error)
	PoolCancelJoin(context.Context, peer.ID, PoolCancelJoinRequest) ([]byte, error)
	PoolRequests(context.Context, peer.ID, PoolRequestsRequest) ([]byte, error)
	PoolList(context.Context, peer.ID, PoolListRequest) ([]byte, error)
	PoolUserList(context.Context, peer.ID, PoolUserListRequest) ([]byte, error)
	PoolVote(context.Context, peer.ID, PoolVoteRequest) ([]byte, error)
	PoolLeave(context.Context, peer.ID, PoolLeaveRequest) ([]byte, error)
	ManifestUpload(context.Context, peer.ID, ManifestUploadRequest) ([]byte, error)
	ManifestStore(context.Context, peer.ID, ManifestStoreRequest) ([]byte, error)
	ManifestAvailable(context.Context, peer.ID, ManifestAvailableRequest) ([]byte, error)
	ManifestRemove(context.Context, peer.ID, ManifestRemoveRequest) ([]byte, error)
	ManifestRemoveStorer(context.Context, peer.ID, ManifestRemoveStorerRequest) ([]byte, error)
	ManifestRemoveStored(context.Context, peer.ID, ManifestRemoveStoredRequest) ([]byte, error)
	SetAuth(context.Context, peer.ID, peer.ID, bool) error

	//Hardware
	BloxFreeSpace(context.Context, peer.ID) ([]byte, error)
	WifiRemoveall(context.Context, peer.ID) ([]byte, error)
	Reboot(context.Context, peer.ID) ([]byte, error)
}

type Config

type Config struct {
	StoreDir string `yaml:"storeDir"`
}

type FxBlockchain

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

func NewFxBlockchain

func NewFxBlockchain(h host.Host, keyStorer KeyStorer, o ...Option) (*FxBlockchain, error)

func (*FxBlockchain) AccountBalance

func (bl *FxBlockchain) AccountBalance(ctx context.Context, to peer.ID, r AccountBalanceRequest) ([]byte, error)

func (*FxBlockchain) AccountCreate

func (bl *FxBlockchain) AccountCreate(ctx context.Context, to peer.ID) ([]byte, error)

func (*FxBlockchain) AccountExists

func (bl *FxBlockchain) AccountExists(ctx context.Context, to peer.ID, r AccountExistsRequest) ([]byte, error)

func (*FxBlockchain) AccountFund

func (bl *FxBlockchain) AccountFund(ctx context.Context, to peer.ID, r AccountFundRequest) ([]byte, error)

func (*FxBlockchain) BloxFreeSpace

func (bl *FxBlockchain) BloxFreeSpace(ctx context.Context, to peer.ID) ([]byte, error)

func (*FxBlockchain) ManifestAvailable

func (bl *FxBlockchain) ManifestAvailable(ctx context.Context, to peer.ID, r ManifestAvailableRequest) ([]byte, error)

func (*FxBlockchain) ManifestRemove

func (bl *FxBlockchain) ManifestRemove(ctx context.Context, to peer.ID, r ManifestRemoveRequest) ([]byte, error)

func (*FxBlockchain) ManifestRemoveStored

func (bl *FxBlockchain) ManifestRemoveStored(ctx context.Context, to peer.ID, r ManifestRemoveStoredRequest) ([]byte, error)

func (*FxBlockchain) ManifestRemoveStorer

func (bl *FxBlockchain) ManifestRemoveStorer(ctx context.Context, to peer.ID, r ManifestRemoveStorerRequest) ([]byte, error)

func (*FxBlockchain) ManifestStore

func (bl *FxBlockchain) ManifestStore(ctx context.Context, to peer.ID, r ManifestStoreRequest) ([]byte, error)

func (*FxBlockchain) ManifestUpload

func (bl *FxBlockchain) ManifestUpload(ctx context.Context, to peer.ID, r ManifestUploadRequest) ([]byte, error)

func (*FxBlockchain) PlugSeedIfNeeded

func (bl *FxBlockchain) PlugSeedIfNeeded(ctx context.Context, action string, req interface{}) interface{}

func (*FxBlockchain) PoolCancelJoin

func (bl *FxBlockchain) PoolCancelJoin(ctx context.Context, to peer.ID, r PoolCancelJoinRequest) ([]byte, error)

func (*FxBlockchain) PoolCreate

func (bl *FxBlockchain) PoolCreate(ctx context.Context, to peer.ID, r PoolCreateRequest) ([]byte, error)

func (*FxBlockchain) PoolJoin

func (bl *FxBlockchain) PoolJoin(ctx context.Context, to peer.ID, r PoolJoinRequest) ([]byte, error)

func (*FxBlockchain) PoolLeave

func (bl *FxBlockchain) PoolLeave(ctx context.Context, to peer.ID, r PoolLeaveRequest) ([]byte, error)

func (*FxBlockchain) PoolList

func (bl *FxBlockchain) PoolList(ctx context.Context, to peer.ID, r PoolListRequest) ([]byte, error)

func (*FxBlockchain) PoolRequests

func (bl *FxBlockchain) PoolRequests(ctx context.Context, to peer.ID, r PoolRequestsRequest) ([]byte, error)

func (*FxBlockchain) PoolUserList

func (bl *FxBlockchain) PoolUserList(ctx context.Context, to peer.ID, r PoolUserListRequest) ([]byte, error)

func (*FxBlockchain) PoolVote

func (bl *FxBlockchain) PoolVote(ctx context.Context, to peer.ID, r PoolVoteRequest) ([]byte, error)

func (*FxBlockchain) Reboot added in v1.0.0

func (bl *FxBlockchain) Reboot(ctx context.Context, to peer.ID) ([]byte, error)

func (*FxBlockchain) Seeded

func (bl *FxBlockchain) Seeded(ctx context.Context, to peer.ID, r SeededRequest) ([]byte, error)

func (*FxBlockchain) SetAuth

func (bl *FxBlockchain) SetAuth(ctx context.Context, on peer.ID, subject peer.ID, allow bool) error

func (*FxBlockchain) Shutdown

func (bl *FxBlockchain) Shutdown(ctx context.Context) error

func (*FxBlockchain) Start

func (bl *FxBlockchain) Start(ctx context.Context) error

func (*FxBlockchain) WifiRemoveall added in v1.0.0

func (bl *FxBlockchain) WifiRemoveall(ctx context.Context, to peer.ID) ([]byte, error)

type KeyStorer

type KeyStorer interface {
	SaveKey(ctx context.Context, key []byte) error
	LoadKey(ctx context.Context) ([]byte, error)
}

Implementations for this interface should be responsible for saving/loading a single key.

type Manifest

type Manifest struct {
	PoolID               int          `json:"pool_id"`
	ReplicationAvailable int          `json:"replication_available"`
	ManifestData         ManifestData `json:"manifest_data"`
}

type ManifestAvailableRequest

type ManifestAvailableRequest struct {
	PoolID int `json:"pool_id"`
}

type ManifestAvailableResponse

type ManifestAvailableResponse struct {
	Manifests []Manifest `json:"manifests"`
}

type ManifestData

type ManifestData struct {
	Uploader         string           `json:"uploader"`
	ManifestMetadata ManifestMetadata `json:"manifest_metadata"`
}

type ManifestJob

type ManifestJob struct {
	Work   string `json:"work"`
	Engine string `json:"engine"`
	Uri    string `json:"uri"`
}

type ManifestMetadata

type ManifestMetadata struct {
	Job ManifestJob `json:"job"`
}

type ManifestRemoveRequest

type ManifestRemoveRequest struct {
	Cid    string `json:"cid"`
	PoolID int    `json:"pool_id"`
}

type ManifestRemoveResponse

type ManifestRemoveResponse struct {
	Uploader string `json:"uploader"`
	Cid      string `json:"cid"`
	PoolID   int    `json:"pool_id"`
}

type ManifestRemoveStoredRequest

type ManifestRemoveStoredRequest struct {
	Uploader string `json:"uploader"`
	Cid      string `json:"cid"`
	PoolID   int    `json:"pool_id"`
}

type ManifestRemoveStoredResponse

type ManifestRemoveStoredResponse struct {
	Uploader string `json:"uploader"`
	Storage  string `json:"storage"`
	Cid      string `json:"cid"`
	PoolID   int    `json:"pool_id"`
}

type ManifestRemoveStorerRequest

type ManifestRemoveStorerRequest struct {
	Storage string `json:"storage"`
	Cid     string `json:"cid"`
	PoolID  int    `json:"pool_id"`
}

type ManifestRemoveStorerResponse

type ManifestRemoveStorerResponse struct {
	Uploader string `json:"uploader"`
	Storage  string `json:"storage"`
	Cid      string `json:"cid"`
	PoolID   int    `json:"pool_id"`
}

type ManifestStoreRequest

type ManifestStoreRequest struct {
	Uploader string `json:"uploader"`
	Cid      string `json:"cid"`
	PoolID   int    `json:"pool_id"`
}

type ManifestStoreResponse

type ManifestStoreResponse struct {
	PoolID   int    `json:"pool_id"`
	Storage  string `json:"storage"`
	Uploader string `json:"uploader"`
	Cid      string `json:"cid"`
}

type ManifestUploadRequest

type ManifestUploadRequest struct {
	PoolID            int              `json:"pool_id"`
	ReplicationFactor int              `json:"replication_factor"`
	ManifestMetadata  ManifestMetadata `json:"manifest_metadata"`
}

type ManifestUploadResponse

type ManifestUploadResponse struct {
	Uploader         string           `json:"uploader"`
	Storage          []string         `json:"storage"`
	ManifestMetadata ManifestMetadata `json:"manifest_metadata"`
	PoolID           int              `json:"pool_id"`
}

type Option

type Option func(*options) error

func WithAllowTransientConnection

func WithAllowTransientConnection(t bool) Option

func WithAuthorizer

func WithAuthorizer(a peer.ID) Option

func WithBlockchainEndPoint

func WithBlockchainEndPoint(b string) Option

func WithTimeout

func WithTimeout(to int) Option

type Pool

type Pool struct {
	PoolID       int      `json:"pool_id"`
	Owner        string   `json:"owner"`
	PoolName     string   `json:"pool_name"`
	Parent       string   `json:"parent"`
	Participants []string `json:"participants"`
}

type PoolCancelJoinRequest

type PoolCancelJoinRequest struct {
	PoolID int `json:"pool_id"`
}

type PoolCancelJoinResponse

type PoolCancelJoinResponse struct {
	Account string `json:"account"`
	PoolID  int    `json:"pool_id"`
}

type PoolCreateRequest

type PoolCreateRequest struct {
	PoolName string `json:"pool_name"`
	PeerID   string `json:"peer_id"`
}

type PoolCreateResponse

type PoolCreateResponse struct {
	Owner  string `json:"owner"`
	PoolID int    `json:"pool_id"`
}

type PoolJoinRequest

type PoolJoinRequest struct {
	PoolID int    `json:"pool_id"`
	PeerID string `json:"peer_id"`
}

type PoolJoinResponse

type PoolJoinResponse struct {
	Account string `json:"account"`
	PoolID  int    `json:"pool_id"`
}

type PoolLeaveRequest

type PoolLeaveRequest struct {
	PoolID int `json:"pool_id"`
}

type PoolLeaveResponse

type PoolLeaveResponse struct {
	Account string `json:"account"`
	PoolID  int    `json:"pool_id"`
}

type PoolListRequest

type PoolListRequest struct {
}

type PoolListResponse

type PoolListResponse struct {
	Pools []Pool `json:"pools"`
}

type PoolRequest

type PoolRequest struct {
	PoolID        int      `json:"pool_id"`
	Account       string   `json:"account"`
	Voted         []string `json:"voted"`
	PositiveVotes int      `json:"positive_votes"`
	PeerID        string   `json:"peer_id"`
}

type PoolRequestsRequest

type PoolRequestsRequest struct {
	PoolID int `json:"pool_id"`
}

type PoolRequestsResponse

type PoolRequestsResponse struct {
	PoolRequests []PoolRequest `json:"poolrequests"`
}

type PoolUserListRequest

type PoolUserListRequest struct {
	PoolID int `json:"pool_id"`
}

type PoolUserListResponse

type PoolUserListResponse struct {
	Users []User `json:"users"`
}

type PoolVoteRequest

type PoolVoteRequest struct {
	PoolID    int    `json:"pool_id"`
	Account   string `json:"account"`
	VoteValue bool   `json:"vote_value"`
}

type PoolVoteResponse

type PoolVoteResponse struct {
	Account string `json:"account"`
	PoolID  int    `json:"pool_id"`
}

type ReqInterface

type ReqInterface interface{}

type SeededRequest

type SeededRequest struct {
	Seed string `json:"seed"`
}

type SeededResponse

type SeededResponse struct {
	Seed    string `json:"seed"`
	Account string `json:"account"`
}

type SimpleKeyStorer

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

func NewSimpleKeyStorer

func NewSimpleKeyStorer() *SimpleKeyStorer

func (*SimpleKeyStorer) LoadKey

func (s *SimpleKeyStorer) LoadKey(ctx context.Context) ([]byte, error)

func (*SimpleKeyStorer) SaveKey

func (s *SimpleKeyStorer) SaveKey(ctx context.Context, key []byte) error

type User

type User struct {
	PoolID        int    `json:"pool_id"`
	RequestPoolID int    `json:"request_pool_id"`
	Account       string `json:"account"`
	PeerID        string `json:"peer_id"`
}

Jump to

Keyboard shortcuts

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