Documentation ¶
Overview ¶
Package index provides the implementation of Charm type and its associated methods.
Package index provides the implementation of Degree struct and its associated methods.
Package index provides the implementation of Height type and its associated methods.
Package index provides the implementation of Rarity type and its associated methods.
Package index provides the implementation of blockchain reorganization detection.
Package index provides the implementation of the Sat struct and its related functions.
Index ¶
- Constants
- Variables
- func WithBatchClient(cli *rpcclient.Client) func(*Options)
- func WithClient(cli *rpcclient.Client) func(*Options)
- func WithDB(db *dao.DB) func(*Options)
- func WithIndexSats(indexSats string) func(*Options)
- func WithIndexSpendSats(indexSpendSats string) func(*Options)
- func WithTidbSessionMemLimit(tidbSessionMemLimit int) func(*Options)
- type Amount
- type Charm
- type Charms
- type Curse
- type Degree
- type Envelope
- type Envelopes
- type Epoch
- type ErrRecoverable
- type Flotsam
- type Height
- type Indexer
- type InscriptionUpdater
- type Option
- type Options
- type Origin
- type OriginNew
- type OriginOld
- type Protocol
- type PushBytes
- type RangeCaches
- func (c *RangeCaches) Delete(outpoint string) (*bytes.Buffer, bool)
- func (c *RangeCaches) Len() int
- func (c *RangeCaches) Range(fn func(k string, v *bytes.Buffer))
- func (c *RangeCaches) Read(outpoint string) (*bytes.Buffer, bool)
- func (c *RangeCaches) Size() int
- func (c *RangeCaches) Write(outpoint string, ranges []byte)
- type Rarity
- type RawEnvelope
- type RawEnvelopes
- type Sat
- type TagType
- type ValueCache
- func (c *ValueCache) Delete(outpoint string, height ...uint32)
- func (c *ValueCache) Len() int
- func (c *ValueCache) Range(fn func(k string, v int64))
- func (c *ValueCache) Read(outpoint string) (int64, bool)
- func (c *ValueCache) Size() int
- func (c *ValueCache) Values() map[string]int64
- func (c *ValueCache) Write(outpoint string, value int64)
- type Witness
Constants ¶
const ( SupplySat = 2099999997690000 LastSupplySat = SupplySat - 1 )
Constants representing the total supply of Sat and the last supply of Sat.
const CycleEpochs uint32 = 6
CycleEpochs is a constant that represents the number of epochs in a cycle.
const DiffChangeInterval uint32 = 2016
DiffChangeInterval is a constant that represents the interval at which the difficulty changes.
const SubsidyHalvingInterval uint32 = 210_000
SubsidyHalvingInterval is the interval at which the subsidy halves.
Variables ¶
var CharmsAll = Charms{ CharmCoin, CharmCursed, CharmEpic, CharmLegendary, CharmLost, CharmNineBall, CharmRare, CharmReInscription, CharmUnbound, CharmUncommon, CharmVindicated, }
CharmsAll is a slice of Charm.
var EpochStartingStats = []Sat{ 0, 1050000000000000, 1575000000000000, 1837500000000000, 1968750000000000, 2034375000000000, 2067187500000000, 2083593750000000, 2091796875000000, 2095898437500000, 2097949218750000, 2098974609270000, 2099487304530000, 2099743652160000, 2099871825870000, 2099935912620000, 2099967955890000, 2099983977420000, 2099991988080000, 2099995993410000, 2099997995970000, 2099998997250000, 2099999497890000, 2099999748210000, 2099999873370000, 2099999935950000, 2099999967240000, 2099999982780000, 2099999990550000, 2099999994330000, 2099999996220000, 2099999997060000, 2099999997480000, SupplySat, }
EpochStartingStats is the starting statistics for each epoch.
var ErrDetectReorg = errors.New("unrecoverable reorg detected")
var FirstPostSubsidy = Epoch{ // contains filtered or unexported fields }
FirstPostSubsidy is the first epoch after the subsidy.
Functions ¶
func WithBatchClient ¶
WithBatchClient is a function that returns an Option. This Option sets the batchCli field of the Options struct to the provided rpcclient.Client instance.
func WithClient ¶
WithClient is a function that returns an Option. This Option sets the cli field of the Options struct to the provided rpcclient.Client instance.
func WithDB ¶
WithDB is a function that returns an Option. This Option sets the db field of the Options struct to the provided dao.DB instance.
func WithIndexSats ¶
WithIndexSats is a function that returns an Option.
func WithIndexSpendSats ¶
WithIndexSpendSats is a function that returns an Option.
func WithTidbSessionMemLimit ¶
Types ¶
type Charm ¶
type Charm uint16
Charm is a type that represents a charm in the blockchain.
var ( CharmCoin Charm = 0 // Represents a coin charm CharmCursed Charm = 1 // Represents a cursed charm CharmEpic Charm = 2 // Represents an epic charm CharmLegendary Charm = 3 // Represents a legendary charm CharmLost Charm = 4 // Represents a lost charm CharmNineBall Charm = 5 // Represents a nine ball charm CharmRare Charm = 6 // Represents a rare charm CharmReInscription Charm = 7 // Represents a re-inscription charm CharmUnbound Charm = 8 // Represents an unbound charm CharmUncommon Charm = 9 // Represents an uncommon charm CharmVindicated Charm = 10 // Represents a vindicated charm )
Define various types of charms as constants of type Charm.
func TitleToCharm ¶
TitleToCharm is a function that returns a pointer to a Charm for a given title.
func (*Charm) Icon ¶
Icon is a method that returns the corresponding icon for a charm. It uses a switch statement to determine the charm type and returns a string representing the icon. If the charm type is not recognized, it returns an empty string.
func (*Charm) IsSet ¶
IsSet is a method that checks if a charm is set in a set of charms. It takes a uint16 as a parameter and returns a bool. The method checks if the bit at the position of the charm in the set of charms is set. If the bit is set, it returns true. Otherwise, it returns false.
type Charms ¶
type Charms []Charm
func (Charms) Titles ¶
Titles is a method that generates a list of titles for a given set of charms. It takes an uint16 representing a set of charms as a parameter. The method iterates over the Charms slice and checks if each charm is set in the given set of charms. If a charm is set, its title is appended to the list of titles. The method returns a slice of strings representing the titles of the set charms.
type Curse ¶
type Curse int
Curse represents the type of curse that can be applied to an inscription.
const ( CurseDuplicateField Curse = 1 CurseIncompleteField Curse = 2 CurseNotAtOffsetZero Curse = 3 CurseNotInFirstInput Curse = 4 CursePointer Curse = 5 CursePushNum Curse = 6 CurseReInscription Curse = 7 CurseStutter Curse = 8 CurseUnrecognizedEvenField Curse = 9 )
These constants represent the different types of curses that can be applied to an inscription.
type Degree ¶
type Degree struct {
// contains filtered or unexported fields
}
Degree is a struct that represents a degree in the blockchain. It contains four fields: - hour: the number of hours in the degree, calculated as the height divided by the product of CycleEpochs and SubsidyHalvingInterval. - minute: the number of minutes in the degree, calculated as the height modulo SubsidyHalvingInterval. - second: the number of seconds in the degree, calculated as the height modulo DiffChangeInterval. - third: the third part of the degree, obtained from the Sat struct.
func NewDegreeFromSat ¶
NewDegreeFromSat is a function that creates a Degree from a Sat. It takes a pointer to a Sat as a parameter and returns a pointer to a Degree. The function first gets the height from the Sat. It then calculates the hour, minute, and second fields of the Degree using the height. It also gets the third field of the Degree from the Sat. Finally, it creates a Degree with the calculated fields and returns it.
type Envelope ¶
type Envelope struct {
// contains filtered or unexported fields
}
Envelope represents an envelope in a transaction. It is a struct that contains the following fields: - input: an integer that represents the index of the input in the transaction. - offset: an integer that represents the offset of the envelope in the transaction. - pushNum: a boolean that indicates whether the envelope is a push number envelope. - stutter: a boolean that indicates whether the envelope is stuttered. - payload: a pointer to an Inscription struct that represents the payload of the envelope.
type Envelopes ¶
type Envelopes []*Envelope
Envelopes is a slice of pointers to Envelope.
func EnvelopeFromRawEnvelope ¶
func EnvelopeFromRawEnvelope(raw RawEnvelopes) Envelopes
EnvelopeFromRawEnvelope is a function that creates envelopes from raw envelopes. It takes a slice of pointers to RawEnvelope as a parameter and returns a slice of pointers to Envelope. The function iterates over each raw envelope in the slice. For each raw envelope, it creates an envelope. If the envelope is not nil, it appends the envelope to the slice of envelopes. After iterating over all raw envelopes, it returns the slice of envelopes.
func ParsedEnvelopFromTransaction ¶
ParsedEnvelopFromTransaction parses envelopes from a transaction.
type Epoch ¶
type Epoch struct {
// contains filtered or unexported fields
}
Epoch represents a period in the blockchain.
func NewEpochFrom ¶
NewEpochFrom creates a new epoch from a given height.
func NewEpochFromSat ¶
NewEpochFromSat creates a new epoch from a given sat.
func (*Epoch) StartingHeight ¶
StartingHeight returns the starting height of the epoch.
func (*Epoch) StartingSat ¶
StartingSat returns the starting sat of the epoch.
type ErrRecoverable ¶
func (*ErrRecoverable) Error ¶
func (r *ErrRecoverable) Error() string
type Flotsam ¶
type Flotsam struct { // InscriptionId is a pointer to the unique identifier of the inscription. InscriptionId *tables.InscriptionId // Offset is the position of the inscription within the transaction. Offset uint64 // Origin is the source of the inscription. It can be either new or old. Origin Origin }
Flotsam represents a floating inscription.
type Height ¶
type Height struct {
// contains filtered or unexported fields
}
Height is a struct that represents a height in the blockchain. It contains a single field, height, which is an uint32.
func NewHeight ¶
NewHeight is a function that creates a Height. It takes an uint32 as a parameter and returns a pointer to a Height. The function creates a Height with the given height and returns it.
func (*Height) N ¶
N is a method that gets the height of a Height. It takes no parameters and returns an uint32. The method returns the height of the Height.
func (*Height) StartingSat ¶
StartingSat is a method that gets the starting Sat of a Height.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer is a struct that holds the configuration options and state for the Indexer.
func NewIndexer ¶
NewIndexer is a function that returns a pointer to a new Indexer instance. It takes a variadic number of Option functions as arguments, which are used to set the configuration options for the Indexer.
func (*Indexer) BatchRpcClient ¶
BatchRpcClient is a method that returns a pointer to the rpcclient.Client instance associated with the Indexer. This client is used for making batch RPC calls to the Bitcoin node.
func (*Indexer) Begin ¶
Begin is a method that starts a new transaction and returns a pointer to the dao.DB instance associated with the transaction.
func (*Indexer) DB ¶
DB is a method that returns a pointer to the dao.DB instance associated with the Indexer.
func (*Indexer) RpcClient ¶
RpcClient is a method that returns a pointer to the rpcclient.Client instance associated with the Indexer. This client is used for making RPC calls to the Bitcoin node.
func (*Indexer) UpdateIndex ¶
UpdateIndex is a method that updates the index of the blockchain. It fetches blocks from the blockchain, starting from the current height of the indexer, and indexes them. If the indexer is configured to index satoshis, it flushes the satoshi range cache to the database. It also updates various statistics related to the indexing process. The method returns an error if there is any issue during the indexing process.
type InscriptionUpdater ¶
type InscriptionUpdater struct {
// contains filtered or unexported fields
}
InscriptionUpdater is responsible for updating inscriptions.
type Option ¶
type Option func(*Options)
Option is a function type that takes a pointer to an Options struct.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is a struct that holds configuration options for the Indexer.
type Origin ¶
Origin represents the origin of an inscription.
It is a struct that contains two pointers, one to an OriginNew and one to an OriginOld. These pointers represent the new and old origins of an inscription respectively. Only one of these pointers should be non-nil at a time, depending on whether the inscription is new or old.
Fields:
New (*OriginNew): A pointer to an OriginNew struct, representing a new origin of an inscription. Old (*OriginOld): A pointer to an OriginOld struct, representing an old origin of an inscription.
type OriginNew ¶
type OriginNew struct { // Cursed is a boolean flag indicating whether the inscription is cursed. Cursed bool // Fee is the fee associated with the inscription. It is represented as an int64. Fee int64 // Hidden is a boolean flag indicating whether the inscription is hidden. Hidden bool // Pointer is an int32 that points to the location of the inscription. Pointer []byte // ReInscription is a boolean flag indicating whether the inscription is a re-inscription. ReInscription bool // Unbound is a boolean flag indicating whether the inscription is unbound. Unbound bool // Inscription is a pointer to the Envelope struct that contains the inscription. Inscription *Envelope }
OriginNew represents a new origin of an inscription.
type OriginOld ¶
type OriginOld struct {
OldSatPoint tables.SatPointToSequenceNum
}
OriginOld represents an old origin of an inscription.
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
func NewProtocol ¶
func NewProtocol(wtx *dao.DB, entry *tables.Inscriptions) *Protocol
NewProtocol is a function that returns a new protocol.
func (*Protocol) SaveProtocol ¶
SaveProtocol is a function that saves the protocol.
type RangeCaches ¶
func NewRangeCaches ¶
func NewRangeCaches() *RangeCaches
func (*RangeCaches) Len ¶
func (c *RangeCaches) Len() int
func (*RangeCaches) Size ¶
func (c *RangeCaches) Size() int
func (*RangeCaches) Write ¶
func (c *RangeCaches) Write(outpoint string, ranges []byte)
type Rarity ¶
type Rarity uint8
Rarity is a type that represents a rarity in the blockchain.
const ( RarityCommon Rarity = iota // Represents a common rarity RarityUncommon // Represents an uncommon rarity RarityRare // Represents a rare rarity RarityEpic // Represents an epic rarity RarityLegendary // Represents a legendary rarity RarityMythic // Represents a mythic rarity )
Define various types of rarities as constants of type Rarity.
func NewRarityFromSat ¶
NewRarityFromSat is a function that creates a Rarity from a Sat. It takes a pointer to a Sat as a parameter and returns a Rarity. The function first creates a Degree from the Sat. It then checks the fields of the Degree to determine the rarity. If all fields of the Degree are zero, the rarity is Mythic. If the minute, second, and third fields are zero, the rarity is Legendary. If the minute and third fields are zero, the rarity is Epic. If the second and third fields are zero, the rarity is Rare. If the third field is zero, the rarity is Uncommon. Otherwise, the rarity is Common. Finally, it returns the determined rarity.
type RawEnvelope ¶
type RawEnvelope struct {
// contains filtered or unexported fields
}
RawEnvelope represents a raw envelope in a transaction. It is a struct that contains the following fields: - payload: a 2D byte slice that represents the payload of the envelope. - input: an integer that represents the index of the input in the transaction. - offset: an integer that represents the offset of the envelope in the transaction. - pushNum: a boolean that indicates whether the envelope is a push number envelope. - stutter: a boolean that indicates whether the envelope is stuttered.
type RawEnvelopes ¶
type RawEnvelopes []*RawEnvelope
RawEnvelopes is a slice of pointers to RawEnvelope.
func RawEnvelopeFromTransaction ¶
func RawEnvelopeFromTransaction(tx *wire.MsgTx) RawEnvelopes
RawEnvelopeFromTransaction is a function that creates raw envelopes from a transaction. It takes a transaction as a parameter and returns a slice of pointers to RawEnvelope. The function iterates over each input in the transaction. For each input, it creates a Witness and checks if it is a Taproot script. If the Witness is not a Taproot script, it continues to the next input. If the Witness is a Taproot script, it creates a script tokenizer and iterates over the instructions in the script. For each instruction, it creates a raw envelope and checks if the envelope is not nil. If the envelope is not nil, it appends the envelope to the slice of envelopes. If the envelope is nil, it sets the stuttered flag to the value of stutter. After iterating over all inputs and instructions, it returns the slice of envelopes.
type Sat ¶
type Sat uint64
Sat represents a uint64 value of Sat.
func AmountToSat ¶
AmountToSat converts a float64 amount to Sat.
func (*Sat) Coin ¶
Coin checks if the Sat is a Coin. It returns true if the Sat is divisible by OneBtc, false otherwise.
func (*Sat) EpochPosition ¶
EpochPosition returns the position of the Sat in the epoch. It calculates the position by subtracting the starting Sat of the epoch from the Sat.
func (*Sat) Height ¶
Height returns the Height of the Sat. It calculates the Height by adding the starting height of the epoch to the epoch position divided by the epoch subsidy.
type TagType ¶
type TagType int
TagType represents the type of tag in the blockchain.
const ( TagPointer TagType = iota TagUnbound TagContentType TagParent TagMetadata TagMetaprotocol TagContentEncoding TagDelegate TagCInsDescription TagNop )
Constants representing the different types of tags.
func TagFromBytes ¶
TagFromBytes creates a new TagType from a given byte slice. It determines the TagType by comparing the first byte of the slice with the constants.
func (TagType) Bytes ¶
Bytes returns the byte representation of the TagType. It determines the byte representation by comparing the TagType with the constants.
func (TagType) IsChunked ¶
IsChunked checks if the TagType is chunked. It returns true if the TagType is TagMetadata, false otherwise.
func (TagType) RemoveField ¶
RemoveField removes a field from a given map of fields. If the TagType is chunked, it removes all values associated with the TagType. If the TagType is not chunked, it removes the first value associated with the TagType. It returns the removed value(s) as a byte slice.
type ValueCache ¶
func NewValueCache ¶
func NewValueCache() *ValueCache
func (*ValueCache) Delete ¶
func (c *ValueCache) Delete(outpoint string, height ...uint32)
func (*ValueCache) Len ¶
func (c *ValueCache) Len() int
func (*ValueCache) Range ¶
func (c *ValueCache) Range(fn func(k string, v int64))
func (*ValueCache) Size ¶
func (c *ValueCache) Size() int
func (*ValueCache) Values ¶
func (c *ValueCache) Values() map[string]int64
func (*ValueCache) Write ¶
func (c *ValueCache) Write(outpoint string, value int64)
type Witness ¶
type Witness struct { wire.TxWitness // The witness in a transaction // contains filtered or unexported fields }
Witness is a struct that represents a witness in a transaction. It contains two fields: - tokenizer: a pointer to a ScriptTokenizer from the txscript package. This is used to tokenize the script in the witness. - TxWitness: an embedded field from the wire package. This represents the witness in a transaction.
func (*Witness) IsTaprootScript ¶
IsTaprootScript checks if the witness is a Taproot script. It first checks if the length of the witness is less than 2, if so it returns false. It then checks if the last element of the witness is an annex, if so it sets the position from last to 3. If the length of the witness is less than the position from last, it returns false. It then creates a script tokenizer from the witness at the position from last and sets the witness's tokenizer to this new tokenizer. It finally returns true, indicating that the witness is a Taproot script.
func (*Witness) ScriptTokenizer ¶
func (w *Witness) ScriptTokenizer() *txscript.ScriptTokenizer
ScriptTokenizer returns the script tokenizer of the witness.