stores

package
v0.0.0-...-425d0f2 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 8 Imported by: 33

Documentation

Index

Constants

View Source
const (
	ChannelStatusOpening                fields.VarUint1 = 0 // Normal opening
	ChannelStatusChallenging            fields.VarUint1 = 1 // Challenging period
	ChannelStatusAgreementClosed        fields.VarUint1 = 2 // After negotiation is closed, reuse can be enabled again
	ChannelStatusFinalArbitrationClosed fields.VarUint1 = 3 // Final arbitration closed, never reusable

)
View Source
const (
	DiamondStatusNormal           fields.VarUint1 = 0
	DiamondStatusLendingSystem    fields.VarUint1 = 1
	DiamondStatusLendingOtherUser fields.VarUint1 = 2
)
View Source
const (

	// Diamonds
	TotalSupplyStoreTypeOfDiamond uint8 = 0 // Number of diamonds excavated
	// BTC
	TotalSupplyStoreTypeOfTransferBitcoin uint8 = 1 // Number of BTCs transferred successfully
	// Circulation quantity
	TotalSupplyStoreTypeOfBlockReward                    uint8 = 2 // Block reward HAC accumulation
	TotalSupplyStoreTypeOfChannelInterest                uint8 = 3 // Channel interest HAC accumulation
	TotalSupplyStoreTypeOfBitcoinTransferUnlockSuccessed uint8 = 4 // HAC accumulation successfully unlocked by bitcoin transfer and issuance
	// data statistics
	TotalSupplyStoreTypeOfLocatedHACInChannel uint8 = 5 // Number of HACs currently effectively locked in the channel
	TotalSupplyStoreTypeOfLocatedSATInChannel uint8 = 6 // Number of SATs currently effectively locked in the channel
	TotalSupplyStoreTypeOfChannelOfOpening    uint8 = 7 // Number of channels currently on
	// Destruction fee
	TotalSupplyStoreTypeOfBurningTotal uint8 = 8 // Handling charge combustion destruction HAC accumulation
	// Diamond lending
	TotalSupplyStoreTypeOfSystemLendingDiamondCurrentMortgageCount      uint8 = 9  // Real time statistics of loan and mortgage amount of diamond system
	TotalSupplyStoreTypeOfSystemLendingDiamondCumulationLoanHacAmount   uint8 = 10 // HAC daily flow quantity of diamond system mortgage cumulative lending
	TotalSupplyStoreTypeOfSystemLendingDiamondCumulationRansomHacAmount uint8 = 11 // Cumulative redemption (destruction) HAC flow of diamond system mortgage
	// Bitcoin lending (0.01 BTC per share)
	TotalSupplyStoreTypeOfSystemLendingBitcoinPortionCurrentMortgageCount      uint8 = 12 // Real time statistics of loan mortgage shares in bitcoin system
	TotalSupplyStoreTypeOfSystemLendingBitcoinPortionBurningInterestHacAmount  uint8 = 13 // Statistics of pre destruction interest of debit and credit in bitcoin system
	TotalSupplyStoreTypeOfSystemLendingBitcoinPortionCumulationLoanHacAmount   uint8 = 14 // Cumulative lending HAC daily flow quantity of debit and credit in bitcoin system
	TotalSupplyStoreTypeOfSystemLendingBitcoinPortionCumulationRansomHacAmount uint8 = 15 // HAC daily flow quantity of debit and credit cumulative redemption in bitcoin system
	// Inter user credit
	TotalSupplyStoreTypeOfUsersLendingCumulationDiamond                  uint8 = 16 // Daily accumulation of inter user loan diamond quantity
	TotalSupplyStoreTypeOfUsersLendingCumulationBitcoin                  uint8 = 17 // Daily accumulation of inter user debit and credit bitcoin quantity (unit: piece)
	TotalSupplyStoreTypeOfUsersLendingCumulationHacAmount                uint8 = 18 // 用户间借贷HAC借出额流水累计(借出累计而非归还累计)
	TotalSupplyStoreTypeOfUsersLendingBurningOnePercentInterestHacAmount uint8 = 19 // 1% interest statistics of inter user loan system destruction
	TotalSupplyStoreTypeOfDiamondBidBurningZhu                           uint8 = 20 // Diamond bidding fee burning part (unit:zhu)
	TotalSupplyStoreTypeOfDiamondEngravedBurning                         uint8 = 21 // Diamond Engraved burning
	TotalSupplyStoreTypeOfDiamondEngravedOperateCount                    uint8 = 22 // Diamond Engraved to do count

)
View Source
const (
	BitcoinSyslendIdLength = 15
)
View Source
const (
	ChannelIdLength = 16
)
View Source
const (
	DiamondSize = 1 + fields.AddressSize
)
View Source
const (
	DiamondSyslendIdLength = 14
)
View Source
const (
	LockblsIdLength = 18
)
View Source
const SatoshiGenesisLogStorePageLimit int = 50
View Source
const (
	UserLendingIdLength = 17
)

Variables

This section is empty.

Functions

func SatoshiGenesisPageSerialize

func SatoshiGenesisPageSerialize(page []*SatoshiGenesis) []byte

func SatoshiGenesisPageSerializeForShow

func SatoshiGenesisPageSerializeForShow(page []*SatoshiGenesis) []string

Types

type Balance

type Balance struct {
	Diamond fields.VarUint3
	Satoshi fields.Satoshi
	Hacash  fields.Amount // max_len = 11
}

func NewBalanceWithAmount

func NewBalanceWithAmount(amt *fields.Amount) *Balance

func NewEmptyBalance

func NewEmptyBalance() *Balance

func (*Balance) Parse

func (this *Balance) Parse(buf []byte, seek uint32) (uint32, error)

func (*Balance) Serialize

func (this *Balance) Serialize() ([]byte, error)

func (*Balance) Size

func (this *Balance) Size() uint32

type BitcoinSystemLending

type BitcoinSystemLending struct {
	IsRansomed                 fields.Bool        // Whether it has been redeemed (redeemed)
	CreateBlockHeight          fields.BlockHeight // 借贷开启时的区块高度
	MainAddress                fields.Address     // Address of Borrower
	MortgageBitcoinPortion     fields.VarUint2    // Number of mortgage bitcoin copies (each = 0.01btc)
	LoanTotalAmount            fields.Amount      // The total lending HAC quantity must be less than or equal to the lendable quantity
	PreBurningInterestAmount   fields.Amount      // Interest for pre destruction must be greater than or equal to the destroyed quantity
	RealtimeTotalMortgageRatio fields.VarUint2    // Value: 0~10000, unit: 10000

	// Write data if redeemed
	RansomBlockHeight              fields.BlockHeight     // Block height at redemption
	RansomAmount                   fields.Amount          // Redemption amount
	RansomAddressIfPublicOperation fields.OptionalAddress // If it is a third party redemption, record the third party address

}

func NewBitcoinSystemLending

func NewBitcoinSystemLending(address fields.Address) *BitcoinSystemLending

func (*BitcoinSystemLending) DropRansomedStatus

func (elm *BitcoinSystemLending) DropRansomedStatus() error

Remove redemption status

func (*BitcoinSystemLending) Parse

func (elm *BitcoinSystemLending) Parse(buf []byte, seek uint32) (uint32, error)

func (*BitcoinSystemLending) Serialize

func (elm *BitcoinSystemLending) Serialize() ([]byte, error)

func (*BitcoinSystemLending) SetRansomedStatus

func (elm *BitcoinSystemLending) SetRansomedStatus(height uint64, amount *fields.Amount, address fields.Address) error

func (*BitcoinSystemLending) Size

func (elm *BitcoinSystemLending) Size() uint32

type Channel

type Channel struct {
	BelongHeight         fields.BlockHeight // Block height when channel is opened
	ArbitrationLockBlock fields.VarUint2    // Number of blocks to be locked for unilateral end channel
	InterestAttribution  fields.VarUint1    // Interest attribution of 1% annualized: 0 Press end to assign 1 All to left 2 Give it all right
	LeftAddress          fields.Address
	LeftAmount           fields.Amount           // HAC
	LeftSatoshi          fields.SatoshiVariation // SAT
	RightAddress         fields.Address
	RightAmount          fields.Amount           // Mortgage amount 2
	RightSatoshi         fields.SatoshiVariation // SAT
	ReuseVersion         fields.VarUint4         // Reuse version number from 1
	Status               fields.VarUint1         // Closed and settled

	// Status = 1 challenge period save data
	IsHaveChallengeLog         fields.Bool             // Record challenge data log
	ChallengeLaunchHeight      fields.BlockHeight      // Block height at the beginning of the challenge
	AssertBillAutoNumber       fields.VarUint8         // Statement serial number provided by the proposer
	AssertAddressIsLeftOrRight fields.Bool             // Whether the proposer is the left address or the right true left false right
	AssertAmount               fields.Amount           // The amount claimed by the proponent
	AssertSatoshi              fields.SatoshiVariation // The sat that proponents claim they should be assigned

	// Status = 2 or status = 3 fund allocation has been closed
	LeftFinalDistributionAmount  fields.Amount           // Final allocation amount on the left
	LeftFinalDistributionSatoshi fields.SatoshiVariation // Final allocation amount on the left

}

func CreateEmptyChannel

func CreateEmptyChannel() *Channel

func (*Channel) CleanChallengingLog

func (this *Channel) CleanChallengingLog()

func (*Channel) IsAgreementClosed

func (this *Channel) IsAgreementClosed() bool

func (*Channel) IsChallenging

func (this *Channel) IsChallenging() bool

func (*Channel) IsClosed

func (this *Channel) IsClosed() bool

func (*Channel) IsFinalDistributionClosed

func (this *Channel) IsFinalDistributionClosed() bool

func (*Channel) IsOpening

func (this *Channel) IsOpening() bool

State judgment

func (*Channel) Parse

func (this *Channel) Parse(buf []byte, seek uint32) (uint32, error)

func (*Channel) Serialize

func (this *Channel) Serialize() ([]byte, error)

func (*Channel) SetAgreementClosed

func (this *Channel) SetAgreementClosed(leftEndAmt *fields.Amount, satoshi fields.Satoshi)

Status operation

func (*Channel) SetChallenging

func (this *Channel) SetChallenging(blkhei uint64, isLeftAddr bool, assertAmount *fields.Amount, assertSAT fields.Satoshi, billno uint64)

func (*Channel) SetFinalArbitrationClosed

func (this *Channel) SetFinalArbitrationClosed(leftEndAmt *fields.Amount, satoshi fields.Satoshi)

func (*Channel) SetOpening

func (this *Channel) SetOpening()

func (*Channel) Size

func (this *Channel) Size() uint32

type Chaswap

type Chaswap struct {
	IsBeUsed fields.Bool // Whether it has been used and cannot be reused
	// Signature address
	AddressCount                            fields.VarUint1 // Signature quantity, can only be 2 or 3
	OnchainTransferFromAndMustSignAddresses []fields.Address
}

Exchange transactions between channels and atoms on the chain, and save credentials

func (*Chaswap) Parse

func (elm *Chaswap) Parse(buf []byte, seek uint32) (uint32, error)

func (*Chaswap) Serialize

func (elm *Chaswap) Serialize() ([]byte, error)

func (*Chaswap) Size

func (this *Chaswap) Size() uint32

type Diamond

type Diamond struct {
	Status  fields.VarUint1 // Status 0 Normally available and transferable 1 Mortgage to system 2 Mortgage to other users
	Address fields.Address
	// engraved info
	EngravedPrevBlockHeight fields.BlockHeight
	EngravedContents        fields.StringMax255List255
}

func NewDiamond

func NewDiamond(address fields.Address) *Diamond

func (*Diamond) Parse

func (this *Diamond) Parse(buf []byte, seek uint32) (uint32, error)

func (*Diamond) Serialize

func (this *Diamond) Serialize() ([]byte, error)

func (*Diamond) Size

func (this *Diamond) Size() uint32

type DiamondSmelt

type DiamondSmelt struct {
	Diamond              fields.DiamondName // WTYUIAHXVMEKBSZN
	Number               fields.DiamondNumber
	ContainBlockHeight   fields.BlockHeight
	ContainBlockHash     fields.Hash // current pending block hash
	PrevContainBlockHash fields.Hash // prev block hash
	MinerAddress         fields.Address
	ApproxFeeOffer       fields.Amount  // Fee Amount
	Nonce                fields.Bytes8  // nonce
	CustomMessage        fields.Bytes32 // msg
	// data statistics
	AverageBidBurnPrice fields.VarUint2 // Average number of HAc destroyed by bidding, rounded down, the lowest one, the highest 65535
	// other data
	//VisualGene fields.Bytes10 // Visual appearance gene
	LifeGene fields.Hash
}

func (*DiamondSmelt) GetApproxFeeOffer

func (this *DiamondSmelt) GetApproxFeeOffer() *fields.Amount

func (*DiamondSmelt) GetVisualGene

func (this *DiamondSmelt) GetVisualGene() fields.Bytes10

func (*DiamondSmelt) Parse

func (this *DiamondSmelt) Parse(buf []byte, seek uint32) (uint32, error)

func (*DiamondSmelt) ParseApproxFeeOffer

func (this *DiamondSmelt) ParseApproxFeeOffer(amt *fields.Amount) error

func (*DiamondSmelt) Serialize

func (this *DiamondSmelt) Serialize() ([]byte, error)

func (*DiamondSmelt) Size

func (this *DiamondSmelt) Size() uint32

type DiamondSystemLending

type DiamondSystemLending struct {
	IsRansomed          fields.Bool                 // Whether it has been redeemed (redeemed)
	CreateBlockHeight   fields.BlockHeight          // 借贷开启时的区块高度
	MainAddress         fields.Address              // Address of Borrower
	MortgageDiamondList fields.DiamondListMaxLen200 // Mortgage diamond list
	LoanTotalAmountMei  fields.VarUint4             // [枚数]总共借出HAC额度,必须等于总可借额度,不能多也不能少
	BorrowPeriod        fields.VarUint1             // Borrowing cycle: one cycle represents 0.5% interest and 10000 blocks for about 35 days, with a minimum of 1 and a maximum of 20

	// Write data if redeemed
	RansomBlockHeight              fields.BlockHeight     // Block height at redemption
	RansomAmount                   fields.Amount          // Redemption amount
	RansomAddressIfPublicOperation fields.OptionalAddress // If it is a third party redemption, record the third party address

}

func NewDiamondSystemLending

func NewDiamondSystemLending(address fields.Address) *DiamondSystemLending

func (*DiamondSystemLending) DropRansomedStatus

func (elm *DiamondSystemLending) DropRansomedStatus() error

Remove redemption status

func (*DiamondSystemLending) Parse

func (elm *DiamondSystemLending) Parse(buf []byte, seek uint32) (uint32, error)

func (*DiamondSystemLending) Serialize

func (elm *DiamondSystemLending) Serialize() ([]byte, error)

func (*DiamondSystemLending) SetRansomedStatus

func (elm *DiamondSystemLending) SetRansomedStatus(height uint64, amount *fields.Amount, address fields.Address) error

func (*DiamondSystemLending) Size

func (elm *DiamondSystemLending) Size() uint32

type Lockbls

type Lockbls struct {
	MasterAddress       fields.Address     // Main address (claim)
	EffectBlockHeight   fields.BlockHeight // Effective (start) block
	LinearBlockNumber   fields.VarUint3    // Number of stepping blocks < 17000000 about 160 years
	TotalLockAmount     fields.Amount      // Total deposit limit
	LinearReleaseAmount fields.Amount      // Limit released each time
	BalanceAmount       fields.Amount      // Effective balance (any amount within the available limit can be withdrawn each time)
}

func NewEmptyLockbls

func NewEmptyLockbls(addr fields.Address) *Lockbls

func (*Lockbls) Parse

func (this *Lockbls) Parse(buf []byte, seek uint32) (uint32, error)

func (*Lockbls) Serialize

func (this *Lockbls) Serialize() ([]byte, error)

func (*Lockbls) Size

func (this *Lockbls) Size() uint32

type SatoshiGenesis

type SatoshiGenesis struct {
	TransferNo               fields.VarUint4         // Transfer serial number
	BitcoinBlockHeight       fields.VarUint4         // Height of bitcoin block transferred
	BitcoinBlockTimestamp    fields.BlockTxTimestamp // Bitcoin block timestamp of transfer
	BitcoinEffectiveGenesis  fields.VarUint4         // The number of bitcoins successfully transferred before this
	BitcoinQuantity          fields.VarUint4         // Number of bitcoins transferred in this transaction (unit: piece)
	AdditionalTotalHacAmount fields.VarUint4         // 本次转账[总共]应该增发的 hac 数量 (单位:枚)
	OriginAddress            fields.Address          // Bitcoin source address transferred out
	BitcoinTransferHash      fields.Hash             // Bitcoin transfer transaction hash
}

func SatoshiGenesisPageParse

func SatoshiGenesisPageParse(buf []byte, seek uint32) []*SatoshiGenesis

func SatoshiGenesisPageParseForShow

func SatoshiGenesisPageParseForShow(logitemstrlist []string) []*SatoshiGenesis

func (*SatoshiGenesis) Parse

func (s *SatoshiGenesis) Parse(buf []byte, seek uint32) (uint32, error)

func (*SatoshiGenesis) Serialize

func (s *SatoshiGenesis) Serialize() ([]byte, error)

func (*SatoshiGenesis) Size

func (s *SatoshiGenesis) Size() uint32

type TotalSupply

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

func NewTotalSupplyStoreData

func NewTotalSupplyStoreData() *TotalSupply

func (*TotalSupply) Clone

func (t *TotalSupply) Clone() *TotalSupply

Copy replication

func (*TotalSupply) CoverCopySave

func (t *TotalSupply) CoverCopySave(src *TotalSupply)

Overwrite save

func (*TotalSupply) DoAdd

func (t *TotalSupply) DoAdd(ty uint8, value float64) float64

func (*TotalSupply) DoAddUint

func (t *TotalSupply) DoAddUint(ty uint8, value uint64) uint64

func (*TotalSupply) DoSub

func (t *TotalSupply) DoSub(ty uint8, value float64) float64

func (*TotalSupply) DoSubUint

func (t *TotalSupply) DoSubUint(ty uint8, value uint64) uint64

func (*TotalSupply) Get

func (t *TotalSupply) Get(ty uint8) float64

func (*TotalSupply) GetUint

func (t *TotalSupply) GetUint(ty uint8) uint64

func (*TotalSupply) Parse

func (t *TotalSupply) Parse(buf []byte, seek uint32) (uint32, error)

Deserialization

func (*TotalSupply) Serialize

func (t *TotalSupply) Serialize() ([]byte, error)

serialize

func (*TotalSupply) Set

func (t *TotalSupply) Set(ty uint8, value float64)

func (*TotalSupply) SetUint

func (t *TotalSupply) SetUint(ty uint8, value uint64)

set up

type UserLending

type UserLending struct {
	IsRansomed           fields.Bool // Whether it has been redeemed (redeemed)
	IsRedemptionOvertime fields.Bool // Whether it can be redeemed after expiration (automatic extension)
	IsPublicRedeemable   fields.Bool // Public redeemable after maturity

	CreateBlockHeight fields.BlockHeight // 借贷开启时的区块高度
	ExpireBlockHeight fields.BlockHeight // Agreed expiration block height

	MortgagorAddress fields.Address // Address of mortgagor
	LenderAddress    fields.Address // Lender address

	MortgageBitcoin     fields.SatoshiVariation     // Mortgage bitcoin quantity unit: SAT
	MortgageDiamondList fields.DiamondListMaxLen200 // Mortgage diamond table

	LoanTotalAmount        fields.Amount // The total lending HAC quantity must be less than or equal to the lendable quantity
	AgreedRedemptionAmount fields.Amount // Agreed redemption amount

	PreBurningInterestAmount fields.Amount // Interest for pre destruction must be greater than or equal to 1% of the lending amount

	// Write data if redeemed
	RansomBlockHeight fields.BlockHeight // Block height at redemption
	RansomAmount      fields.Amount      // Redemption amount
	RansomAddress     fields.Address     // Address of the Redeemer
}

func (*UserLending) DropRansomedStatus

func (elm *UserLending) DropRansomedStatus() error

Remove redemption status

func (*UserLending) Parse

func (elm *UserLending) Parse(buf []byte, seek uint32) (uint32, error)

func (*UserLending) Serialize

func (elm *UserLending) Serialize() ([]byte, error)

func (*UserLending) SetRansomedStatus

func (elm *UserLending) SetRansomedStatus(height uint64, amount *fields.Amount, address fields.Address) error

func (*UserLending) Size

func (elm *UserLending) Size() uint32

Jump to

Keyboard shortcuts

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