network

package
v0.0.0-...-ebe377f Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account interface {
	// GetPubKey returns the public key of this account.
	GetPubKey() []byte

	// Sign signs a message with this account's secret key.
	Sign(message []byte, callback SignCallback)

	// Verify verifies the signature of this account.
	Verify(signBytes []byte, message []byte, callback VerifyCallback)

	// SetProperty sets a property for this algorithm account. Plugin can save some extra data of this account if needed.
	// Notices that the properties belong to the keyPair, if default keyPair changes, properties would be changed.
	SetProperty(key string, value string)

	// GetProperty retrieves a property for this algorithm account of a certain key.
	GetProperty(key string) string
}

Account interface represents an account.

type Block

type Block struct {
	ChainPath         string
	Number            int64
	Hash              string
	ParentHash        []string
	Roots             []string
	TransactionHashes []string
	Timestamp         int64
	Bytes             []byte
}

func (Block) HashCode

func (b Block) HashCode() int

func (Block) String

func (b Block) String() string

type CallRequest

type CallRequest struct {
	Path       string                 // 调用资源的路径。例如:payment.chain0.hello
	Method     string                 // 资源函数的方法名。例如:"transfer"
	Args       []string               // 函数的参数。例如:["Tom", "100"]
	Nonce      int64                  // 唯一性标识符
	Sender     string                 // 调用请求的发送者
	Version    string                 // luyu 协议的版本
	LuyuSign   []byte                 // 由 luyu 账户签名的签名
	Properties map[string]interface{} // 扩展参数
}

CallRequest 结构表示一个调用请求

func (CallRequest) String

func (cr CallRequest) String() string

String 返回调用请求的字符串表示形式

type CallResponse

type CallResponse struct {
	Result  []string // Resource function's return output
	Code    int64    // Error code
	Message string   // Error message
	Path    string   // Transaction path of the calling resource. eg: payment.chain0.hello
	Method  string   // Transaction method of resource function name. eg: "transfer"
	Args    []string // Transaction arguments of function. eg: ["Tom", "100"]
	Version string   // version of luyu protocol
}

func (CallResponse) String

func (c CallResponse) String() string

type CallResponseCallback

type CallResponseCallback interface {
	// Define CallResponseCallback interface
	OnResponse(status int, message string, callResponse CallResponse)
}

type Events

type Events interface {
	// Define Events interface methods
	SendTransaction(tx Transaction, callback ReceiptCallback)
	Call(request CallRequest, callback CallResponseCallback)
	GetAccountByIdentity(identity string, callback KeyCallback)
}

type KeyCallback

type KeyCallback interface {
	// Define KeyCallback interface method
	OnResponse(account Account)
}

type Receipt

type Receipt struct {
	Result           []string // Resource function's return output
	Code             int      // Error code of blockchain
	Message          string   // Error message of blockchain
	Path             string   // Transaction path of the calling resource. eg: payment.chain0.hello
	Method           string   // Transaction method of resource function name. eg: "transfer"
	Args             []string // Transaction arguments of function. eg: ["Tom", "100"]
	TransactionHash  string   // Original transaction hash
	TransactionBytes []byte   // The original transaction bytes of a certain blockchain
	BlockNumber      int64    // Block number of this transaction belongs to
	Version          string   // version of luyu protocol
}

Receipt represents a transaction receipt.

func (Receipt) String

func (r Receipt) String() string

type ReceiptCallback

type ReceiptCallback interface {
	// Define ReceiptCallback interface
	OnResponse(status int, message string, receipt Receipt)
}

type Resource

type Resource struct {
	Path       string
	Type       string
	Methods    []string
	Properties map[string]interface{}
}

func (Resource) String

func (r Resource) String() string

type SignCallback

type SignCallback func(status int, message string, signBytes []byte)

SignCallback is a callback function for signing.

type Transaction

type Transaction struct {
	Path       string                 // 调用资源的路径。例如:payment.chain0.hello
	Method     string                 // 资源函数的方法名。例如:"transfer"
	Args       []string               // 函数的参数。例如:["Tom", "100"]
	Nonce      int64                  // 唯一性标识符
	Sender     string                 // 交易发送者
	Version    string                 // luyu 协议的版本
	LuyuSign   []byte                 // 由 luyu 账户签名的签名
	Properties map[string]interface{} // 扩展参数
}

Transaction 结构表示一个交易

func (Transaction) String

func (t Transaction) String() string

String 返回交易的字符串表示形式

type VerifyCallback

type VerifyCallback func(status int, message string, verifyResult bool)

VerifyCallback is a callback function for signature verification.

Jump to

Keyboard shortcuts

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