types

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ArweaveSignType  = 1
	ED25519SignType  = 2
	EthereumSignType = 3
	SolanaSignType   = 4
)
View Source
const (
	SuccessTxStatus = "Success"
	PendingTxStatus = "Pending"

	MAX_CHUNK_SIZE = 256 * 1024
	MIN_CHUNK_SIZE = 32 * 1024
	NOTE_SIZE      = 32
	HASH_SIZE      = 32

	// concurrent submit chunks min size
	DEFAULT_CHUNK_CONCURRENT_NUM = 50 // default concurrent number

	// number of bits in a big.Word
	WordBits = 32 << (uint64(^big.Word(0)) >> 63)
	// number of bytes in a big.Word
	WordBytes      = WordBits / 8
	BranchNodeType = "branch"
	LeafNodeType   = "leaf"

	// Maximum amount of chunks we will upload in the body.
	MAX_CHUNKS_IN_BODY = 1

	// Amount we will delay on receiving an error response but do want to continue.
	ERROR_DELAY = 1000 * 40
)
View Source
const (
	BUNDLER_HOST           = "https://node1.bundlr.network"
	MIN_BUNDLE_BINARY_SIZE = 1044
)

about bundle

Variables

View Source
var FATAL_CHUNK_UPLOAD_ERRORS = map[string]struct{}{
	"{\"error\":\"disk_full\"}":                        struct{}{},
	"{\"error\":\"invalid_json\"}":                     struct{}{},
	"{\"error\":\"chunk_too_big\"}":                    struct{}{},
	"{\"error\":\"data_path_too_big\"}":                struct{}{},
	"{\"error\":\"offset_too_big\"}":                   struct{}{},
	"{\"error\":\"data_size_too_big\"}":                struct{}{},
	"{\"error\":\"chunk_proof_ratio_not_attractive\"}": struct{}{},
	"{\"error\":\"invalid_proof\"}":                    struct{}{},
}

Errors from /chunk we should never try and continue on.

View Source
var SigConfigMap = map[int]SigMeta{
	ArweaveSignType: {
		SigLength: 512,
		PubLength: 512,
		SigName:   "arweave",
	},
	ED25519SignType: {
		SigLength: 64,
		PubLength: 32,
		SigName:   "ed25519",
	},
	EthereumSignType: {
		SigLength: 65,
		PubLength: 65,
		SigName:   "ethereum",
	},
	SolanaSignType: {
		SigLength: 64,
		PubLength: 32,
		SigName:   "solana",
	},
}

Functions

This section is empty.

Types

type Block

type Block struct {
	Nonce                    string        `json:"nonce"`
	PreviousBlock            string        `json:"previous_block"`
	Timestamp                int64         `json:"timestamp"`
	LastRetarget             int64         `json:"last_retarget"`
	Diff                     interface{}   `json:"diff"`
	Height                   int64         `json:"height"`
	Hash                     string        `json:"hash"`
	IndepHash                string        `json:"indep_hash"`
	Txs                      []string      `json:"txs"`
	TxRoot                   string        `json:"tx_root"`
	TxTree                   interface{}   `json:"tx_tree"`
	HashList                 interface{}   `json:"hash_list"`
	HashListMerkle           string        `json:"hash_list_merkle"`
	WalletList               string        `json:"wallet_list"`
	RewardAddr               string        `json:"reward_addr"`
	Tags                     []interface{} `json:"tags"`
	RewardPool               interface{}   `json:"reward_pool"` // always string
	WeaveSize                interface{}   `json:"weave_size"`  // always string
	BlockSize                interface{}   `json:"block_size"`  // always string
	CumulativeDiff           interface{}   `json:"cumulative_diff"`
	SizeTaggedTxs            interface{}   `json:"size_tagged_txs"`
	Poa                      POA           `json:"poa"`
	UsdToArRate              []string      `json:"usd_to_ar_rate"`
	ScheduledUsdToArRate     []string      `json:"scheduled_usd_to_ar_rate"`
	Packing25Threshold       string        `json:"packing_2_5_threshold"`
	StrictDataSplitThreshold string        `json:"strict_data_split_threshold"`
}

type Bundle

type Bundle struct {
	Items            []BundleItem `json:"items"`
	BundleBinary     []byte
	BundleDataReader *os.File
}

type BundleItem

type BundleItem struct {
	SignatureType int    `json:"signatureType"`
	Signature     string `json:"signature"`
	Owner         string `json:"owner"`  //  utils.Base64Encode(pubkey)
	Target        string `json:"target"` // optional, if exist must length 32, and is base64 str
	Anchor        string `json:"anchor"` // optional, if exist must length 32, and is base64 str
	Tags          []Tag  `json:"tags"`
	Data          string `json:"data"`
	Id            string `json:"id"`
	TagsBy        string `json:"tagsBy"` // utils.Base64Encode(TagsBytes) for retry assemble item

	ItemBinary []byte   `json:"-"`
	DataReader *os.File `json:"-"`
}

type BundlrResp

type BundlrResp struct {
	Id                  string   `json:"id"`
	Signature           string   `json:"signature"`
	N                   string   `json:"n"`
	Public              string   `json:"public"`
	Block               int64    `json:"block"`
	ValidatorSignatures []string `json:"validatorSignatures"`
}

type Chunk

type Chunk struct {
	DataHash     []byte
	MinByteRange int
	MaxByteRange int
}

type Chunks

type Chunks struct {
	DataRoot []byte   `json:"data_root"`
	Chunks   []Chunk  `json:"chunks"`
	Proofs   []*Proof `json:"proofs"`
}

type GetChunk

type GetChunk struct {
	DataRoot string `json:"data_root"`
	DataSize string `json:"data_size"`
	DataPath string `json:"data_path"`
	Offset   string `json:"offset"`
	Chunk    string `json:"chunk"`
}

func (*GetChunk) Marshal

func (gc *GetChunk) Marshal() ([]byte, error)

type Input

type Input map[string]interface{}

func (Input) ToString

func (i Input) ToString() (string, error)

type NetworkInfo

type NetworkInfo struct {
	Network          string `json:"network"`
	Version          int64  `json:"version"`
	Release          int64  `json:"release"`
	Height           int64  `json:"height"`
	Current          string `json:"current"`
	Blocks           int64  `json:"blocks"`
	Peers            int64  `json:"peers"`
	QueueLength      int64  `json:"queue_length"`
	NodeStateLatency int64  `json:"node_state_latency"`
}

type Node

type Node struct {
	ID           []byte
	Type         string // "branch" or "leaf"
	DataHash     []byte // only leaf node
	MinByteRange int    // only leaf node
	MaxByteRange int
	ByteRange    int   // only branch node
	LeftChild    *Node // only branch node
	RightChild   *Node // only branch node
}

Node include leaf node and branch node

type POA

type POA struct {
	Option   string `json:"option"`
	TxPath   string `json:"tx_path"`
	DataPath string `json:"data_path"`
	Chunk    string `json:"chunk"`
}

type Proof

type Proof struct {
	Offest int
	Proof  []byte
}

type SigMeta

type SigMeta struct {
	SigLength int
	PubLength int
	SigName   string
}

type Tag

type Tag struct {
	Name  string `json:"name" avro:"name"`
	Value string `json:"value" avro:"value"`
}

type Transaction

type Transaction struct {
	Format     int      `json:"format"`
	ID         string   `json:"id"`
	LastTx     string   `json:"last_tx"`
	Owner      string   `json:"owner"` // utils.Base64Encode(wallet.PubKey.N.Bytes())
	Tags       []Tag    `json:"tags"`
	Target     string   `json:"target"`
	Quantity   string   `json:"quantity"`
	Data       string   `json:"data"` // base64.encode
	DataReader *os.File `json:"-"`    // when dataSize too big use dataReader, set Data = ""
	DataSize   string   `json:"data_size"`
	DataRoot   string   `json:"data_root"`
	Reward     string   `json:"reward"`
	Signature  string   `json:"signature"`

	// Computed when needed.
	Chunks *Chunks `json:"-"`
}

type TransactionChunk

type TransactionChunk struct {
	Chunk    string `json:"chunk"`
	DataPath string `json:"data_path"`
	TxPath   string `json:"tx_path"`
}

type TransactionOffset

type TransactionOffset struct {
	Size   string `json:"size"`
	Offset string `json:"offset"`
}

type TxStatus

type TxStatus struct {
	BlockHeight           int    `json:"block_height"`
	BlockIndepHash        string `json:"block_indep_hash"`
	NumberOfConfirmations int    `json:"number_of_confirmations"`
}

Jump to

Keyboard shortcuts

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