alicenet

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status  string
	Message []byte
}

An APIError returned from alicenet.

func (APIError) Error

func (a APIError) Error() string

Error reported from the API that isn't a low-level socket error.

type Account

type Account struct {
	Address string
	Balance string
}

An Account model to store in Spanner.

func (Account) Key

func (a Account) Key() spanner.Key

Key for the Account.

func (Account) List

func (Account) List(_ spanner.Key, limit, offset int64) spanner.Statement

List statement for Accounts.

func (Account) Table

func (Account) Table() string

Table to store Accounts.

type AccountStore

type AccountStore struct {
	Address     string
	Index       string
	IssuedAt    int64
	Value       string
	ObserveTime time.Time
}

An AccountStore model to store in Spanner.

func (AccountStore) Key

func (a AccountStore) Key() spanner.Key

Key for the AccountStore.

func (AccountStore) List

func (AccountStore) List(prefix spanner.Key, limit, offset int64) spanner.Statement

List statement for AccountStores.

func (AccountStore) Table

func (AccountStore) Table() string

Table to store AccountStores.

type AccountTransaction

type AccountTransaction struct {
	Address         string
	TransactionHash string
	ObserveTime     time.Time
}

An AccountTransaction model to store in Spanner.

func (AccountTransaction) Key

func (a AccountTransaction) Key() spanner.Key

Key for the AccountTransaction.

func (AccountTransaction) List

func (AccountTransaction) List(prefix spanner.Key, limit, offset int64) spanner.Statement

List statement for AccountTransactions.

func (AccountTransaction) Table

func (AccountTransaction) Table() string

Table to store AccountTransactions.

type Block

type Block struct {
	ChainID             int64
	Height              int64
	TransactionCount    int64
	PreviousBlockHash   string
	TransactionRootHash string
	StateRootHash       string
	HeaderRootHash      string
	GroupSignatureHash  string
	TransactionHashes   []string
	ObserveTime         time.Time
}

A Block model for storage in Spanner.

func (Block) Key

func (b Block) Key() spanner.Key

Key for the Block.

func (Block) List

func (Block) List(_ spanner.Key, limit, offset int64) spanner.Statement

List statement for Blocks.

func (Block) Table

func (Block) Table() string

Table to store Blocks.

type Client

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

Client to interact with alicenet. Note: This is a temporary solution as the GRPC endpoint is currently unavailable.

func Connect

func Connect(baseURL string) *Client

Connect to AliceNet.

func (*Client) BlockHeader

func (c *Client) BlockHeader(ctx context.Context, height uint32) (*proto.BlockHeader, error)

BlockHeader at a given height.

func (*Client) Height

func (c *Client) Height(ctx context.Context) (uint32, error)

Height of chain.

func (*Client) Transaction

func (c *Client) Transaction(ctx context.Context, hash string) (*MinedTransactionResponse, error)

Transaction for a given hash.

type DataStore

type DataStore struct {
	Signature           string
	TransactionHash     string
	ChainID             int64
	Index               string
	IssuedAt            int64
	Deposit             string
	RawData             string
	TransactionOutIndex int64
	Owner               string
	Fee                 string
	ObserveTime         time.Time
}

A DataStore model to store in Spanner.

func (DataStore) Key

func (d DataStore) Key() spanner.Key

Key for the DataStores.

func (DataStore) List

func (DataStore) List(prefix spanner.Key, _, _ int64) spanner.Statement

List statement for DataStores.

func (DataStore) Table

func (DataStore) Table() string

Table to store DataStores.

type Interface

type Interface interface {
	Height(context.Context) (uint32, error)
	BlockHeader(context.Context, uint32) (*proto.BlockHeader, error)
	Transaction(context.Context, string) (*MinedTransactionResponse, error)
}

The Interface to working with alicenet.

type MinedTransactionResponse

type MinedTransactionResponse struct {
	Tx struct {
		Fee string
		Vin []struct {
			TXInLinker struct {
				TXInPreImage struct {
					ChainID        uint32
					ConsumedTxIdx  uint32
					ConsumedTxHash string
				}
				TxHash string
			}
			Signature string
		}
		Vout []struct {
			DataStore *struct {
				DSLinker struct {
					DSPreImage struct {
						ChainID  uint32
						Index    string
						IssuedAt uint32
						Deposit  string
						RawData  string
						TXOutIdx uint32
						Owner    string
						Fee      string
					}
					TxHash string
				}
				Signature string
			}
			ValueStore *struct {
				VSPreImage struct {
					ChainID  uint32
					Value    string
					TXOutIdx uint32
					Owner    string
					Fee      string
				}
				TxHash string
			}
		}
	}
}

MinedTransactionResponse is a hack put in place to allow for json deserialization because the proto models will eat the contents of Vout. This will not be necessary after moving to using GRPC clients.

type Stores

type Stores struct {
	Blocks              store.Store[Block]
	Transactions        store.Store[Transaction]
	TransactionInputs   store.Store[TransactionInput]
	DataStores          store.Store[DataStore]
	ValueStores         store.Store[ValueStore]
	Accounts            store.Store[Account]
	AccountTransactions store.Store[AccountTransaction]
	AccountStores       store.Store[AccountStore]
}

Stores is a collection of all alicenet Storable objects.

func InSpanner

func InSpanner(client *spanner.Client) *Stores

InSpanner storage of all alicenet resources.

type Transaction

type Transaction struct {
	Height          int64
	TransactionHash string
	ObserveTime     time.Time
	Missing         *bool
}

A Transaction model for storage in Spanner.

func (Transaction) Key

func (t Transaction) Key() spanner.Key

Key for the Transaction.

func (Transaction) List

func (Transaction) List(_ spanner.Key, limit, offset int64) spanner.Statement

List statement for Transactions.

func (Transaction) Table

func (Transaction) Table() string

Table to store Transactions.

type TransactionInput

type TransactionInput struct {
	TransactionHash          string
	TransactionIndex         int64
	ChainID                  int64
	ConsumedTransactionHash  string
	ConsumedTransactionIndex int64
	Signature                string
	ObserveTime              time.Time
}

A TransactionInput for storage in Spanner.

func (TransactionInput) Key

func (t TransactionInput) Key() spanner.Key

Key for the Transaction.

func (TransactionInput) List

func (TransactionInput) List(prefix spanner.Key, _, _ int64) spanner.Statement

List statement for TransactionInputs.

func (TransactionInput) Table

func (TransactionInput) Table() string

Table to store TransactionInputs.

type ValueStore

type ValueStore struct {
	TransactionHash     string
	ChainID             int64
	Value               string
	TransactionOutIndex int64
	Owner               string
	Fee                 string
	ObserveTime         time.Time
}

A ValueStore model to store in Spanner.

func (ValueStore) Key

func (v ValueStore) Key() spanner.Key

Key for the ValueStores.

func (ValueStore) List

func (ValueStore) List(prefix spanner.Key, _, _ int64) spanner.Statement

List statement for ValueStores.

func (ValueStore) Table

func (ValueStore) Table() string

Table to store ValueStores.

Jump to

Keyboard shortcuts

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