Documentation ¶
Overview ¶
TODO(DELETEME): This entire file is replaced by remote_miner.go. We should delete all of this code and use remote_miner in all the places where we currently use the miner. The reason we don't do this now is it would break a lot of test cases that we have.
Index ¶
- Constants
- Variables
- func Add(a *big.Float, b *big.Float) *big.Float
- func Base58CheckDecode(input string) (_result []byte, _prefix []byte, _err error)
- func Base58CheckDecodePrefix(input string, prefixLen int) (_result []byte, _prefix []byte, _err error)
- func Base58CheckEncode(input []byte, isPrivate bool, params *BitCloutParams) string
- func Base58CheckEncodeWithPrefix(input []byte, prefix [3]byte) string
- func BigFloatExp(z *big.Float) *big.Float
- func BigFloatExpMulti(hi, lo *big.Float, k int64) *big.Float
- func BigFloatLog(x *big.Float) *big.Float
- func BigFloatLog2(x *big.Float) *big.Float
- func BigFloatPow(z *big.Float, w *big.Float) *big.Float
- func BigintToBytes(bigint *big.Int) []byte
- func BitcoinTxnToString(txn *wire.MsgTx) string
- func BlockCypherCheckBitcoinDoubleSpend(txnHash *chainhash.Hash, blockCypherAPIKey string, params *BitCloutParams) (_isDoubleSpend bool, _err error)
- func BlockCypherPushAndWaitForTxn(txnHex string, txnHash *chainhash.Hash, blockCypherAPIKey string, ...) error
- func BlockCypherPushTransaction(txnHex string, txnHash *chainhash.Hash, blockCypherAPIKey string, ...) (_added bool, _err error)
- func BlockHashToBlockKey(blockHash *BlockHash) []byte
- func BlockonomicsCheckRBF(bitcoinTxnHash string) (_hasRBF bool, _err error)
- func BlocksPerDuration(duration time.Duration, timeBetweenBlocks time.Duration) uint32
- func BytesToBigint(bb []byte) *big.Int
- func CalcBlockRewardNanos(blockHeight uint32) uint64
- func CalcNanosToCreate(startNanos uint64, satoshisToBurn uint64, ...) (_nanosToCreate uint64)
- func CalculateBitCloutToReturn(deltaCreatorCoinNanos uint64, currentCreatorCoinSupplyNanos uint64, ...) uint64
- func CalculateCreatorCoinToMint(bitcloutToSellNanos uint64, coinsInCirculationNanos uint64, ...) uint64
- func CalculateCreatorCoinToMintBancor(deltaBitCloutNanos uint64, currentCreatorCoinSupplyNanos uint64, ...) uint64
- func CalculateCreatorCoinToMintPolynomial(deltaBitCloutNanos uint64, currentCreatorCoinSupplyNanos uint64, ...) uint64
- func CheckTransactionSanity(txn *MsgBitCloutTxn) error
- func ComputeKeysFromSeed(seedBytes []byte, index uint32, params *BitCloutParams) (_pubKey *btcec.PublicKey, _privKey *btcec.PrivateKey, _btcAddress string, ...)
- func ComputeKeysFromSeedWithNet(seedBytes []byte, index uint32, isTestnet bool) (_pubKey *btcec.PublicKey, _privKey *btcec.PrivateKey, _btcAddress string, ...)
- func ComputeMerkleRoot(txns []*MsgBitCloutTxn) (_merkle *BlockHash, _txHashes []*BlockHash, _err error)
- func CreateBitcoinSpendTransaction(spendAmountSatoshis uint64, feeRateSatoshisPerKB uint64, ...) (_txn *wire.MsgTx, _totalInput uint64, _fee uint64, _unsignedHashes []string, ...)
- func CreateUnsignedBitcoinSpendTransaction(spendAmountSatoshis uint64, feeRateSatoshisPerKB uint64, ...) (_txn *wire.MsgTx, _totalInput uint64, _fee uint64, _err error)
- func DBDeleteAcceptedNFTBidEntriesMappingsWithTxn(txn *badger.Txn, nftPostHash *BlockHash, serialNumber uint64) error
- func DBDeleteAcceptedNFTBidMappings(handle *badger.DB, postHash *BlockHash, serialNumber uint64) error
- func DBDeleteCreatorCoinBalanceEntryMappings(handle *badger.DB, hodlerPKID *PKID, creatorPKID *PKID, params *BitCloutParams) error
- func DBDeleteCreatorCoinBalanceEntryMappingsWithTxn(txn *badger.Txn, hodlerPKID *PKID, creatorPKID *PKID, params *BitCloutParams) error
- func DBDeleteNFTBidMappings(handle *badger.DB, nftBidKey *NFTBidKey) error
- func DBDeleteNFTBidMappingsWithTxn(txn *badger.Txn, nftBidKey *NFTBidKey) error
- func DBDeleteNFTMappings(handle *badger.DB, postHash *BlockHash, serialNumber uint64) error
- func DBDeleteNFTMappingsWithTxn(txn *badger.Txn, nftPostHash *BlockHash, serialNumber uint64) error
- func DBDeletePKIDMappingsWithTxn(txn *badger.Txn, publicKey []byte, params *BitCloutParams) error
- func DBDeletePostEntryMappings(handle *badger.DB, postHash *BlockHash, params *BitCloutParams) error
- func DBDeletePostEntryMappingsWithTxn(txn *badger.Txn, postHash *BlockHash, params *BitCloutParams) error
- func DBDeleteProfileEntryMappings(handle *badger.DB, pkid *PKID, params *BitCloutParams) error
- func DBDeleteProfileEntryMappingsWithTxn(txn *badger.Txn, pkid *PKID, params *BitCloutParams) error
- func DBGetAcceptedNFTBidEntriesByPostHashSerialNumber(db *badger.DB, postHash *BlockHash, serialNumber uint64) *[]*NFTBidEntry
- func DBGetAcceptedNFTBidEntriesByPostHashSerialNumberWithTxn(txn *badger.Txn, postHash *BlockHash, serialNumber uint64) *[]*NFTBidEntry
- func DBGetAllPostsAndCommentsForPublicKeyOrderedByTimestamp(handle *badger.DB, publicKey []byte, fetchEntries bool, ...) (_tstamps []uint64, _postAndCommentHashes []*BlockHash, ...)
- func DBGetAllPostsByTstamp(handle *badger.DB, fetchEntries bool) (_tstamps []uint64, _postHashes []*BlockHash, _postEntries []*PostEntry, ...)
- func DBGetAllProfilesByCoinValue(handle *badger.DB, fetchEntries bool) (_lockedBitCloutNanos []uint64, _profilePublicKeys []*PKID, ...)
- func DBGetCommentPostHashesForParentStakeID(handle *badger.DB, stakeIDXXX []byte, fetchEntries bool) (_tstamps []uint64, _commentPostHashes []*BlockHash, ...)
- func DBGetPaginatedKeysAndValuesForPrefix(db *badger.DB, startPrefix []byte, validForPrefix []byte, keyLen int, ...) (_keysFound [][]byte, _valsFound [][]byte, _err error)
- func DBGetPaginatedKeysAndValuesForPrefixWithTxn(dbTxn *badger.Txn, startPrefix []byte, validForPrefix []byte, maxKeyLen int, ...) (_keysFound [][]byte, _valsFound [][]byte, _err error)
- func DBGetPaginatedPostsOrderedByTime(db *badger.DB, startPostTimestampNanos uint64, startPostHash *BlockHash, ...) (_postHashes []*BlockHash, _tstampNanos []uint64, _postEntries []*PostEntry, ...)
- func DBGetPublicKeyForPKID(db *badger.DB, pkidd *PKID) []byte
- func DBGetPublicKeyForPKIDWithTxn(txn *badger.Txn, pkidd *PKID) []byte
- func DBPutAcceptedNFTBidEntriesMapping(handle *badger.DB, nftKey NFTKey, nftBidEntries *[]*NFTBidEntry) error
- func DBPutAcceptedNFTBidEntriesMappingWithTxn(txn *badger.Txn, nftKey NFTKey, nftBidEntries *[]*NFTBidEntry) error
- func DBPutCreatorCoinBalanceEntryMappings(handle *badger.DB, balanceEntry *BalanceEntry, params *BitCloutParams) error
- func DBPutCreatorCoinBalanceEntryMappingsWithTxn(txn *badger.Txn, balanceEntry *BalanceEntry, params *BitCloutParams) error
- func DBPutNFTBidEntryMappings(handle *badger.DB, nftEntry *NFTBidEntry) error
- func DBPutNFTBidEntryMappingsWithTxn(txn *badger.Txn, nftBidEntry *NFTBidEntry) error
- func DBPutNFTEntryMappings(handle *badger.DB, nftEntry *NFTEntry) error
- func DBPutNFTEntryMappingsWithTxn(txn *badger.Txn, nftEntry *NFTEntry) error
- func DBPutPKIDMappingsWithTxn(txn *badger.Txn, publicKey []byte, pkidEntry *PKIDEntry, ...) error
- func DBPutPostEntryMappings(handle *badger.DB, postEntry *PostEntry, params *BitCloutParams) error
- func DBPutPostEntryMappingsWithTxn(txn *badger.Txn, postEntry *PostEntry, params *BitCloutParams) error
- func DBPutProfileEntryMappings(handle *badger.DB, profileEntry *ProfileEntry, pkid *PKID, ...) error
- func DBPutProfileEntryMappingsWithTxn(txn *badger.Txn, profileEntry *ProfileEntry, pkid *PKID, ...) error
- func DbBufForUtxoKey(utxoKey *UtxoKey) []byte
- func DbBulkDeleteHeightHashToNodeInfo(nodes []*BlockNode, handle *badger.DB, bitcoinNodes bool) error
- func DbDeleteAllMempoolTxns(handle *badger.DB) error
- func DbDeleteAllMempoolTxnsWithTxn(txn *badger.Txn) error
- func DbDeleteBitcoinBurnTxIDWithTxn(txn *badger.Txn, bitcoinBurnTxID *BlockHash) error
- func DbDeleteDiamondMappings(handle *badger.DB, diamondEntry *DiamondEntry) error
- func DbDeleteDiamondMappingsWithTxn(txn *badger.Txn, diamondEntry *DiamondEntry) error
- func DbDeleteFollowMappings(handle *badger.DB, followerPKID *PKID, followedPKID *PKID) error
- func DbDeleteFollowMappingsWithTxn(txn *badger.Txn, followerPKID *PKID, followedPKID *PKID) error
- func DbDeleteForbiddenBlockSignaturePubKey(handle *badger.DB, publicKey []byte) error
- func DbDeleteForbiddenBlockSignaturePubKeyWithTxn(txn *badger.Txn, publicKey []byte) error
- func DbDeleteHeightHashToNodeInfoWithTxn(node *BlockNode, txn *badger.Txn, bitcoinNodes bool) error
- func DbDeleteLikeMappings(handle *badger.DB, userPubKey []byte, likedPostHash BlockHash) error
- func DbDeleteLikeMappingsWithTxn(txn *badger.Txn, userPubKey []byte, likedPostHash BlockHash) error
- func DbDeleteMempoolTxn(handle *badger.DB, mempoolTx *MempoolTx) error
- func DbDeleteMempoolTxnKey(handle *badger.DB, txnKey []byte) error
- func DbDeleteMempoolTxnKeyWithTxn(txn *badger.Txn, txnKey []byte) error
- func DbDeleteMempoolTxnWithTxn(txn *badger.Txn, mempoolTx *MempoolTx) error
- func DbDeleteMessageEntryMappings(handle *badger.DB, publicKey []byte, tstampNanos uint64) error
- func DbDeleteMessageEntryMappingsWithTxn(txn *badger.Txn, publicKey []byte, tstampNanos uint64) error
- func DbDeletePublicKeyToBitcloutBalance(handle *badger.DB, publicKey []byte) error
- func DbDeletePublicKeyToBitcloutBalanceWithTxn(txn *badger.Txn, publicKey []byte) error
- func DbDeleteRecloutMappings(handle *badger.DB, userPubKey []byte, recloutedPostHash BlockHash) error
- func DbDeleteRecloutMappingsWithTxn(txn *badger.Txn, userPubKey []byte, recloutedPostHash BlockHash) error
- func DbDeleteTxindexNextIndexForPublicKeyWithTxn(txn *badger.Txn, publicKey []byte) error
- func DbDeleteTxindexPublicKeyToTxnMappingSingleWithTxn(dbTxn *badger.Txn, publicKey []byte, txID *BlockHash) error
- func DbDeleteTxindexTransactionMappings(handle *badger.DB, txn *MsgBitCloutTxn, params *BitCloutParams) error
- func DbDeleteTxindexTransactionMappingsWithTxn(dbTxn *badger.Txn, txn *MsgBitCloutTxn, params *BitCloutParams) error
- func DbExistsBitcoinBurnTxID(db *badger.DB, bitcoinBurnTxID *BlockHash) bool
- func DbExistsBitcoinBurnTxIDWithTxn(txn *badger.Txn, bitcoinBurnTxID *BlockHash) bool
- func DbGetBalanceEntriesHodlingYou(pkid *PKIDEntry, fetchProfiles bool, filterOutZeroBalances bool, ...) (_entriesHodlingYou []*BalanceEntry, _profilesHodlingYou []*ProfileEntry, ...)
- func DbGetBalanceEntriesYouHodl(pkid *PKIDEntry, fetchProfiles bool, filterOutZeroBalances bool, ...) (_entriesYouHodl []*BalanceEntry, _profilesYouHodl []*ProfileEntry, _err error)
- func DbGetBitcloutBalanceNanosForPublicKey(db *badger.DB, publicKey []byte) (_balance uint64, _err error)
- func DbGetBitcloutBalanceNanosForPublicKeyWithTxn(txn *badger.Txn, publicKey []byte) (_balance uint64, _err error)
- func DbGetBlockRewardForPublicKeyBlockHash(db *badger.DB, publicKey []byte, blockHash *BlockHash) (_balance uint64, _err error)
- func DbGetBlockRewardForPublicKeyBlockHashWithTxn(txn *badger.Txn, publicKey []byte, blockHash *BlockHash) (_balance uint64, _err error)
- func DbGetCreatorCoinBalanceEntriesForPubKey(pkid *PKIDEntry, fetchProfiles bool, filterOutZeroBalances bool, ...) (_entriesYouHodl []*BalanceEntry, _entriesThatHodlYou []*BalanceEntry, ...)
- func DbGetFollowerToFollowedMapping(db *badger.DB, followerPKID *PKID, followedPKID *PKID) []byte
- func DbGetFollowerToFollowedMappingWithTxn(txn *badger.Txn, followerPKID *PKID, followedPKID *PKID) []byte
- func DbGetForbiddenBlockSignaturePubKey(db *badger.DB, publicKey []byte) []byte
- func DbGetForbiddenBlockSignaturePubKeyWithTxn(txn *badger.Txn, publicKey []byte) []byte
- func DbGetLikerPubKeyToLikedPostHashMapping(db *badger.DB, userPubKey []byte, likedPostHash BlockHash) []byte
- func DbGetLikerPubKeyToLikedPostHashMappingWithTxn(txn *badger.Txn, userPubKey []byte, likedPostHash BlockHash) []byte
- func DbGetLikerPubKeysLikingAPostHash(handle *badger.DB, likedPostHash BlockHash) (_pubKeys [][]byte, _err error)
- func DbGetNanosPurchased(handle *badger.DB) uint64
- func DbGetNanosPurchasedWithTxn(txn *badger.Txn) uint64
- func DbGetPKIDsThatDiamondedYouMap(handle *badger.DB, yourPKID *PKID, fetchYouDiamonded bool) (_pkidToDiamondsMap map[PKID][]*DiamondEntry, _err error)
- func DbGetPubKeysFollowingYou(handle *badger.DB, yourPubKey []byte) (_pubKeys [][]byte, _err error)
- func DbGetPubKeysYouFollow(handle *badger.DB, yourPubKey []byte) (_pubKeys [][]byte, _err error)
- func DbGetTxindexFullTransactionByTxID(txindexDBHandle *badger.DB, blockchainDBHandle *badger.DB, txID *BlockHash) (_txn *MsgBitCloutTxn, _txnMeta *TransactionMetadata)
- func DbGetTxindexNextIndexForPublicKey(handle *badger.DB, publicKey []byte) *uint64
- func DbGetUSDCentsPerBitcoinExchangeRate(handle *badger.DB) uint64
- func DbGetUSDCentsPerBitcoinExchangeRateWithTxn(txn *badger.Txn) uint64
- func DbPutBitcloutBalanceForPublicKey(handle *badger.DB, publicKey []byte, balanceNanos uint64) error
- func DbPutBitcloutBalanceForPublicKeyWithTxn(txn *badger.Txn, publicKey []byte, balanceNanos uint64) error
- func DbPutBitcoinBurnTxIDWithTxn(txn *badger.Txn, bitcoinBurnTxID *BlockHash) error
- func DbPutDiamondMappings(handle *badger.DB, diamondEntry *DiamondEntry) error
- func DbPutDiamondMappingsWithTxn(txn *badger.Txn, diamondEntry *DiamondEntry) error
- func DbPutFollowMappings(handle *badger.DB, followerPKID *PKID, followedPKID *PKID) error
- func DbPutFollowMappingsWithTxn(txn *badger.Txn, followerPKID *PKID, followedPKID *PKID) error
- func DbPutForbiddenBlockSignaturePubKey(handle *badger.DB, publicKey []byte) error
- func DbPutForbiddenBlockSignaturePubKeyWithTxn(txn *badger.Txn, publicKey []byte) error
- func DbPutGlobalParamsEntry(handle *badger.DB, globalParamsEntry GlobalParamsEntry) error
- func DbPutGlobalParamsEntryWithTxn(txn *badger.Txn, globalParamsEntry GlobalParamsEntry) error
- func DbPutLikeMappings(handle *badger.DB, userPubKey []byte, likedPostHash BlockHash) error
- func DbPutLikeMappingsWithTxn(txn *badger.Txn, userPubKey []byte, likedPostHash BlockHash) error
- func DbPutMempoolTxn(handle *badger.DB, mempoolTx *MempoolTx) error
- func DbPutMempoolTxnWithTxn(txn *badger.Txn, mempoolTx *MempoolTx) error
- func DbPutMessageEntry(handle *badger.DB, messageEntry *MessageEntry) error
- func DbPutMessageEntryWithTxn(txn *badger.Txn, messageEntry *MessageEntry) error
- func DbPutNanosPurchased(handle *badger.DB, nanosPurchased uint64) error
- func DbPutNanosPurchasedWithTxn(txn *badger.Txn, nanosPurchased uint64) error
- func DbPutRecloutMappings(handle *badger.DB, userPubKey []byte, recloutedPostHash BlockHash, ...) error
- func DbPutRecloutMappingsWithTxn(txn *badger.Txn, userPubKey []byte, recloutedPostHash BlockHash, ...) error
- func DbPutTxindexNextIndexForPublicKeyWithTxn(txn *badger.Txn, publicKey []byte, nextIndex uint64) error
- func DbPutTxindexPublicKeyToTxnMappingSingleWithTxn(dbTxn *badger.Txn, publicKey []byte, txID *BlockHash) error
- func DbPutTxindexTip(handle *badger.DB, tipHash *BlockHash) error
- func DbPutTxindexTipWithTxn(dbTxn *badger.Txn, tipHash *BlockHash) error
- func DbPutTxindexTransaction(handle *badger.DB, txID *BlockHash, txnMeta *TransactionMetadata) error
- func DbPutTxindexTransactionMappings(handle *badger.DB, bitcloutTxn *MsgBitCloutTxn, params *BitCloutParams, ...) error
- func DbPutTxindexTransactionMappingsWithTxn(dbTx *badger.Txn, txn *MsgBitCloutTxn, params *BitCloutParams, ...) error
- func DbPutTxindexTransactionWithTxn(txn *badger.Txn, txID *BlockHash, txnMeta *TransactionMetadata) error
- func DbPutUSDCentsPerBitcoinExchangeRateWithTxn(txn *badger.Txn, usdCentsPerBitcoinExchangeRate uint64) error
- func DbTxindexPublicKeyIndexToTxnKey(publicKey []byte, index uint32) []byte
- func DbTxindexPublicKeyPrefix(publicKey []byte) []byte
- func DbTxindexTxIDKey(txID *BlockHash) []byte
- func DecodeUint32(num []byte) uint32
- func DecodeUint64(scoreBytes []byte) uint64
- func DecryptBytesWithPrivateKey(bytesToDecrypt []byte, privKey *ecdsa.PrivateKey) ([]byte, error)
- func DeletePubKeyUtxoKeyMappingWithTxn(txn *badger.Txn, publicKey []byte, utxoKey *UtxoKey) error
- func DeleteUnmodifiedMappingsForUtxoWithTxn(txn *badger.Txn, utxoKey *UtxoKey) error
- func DeleteUtxoEntryForKeyWithTxn(txn *badger.Txn, utxoKey *UtxoKey) error
- func DeleteUtxoOperationsForBlockWithTxn(txn *badger.Txn, blockHash *BlockHash) error
- func Diff(expected interface{}, actual interface{}) string
- func Div(a *big.Float, b *big.Float) *big.Float
- func EncodeUint64(num uint64) []byte
- func EncryptBytesWithPublicKey(bytesToEncrypt []byte, pubkey *ecdsa.PublicKey) ([]byte, error)
- func EnumerateKeysForPrefix(db *badger.DB, dbPrefix []byte) (_keysFound [][]byte, _valsFound [][]byte)
- func EstimateBitcoinTxFee(numInputs int, numOutputs int, feeRateSatoshisPerKB uint64) uint64
- func ExtractBitcoinBurnTransactionsFromBitcoinBlock(bitcoinBlock *wire.MsgBlock, bitcoinBurnAddress string, params *BitCloutParams) []*wire.MsgTx
- func ExtractBitcoinBurnTransactionsFromBitcoinBlockWithMerkleProofs(bitcoinBlock *wire.MsgBlock, burnAddress string, params *BitCloutParams) (_txns []*wire.MsgTx, _merkleProofs [][]*merkletree.ProofPart, _err error)
- func ExtractBitcoinPublicKeyFromBitcoinTransactionInputs(bitcoinTransaction *wire.MsgTx, btcdParams *chaincfg.Params) (_publicKey *btcec.PublicKey, _err error)
- func FlushMempoolToDb(handle *badger.DB, allTxns []*MempoolTx) error
- func FlushMempoolToDbWithTxn(txn *badger.Txn, allTxns []*MempoolTx) error
- func GetBadgerDbPath(dataDir string) string
- func GetBitCloutNanosDiamondLevelMapAtBlockHeight(blockHeight int64) map[int64]uint64
- func GetBitCloutNanosForDiamondLevelAtBlockHeight(diamondLevel int64, blockHeight int64) uint64
- func GetBlockIndex(handle *badger.DB, bitcoinNodes bool) (map[BlockHash]*BlockNode, error)
- func GetCreatorCoinNanosForDiamondLevelAtBlockHeight(coinsInCirculationNanos uint64, bitcloutLockedNanos uint64, diamondLevel int64, ...) uint64
- func GetDataDir(params *BitCloutParams) string
- func GetReorgBlocks(tip *BlockNode, newNode *BlockNode) (_commonAncestor *BlockNode, _detachNodes []*BlockNode, ...)
- func GetSatoshisPerUnitExchangeRate(startNanos uint64, usdCentsPerBitcoinExchangeRate uint64) uint64
- func GetStartPriceSatoshisPerBitClout(usdCentsPerBitcoinExchangeRate uint64) uint64
- func GetUtxoNumEntries(handle *badger.DB) uint64
- func GetUtxoNumEntriesWithTxn(txn *badger.Txn) uint64
- func GetUtxoOperationsForBlock(handle *badger.DB, blockHash *BlockHash) ([][]*UtxoOperation, error)
- func GetUtxoOperationsForBlockWithTxn(txn *badger.Txn, blockHash *BlockHash) ([][]*UtxoOperation, error)
- func HashToBigint(hash *BlockHash) *big.Int
- func HashToStakeID(hash *BlockHash) []byte
- func HeaderSizeBytes() int
- func IPToNetAddr(ipStr string, addrMgr *addrmgr.AddrManager, params *BitCloutParams) (*wire.NetAddress, error)
- func InitDbWithBitCloutGenesisBlock(params *BitCloutParams, handle *badger.DB) error
- func InitializeSecureMiddleware(allowedHosts []string, isDevelopment bool, contentSecurityPolicy string) *secure.Secure
- func IntAdd(a *big.Int, b *big.Int) *big.Int
- func IntDiv(a *big.Int, b *big.Int) *big.Int
- func IntMul(a *big.Int, b *big.Int) *big.Int
- func IntSub(a *big.Int, b *big.Int) *big.Int
- func IntToBuf(xx int64) []byte
- func IsBitcoinTestnet(params *BitCloutParams) bool
- func IsControlMessage(msgType MsgType) bool
- func IsForgivenBitcoinTransaction(txn *MsgBitCloutTxn) bool
- func IsNukedBitcoinTransaction(txn *MsgBitCloutTxn) bool
- func IsQuotedReclout(postEntry *PostEntry) bool
- func IsRestrictedPubKey(userGraylistState []byte, userBlacklistState []byte, moderationType string) bool
- func IsRuleError(err error) bool
- func IsUnminedBitcoinExchange(txnMeta *BitcoinExchangeMetadata) bool
- func IsVanillaReclout(postEntry *PostEntry) bool
- func LessThan(aa *BlockHash, bb *BlockHash) bool
- func LogDBSummarySnapshot(db *badger.DB)
- func MakeDirIfNonExistent(filePath string) error
- func MinInt(a, b int) int
- func MinUint32(a, b uint32) uint32
- func Mul(a *big.Float, b *big.Float) *big.Float
- func MustBase58CheckDecode(input string) []byte
- func NewFloat() *big.Float
- func PKIDToPublicKey(pkid *PKID) []byte
- func PPrintJSON(xx interface{})
- func PkToString(pk []byte, params *BitCloutParams) string
- func PkToStringBoth(pk []byte) string
- func PkToStringMainnet(pk []byte) string
- func PkToStringTestnet(pk []byte) string
- func PrivToString(priv []byte, params *BitCloutParams) string
- func PublicKeyBlockHashToBlockRewardKey(publicKey []byte, blockHash *BlockHash) []byte
- func PutBestHash(bh *BlockHash, handle *badger.DB, chainType ChainType) error
- func PutBestHashWithTxn(txn *badger.Txn, bh *BlockHash, chainType ChainType) error
- func PutBlock(bitcloutBlock *MsgBitCloutBlock, handle *badger.DB) error
- func PutBlockWithTxn(txn *badger.Txn, bitcloutBlock *MsgBitCloutBlock) error
- func PutHeightHashToNodeInfo(node *BlockNode, handle *badger.DB, bitcoinNodes bool) error
- func PutHeightHashToNodeInfoWithTxn(txn *badger.Txn, node *BlockNode, bitcoinNodes bool) error
- func PutMappingsForUtxoWithTxn(txn *badger.Txn, utxoKey *UtxoKey, utxoEntry *UtxoEntry) error
- func PutPubKeyUtxoKeyWithTxn(txn *badger.Txn, publicKey []byte, utxoKey *UtxoKey) error
- func PutUtxoEntryForUtxoKeyWithTxn(txn *badger.Txn, utxoKey *UtxoKey, utxoEntry *UtxoEntry) error
- func PutUtxoNumEntriesWithTxn(txn *badger.Txn, newNumEntries uint64) error
- func PutUtxoOperationsForBlockWithTxn(txn *badger.Txn, blockHash *BlockHash, utxoOpsForBlock [][]*UtxoOperation) error
- func PutUvarint(buf []byte, x uint64) int
- func PutVarint(buf []byte, x int64) int
- func RandInt32(max int32) int32
- func RandInt64(max int64) int64
- func RandomBytes(numBytes int32) []byte
- func RandomBytesHex(numBytes int32) string
- func ReadUvarint(r io.Reader) (uint64, error)
- func ReadVarString(rr io.Reader) ([]byte, error)
- func ReadVarint(r io.Reader) (int64, error)
- func SerializeBlockNode(blockNode *BlockNode) ([]byte, error)
- func StartDBSummarySnapshots(db *badger.DB)
- func Sub(a *big.Float, b *big.Float) *big.Float
- func UintToBuf(xx uint64) []byte
- func Uvarint(buf []byte) (uint64, int)
- func Varint(buf []byte) (int64, int)
- func WriteMessage(ww io.Writer, msg BitCloutMessage, networkType NetworkType) ([]byte, error)
- type AcceptNFTBidMetadata
- type AcceptNFTBidTxindexMetadata
- type AffectedPublicKey
- type BalanceEntry
- func DBGetCreatorCoinBalanceEntryForCreatorPKIDAndHODLerPubKeyWithTxn(txn *badger.Txn, creatorPKID *PKID, hodlerPKID *PKID) *BalanceEntry
- func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDs(handle *badger.DB, hodlerPKID *PKID, creatorPKID *PKID) *BalanceEntry
- func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDsWithTxn(txn *badger.Txn, hodlerPKID *PKID, creatorPKID *PKID) *BalanceEntry
- func DbGetBalanceEntry(db *badger.DB, holder *PKID, creator *PKID) *BalanceEntry
- func DbGetHolderPKIDCreatorPKIDToBalanceEntryWithTxn(txn *badger.Txn, holder *PKID, creator *PKID) *BalanceEntry
- func GetSingleBalanceEntryFromPublicKeys(holder []byte, creator []byte, utxoView *UtxoView) (*BalanceEntry, error)
- type BalanceEntryMapKey
- type BasicTransferMetadata
- type BasicTransferTxindexMetadata
- type BitCloutBlockProducer
- func (bitcloutBlockProducer *BitCloutBlockProducer) AddBlockTemplate(block *MsgBitCloutBlock, diffTarget *BlockHash)
- func (bitcloutBlockProducer *BitCloutBlockProducer) GetCopyOfRecentBlock(blockID string) (*MsgBitCloutBlock, error)
- func (blockProducer *BitCloutBlockProducer) GetHeadersAndExtraDatas(publicKeyBytes []byte, numHeaders int64, headerVersion uint32) (_blockID string, _headers [][]byte, _extraNonces []uint64, ...)
- func (bbp *BitCloutBlockProducer) GetLatestBlockTemplateStats() *BlockTemplateStats
- func (bitcloutBlockProducer *BitCloutBlockProducer) GetRecentBlock(blockHash *BlockHash) *MsgBitCloutBlock
- func (bitcloutBlockProducer *BitCloutBlockProducer) SignBlock(blockFound *MsgBitCloutBlock) error
- func (bitcloutBlockProducer *BitCloutBlockProducer) Start()
- func (bitcloutBlockProducer *BitCloutBlockProducer) Stop()
- func (bitcloutBlockProducer *BitCloutBlockProducer) UpdateLatestBlockTemplate() error
- type BitCloutBodySchema
- type BitCloutInput
- type BitCloutMempool
- func (mp *BitCloutMempool) BlockUntilReadOnlyViewRegenerated()
- func (mp *BitCloutMempool) CheckSpend(op UtxoKey) *MsgBitCloutTxn
- func (mp *BitCloutMempool) Count() int
- func (mp *BitCloutMempool) DumpTxnsToDB()
- func (mp *BitCloutMempool) EvictUnminedBitcoinTransactions(bitcoinTxnHashes []string, dryRun bool) (int64, map[string]int64, []string, []string)
- func (mp *BitCloutMempool) FetchTransaction(txHash *BlockHash) *MempoolTx
- func (mp *BitCloutMempool) GetAugmentedUniversalView() (*UtxoView, error)
- func (mp *BitCloutMempool) GetAugmentedUtxoViewForPublicKey(pkBytes []byte, optionalTxn *MsgBitCloutTxn) (*UtxoView, error)
- func (mp *BitCloutMempool) GetMempoolSummaryStats() (_summaryStatsMap map[string]*SummaryStats)
- func (mp *BitCloutMempool) GetTransaction(txId *BlockHash) (txn *MempoolTx)
- func (mp *BitCloutMempool) GetTransactionsOrderedByTimeAdded() (_poolTxns []*MempoolTx, _unconnectedTxns []*UnconnectedTx, _err error)
- func (mp *BitCloutMempool) InefficientRemoveTransaction(tx *MsgBitCloutTxn)
- func (mp *BitCloutMempool) IsTransactionInPool(hash *BlockHash) bool
- func (mp *BitCloutMempool) LoadTxnsFromDB()
- func (mp *BitCloutMempool) MempoolTxs() []*MempoolTx
- func (mp *BitCloutMempool) OpenTempDBAndDumpTxns() error
- func (mp *BitCloutMempool) ProcessTransaction(tx *MsgBitCloutTxn, allowUnconnectedTxn bool, rateLimit bool, peerID uint64, ...) ([]*MempoolTx, error)
- func (mp *BitCloutMempool) ProcessUnconnectedTransactions(acceptedTx *MsgBitCloutTxn, rateLimit bool, verifySignatures bool) []*MempoolTx
- func (mp *BitCloutMempool) PublicKeyTxnMap(publicKey []byte) (txnMap map[BlockHash]*MempoolTx)
- func (mp *BitCloutMempool) RegenerateReadOnlyView() error
- func (mp *BitCloutMempool) StartMempoolDBDumper()
- func (mp *BitCloutMempool) StartReadOnlyUtxoViewRegenerator()
- func (mp *BitCloutMempool) Stop()
- func (mp *BitCloutMempool) TryAcceptTransaction(tx *MsgBitCloutTxn, rateLimit bool, verifySignatures bool) ([]*BlockHash, *MempoolTx, error)
- func (mp *BitCloutMempool) TxHashes() []*BlockHash
- func (mp *BitCloutMempool) UpdateAfterConnectBlock(blk *MsgBitCloutBlock) (_txnsAddedToMempool []*MempoolTx)
- func (mp *BitCloutMempool) UpdateAfterDisconnectBlock(blk *MsgBitCloutBlock)
- type BitCloutMessage
- type BitCloutMessageMeta
- type BitCloutMiner
- type BitCloutOutput
- type BitCloutParams
- type BitCloutTxnMetadata
- type BitcoinExchangeMetadata
- type BitcoinExchangeTxindexMetadata
- type BitcoinManager
- func (bm *BitcoinManager) AddSeeds()
- func (bm *BitcoinManager) BroadcastTxn(txn *wire.MsgTx)
- func (bm *BitcoinManager) BroadcastTxnAndCheckAdded(txn *wire.MsgTx, timeoutSecs int) (_err error)
- func (bm *BitcoinManager) BroadcastTxnAndCheckAddedRedundant(txn *wire.MsgTx, timeoutSecs int, numNodesToPing int) (_err error)
- func (bm *BitcoinManager) FullyValidateHeaderAtIndex(index int) (_finished bool, _err error)
- func (bm *BitcoinManager) FullyValidateHeaders() error
- func (bm *BitcoinManager) GetAddrManager() *addrmgr.AddrManager
- func (bm *BitcoinManager) GetBitcoinBlockNode(hash *BlockHash) *BlockNode
- func (bm *BitcoinManager) GetBitcoinBurnWorkBlocks(blockHeight uint32) int64
- func (bm *BitcoinManager) HandleBitcoinHeaders(conn net.Conn, msg *wire.MsgHeaders) error
- func (bm *BitcoinManager) HeaderAtHeight(blockHeight uint32) *BlockNode
- func (bm *BitcoinManager) HeaderForHash(hash *BlockHash) *BlockNode
- func (bm *BitcoinManager) HeaderTip() *BlockNode
- func (bm *BitcoinManager) IsCurrent(considerCumWork bool) bool
- func (bm *BitcoinManager) MaybeRequestBitcoinBlock(conn net.Conn, hash chainhash.Hash)
- func (bm *BitcoinManager) ProcessBitcoinBlock(bitcoinBlock *wire.MsgBlock)
- func (bm *BitcoinManager) ProcessBitcoinHeaderFull(bitcoinHeader *wire.BlockHeader, params *BitCloutParams) (_isMainChain bool, _isOrphan bool, _err error)
- func (bm *BitcoinManager) ProcessBitcoinHeaderQuick(bitcoinHeader *wire.BlockHeader, params *BitCloutParams) (_isMainChain bool, _isOrphan bool, _err error)
- func (bm *BitcoinManager) RequestBitcoinBlock(blockHash chainhash.Hash)
- func (bm *BitcoinManager) RequestBitcoinTxn(txHash chainhash.Hash)
- func (bm *BitcoinManager) ResetBitcoinHeaderIndex() error
- func (bm *BitcoinManager) SendGetHeaders(conn net.Conn)
- func (bm *BitcoinManager) SetHeaderIndexAndBestChainListMap(bestChain []*BlockNode, headerIndex map[BlockHash]*BlockNode)
- func (bm *BitcoinManager) Start()
- func (bm *BitcoinManager) SyncConn() net.Conn
- type BitcoinUtxo
- func BlockCypherExtractBitcoinUtxosFromResponse(apiData *BlockCypherAPIFullAddressResponse, addrString string, ...) ([]*BitcoinUtxo, error)
- func BlockCypherUtxoSource(addrString string, params *BitCloutParams) ([]*BitcoinUtxo, error)
- func FrontendBlockCypherUtxoSource(apiData *BlockCypherAPIFullAddressResponse, addrString string, ...) ([]*BitcoinUtxo, error)
- type BlockCypherAPIFullAddressResponse
- type BlockCypherAPIInputResponse
- type BlockCypherAPIOutputResponse
- type BlockCypherAPITxnResponse
- type BlockHash
- func BigintToHash(bigint *big.Int) *BlockHash
- func CalcNextDifficultyTarget(lastNode *BlockNode, version uint32, params *BitCloutParams) (*BlockHash, error)
- func ComputeTransactionHashes(txns []*MsgBitCloutTxn) ([]*BlockHash, error)
- func CopyBytesIntoBlockHash(data []byte) *BlockHash
- func DbGetAllBitcoinBurnTxIDs(handle *badger.DB) (_bitcoinBurnTxIDs []*BlockHash)
- func DbGetBestHash(handle *badger.DB, chainType ChainType) *BlockHash
- func DbGetPostHashesYouLike(handle *badger.DB, yourPublicKey []byte) (_postHashes []*BlockHash, _err error)
- func DbGetPostHashesYouReclout(handle *badger.DB, yourPublicKey []byte) (_postHashes []*BlockHash, _err error)
- func DbGetTxindexTip(handle *badger.DB) *BlockHash
- func DbGetTxindexTxnsForPublicKey(handle *badger.DB, publicKey []byte) []*BlockHash
- func DbGetTxindexTxnsForPublicKeyWithTxn(dbTxn *badger.Txn, publicKey []byte) []*BlockHash
- func ExpectedWorkForBlockHash(hash *BlockHash) *BlockHash
- func FindLowestHash(blockHeaderr *MsgBitCloutHeader, iterations uint64) (lowestHash *BlockHash, lowestNonce uint64, ee error)
- func MustDecodeHexBlockHash(ss string) *BlockHash
- func NewBlockHash(hexBytes string) *BlockHash
- func ProofOfWorkHash(inputBytes []byte, version uint32) *BlockHash
- func Sha256DoubleHash(input []byte) *BlockHash
- func StakeIDToHash(stakeID []byte) *BlockHash
- type BlockNode
- func DeserializeBlockNode(data []byte) (*BlockNode, error)
- func GetBestChain(tipNode *BlockNode, blockIndex map[BlockHash]*BlockNode) ([]*BlockNode, error)
- func GetHeightHashToNodeInfo(handle *badger.DB, height uint32, hash *BlockHash, bitcoinNodes bool) *BlockNode
- func GetHeightHashToNodeInfoWithTxn(txn *badger.Txn, height uint32, hash *BlockHash, bitcoinNodes bool) *BlockNode
- func NewBlockNode(parent *BlockNode, hash *BlockHash, height uint32, difficultyTarget *BlockHash, ...) *BlockNode
- type BlockProducerInfo
- type BlockRewardMetadataa
- type BlockStatus
- type BlockTemplateStats
- type Blockchain
- func (bc *Blockchain) AddInputsAndChangeToTransaction(txArg *MsgBitCloutTxn, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) (_totalInputAdded uint64, _spendAmount uint64, _totalChangeAdded uint64, ...)
- func (bc *Blockchain) AddInputsAndChangeToTransactionWithSubsidy(txArg *MsgBitCloutTxn, minFeeRateNanosPerKB uint64, inputSubsidy uint64, ...) (_totalInputAdded uint64, _spendAmount uint64, _totalChangeAdded uint64, ...)
- func (bc *Blockchain) BestChain() []*BlockNode
- func (bc *Blockchain) BlockTip() *BlockNode
- func (bc *Blockchain) ChainState() SyncState
- func (bc *Blockchain) CopyBestChain() ([]*BlockNode, map[BlockHash]*BlockNode)
- func (bc *Blockchain) CopyBestHeaderChain() ([]*BlockNode, map[BlockHash]*BlockNode)
- func (bc *Blockchain) CopyBlockIndex() map[BlockHash]*BlockNode
- func (bc *Blockchain) CreateAcceptNFTBidTxn(UpdaterPublicKey []byte, NFTPostHash *BlockHash, SerialNumber uint64, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateBasicTransferTxnWithDiamonds(SenderPublicKey []byte, DiamondPostHash *BlockHash, DiamondLevel int64, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _spendAmount uint64, ...)
- func (bc *Blockchain) CreateCreateNFTTxn(UpdaterPublicKey []byte, NFTPostHash *BlockHash, NumCopies uint64, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateCreatorCoinTransferTxn(UpdaterPublicKey []byte, ProfilePublicKey []byte, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateCreatorCoinTransferTxnWithDiamonds(SenderPublicKey []byte, ReceiverPublicKey []byte, DiamondPostHash *BlockHash, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateCreatorCoinTxn(UpdaterPublicKey []byte, ProfilePublicKey []byte, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateFollowTxn(senderPublicKey []byte, followedPublicKey []byte, isUnfollow bool, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateLikeTxn(userPublicKey []byte, likedPostHash BlockHash, isUnlike bool, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateMaxSpend(senderPkBytes []byte, recipientPkBytes []byte, minFeeRateNanosPerKB uint64, ...) (_txn *MsgBitCloutTxn, _totalInputAdded uint64, _spendAmount uint64, ...)
- func (bc *Blockchain) CreateNFTBidTxn(UpdaterPublicKey []byte, NFTPostHash *BlockHash, SerialNumber uint64, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreatePrivateMessageTxn(senderPublicKey []byte, recipientPublicKey []byte, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateSubmitPostTxn(updaterPublicKey []byte, postHashToModify []byte, parentStakeID []byte, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateSwapIdentityTxn(UpdaterPublicKeyBytes []byte, FromPublicKeyBytes []byte, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateUpdateBitcoinUSDExchangeRateTxn(updaterPublicKey []byte, usdCentsPerbitcoin uint64, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateUpdateGlobalParamsTxn(updaterPublicKey []byte, usdCentsPerBitcoin int64, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateUpdateNFTTxn(UpdaterPublicKey []byte, NFTPostHash *BlockHash, SerialNumber uint64, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) CreateUpdateProfileTxn(UpdaterPublicKeyBytes []byte, OptionalProfilePublicKeyBytes []byte, ...) (_txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, ...)
- func (bc *Blockchain) DB() *badger.DB
- func (bc *Blockchain) EstimateDefaultFeeRateNanosPerKB(medianThreshold float64, minFeeRateNanosPerKB uint64) uint64
- func (bc *Blockchain) GetBlock(blockHash *BlockHash) *MsgBitCloutBlock
- func (bc *Blockchain) GetBlockAtHeight(height uint32) *MsgBitCloutBlock
- func (bc *Blockchain) GetBlockNodesToFetch(numBlocks int, _maxHeight int, blocksToIgnore map[BlockHash]bool) []*BlockNode
- func (bc *Blockchain) GetSpendableUtxosForPublicKey(spendPublicKeyBytes []byte, mempool *BitCloutMempool, ...) ([]*UtxoEntry, error)
- func (bc *Blockchain) HasBlock(blockHash *BlockHash) bool
- func (bc *Blockchain) HasHeader(headerHash *BlockHash) bool
- func (bc *Blockchain) HeaderAtHeight(blockHeight uint32) *BlockNode
- func (bc *Blockchain) HeaderLocatorWithNodeHash(blockHash *BlockHash) ([]*BlockHash, error)
- func (bc *Blockchain) HeaderTip() *BlockNode
- func (bc *Blockchain) LatestHeaderLocator() []*BlockHash
- func (bc *Blockchain) LatestLocator(tip *BlockNode) []*BlockHash
- func (bc *Blockchain) LocateBestBlockChainHeaders(locator []*BlockHash, stopHash *BlockHash) []*MsgBitCloutHeader
- func (bc *Blockchain) MarkBlockInvalid(node *BlockNode, errOccurred RuleError)
- func (bc *Blockchain) ProcessBlock(bitcloutBlock *MsgBitCloutBlock, verifySignatures bool) (_isMainChain bool, _isOrphan bool, _err error)
- func (bc *Blockchain) ProcessHeader(blockHeader *MsgBitCloutHeader, headerHash *BlockHash) (_isMainChain bool, _isOrphan bool, _err error)
- func (bc *Blockchain) ProcessOrphanBlock(bitcloutBlock *MsgBitCloutBlock, blockHash *BlockHash) error
- func (bc *Blockchain) SetBestChain(bestChain []*BlockNode)
- func (bc *Blockchain) SetBestChainMap(bestChain []*BlockNode, bestChainMap map[BlockHash]*BlockNode, ...)
- func (bc *Blockchain) ValidateTransaction(txnMsg *MsgBitCloutTxn, blockHeight uint32, verifySignatures bool, ...) error
- type BlockonomicsRBFResponse
- type BroadcastTxn
- type ChainType
- type CoinEntry
- type ConnectionManager
- func (cmgr *ConnectionManager) ConnectPeer(conn net.Conn, persistentAddr *wire.NetAddress)
- func (cmgr *ConnectionManager) GetAddrManager() *addrmgr.AddrManager
- func (cmgr *ConnectionManager) GetAllPeers() []*Peer
- func (cmgr *ConnectionManager) RandomPeer() *Peer
- func (cmgr *ConnectionManager) RemovePeer(pp *Peer)
- func (cmgr *ConnectionManager) Start()
- func (cmgr *ConnectionManager) Stop()
- type CreateNFTMetadata
- type CreatorCoinMetadataa
- type CreatorCoinOperationType
- type CreatorCoinTransferMetadataa
- type CreatorCoinTransferTxindexMetadata
- type CreatorCoinTxindexMetadata
- type DiamondEntry
- func DbGetDiamondEntriesForSenderToReceiver(handle *badger.DB, receiverPKID *PKID, senderPKID *PKID) (_diamondEntries []*DiamondEntry, _err error)
- func DbGetDiamondMappings(db *badger.DB, diamondReceiverPKID *PKID, diamondSenderPKID *PKID, ...) *DiamondEntry
- func DbGetDiamondMappingsWithTxn(txn *badger.Txn, diamondReceiverPKID *PKID, diamondSenderPKID *PKID, ...) *DiamondEntry
- type DiamondKey
- type ExpectedBitcoinResponse
- type ExpectedResponse
- type FollowEntry
- type FollowKey
- type FollowMetadata
- type FollowTxindexMetadata
- type ForbiddenPubKeyEntry
- type GetDataRequestInfo
- type GlobalParamsEntry
- type InvType
- type InvVect
- type LikeEntry
- type LikeKey
- type LikeMetadata
- type LikeTxindexMetadata
- type MempoolTx
- type MempoolTxFeeMinHeap
- type MessageEntry
- func DbGetLimitedMessageEntriesForPublicKey(handle *badger.DB, publicKey []byte) (_privateMessages []*MessageEntry, _err error)
- func DbGetMessageEntriesForPublicKey(handle *badger.DB, publicKey []byte) (_privateMessages []*MessageEntry, _err error)
- func DbGetMessageEntry(db *badger.DB, publicKey []byte, tstampNanos uint64) *MessageEntry
- func DbGetMessageEntryWithTxn(txn *badger.Txn, publicKey []byte, tstampNanos uint64) *MessageEntry
- type MessageKey
- type MiningSupplyIntervalStart
- type MsgBitCloutAddr
- type MsgBitCloutBitcoinManagerUpdate
- type MsgBitCloutBlock
- func (msg *MsgBitCloutBlock) EncodeBlockCommmon(preSignature bool) ([]byte, error)
- func (msg *MsgBitCloutBlock) EncodeBlockVersion0(preSignature bool) ([]byte, error)
- func (msg *MsgBitCloutBlock) EncodeBlockVersion1(preSignature bool) ([]byte, error)
- func (msg *MsgBitCloutBlock) FromBytes(data []byte) error
- func (msg *MsgBitCloutBlock) GetMsgType() MsgType
- func (msg *MsgBitCloutBlock) Hash() (*BlockHash, error)
- func (msg *MsgBitCloutBlock) String() string
- func (msg *MsgBitCloutBlock) ToBytes(preSignature bool) ([]byte, error)
- type MsgBitCloutBlockAccepted
- type MsgBitCloutDonePeer
- type MsgBitCloutGetAddr
- type MsgBitCloutGetBlocks
- type MsgBitCloutGetHeaders
- type MsgBitCloutGetTransactions
- type MsgBitCloutHeader
- func (msg *MsgBitCloutHeader) EncodeHeaderVersion0(preSignature bool) ([]byte, error)
- func (msg *MsgBitCloutHeader) EncodeHeaderVersion1(preSignature bool) ([]byte, error)
- func (msg *MsgBitCloutHeader) FromBytes(data []byte) error
- func (msg *MsgBitCloutHeader) GetMsgType() MsgType
- func (msg *MsgBitCloutHeader) Hash() (*BlockHash, error)
- func (msg *MsgBitCloutHeader) String() string
- func (msg *MsgBitCloutHeader) ToBytes(preSignature bool) ([]byte, error)
- type MsgBitCloutHeaderBundle
- type MsgBitCloutInv
- type MsgBitCloutMempool
- type MsgBitCloutNewPeer
- type MsgBitCloutPing
- type MsgBitCloutPong
- type MsgBitCloutQuit
- type MsgBitCloutTransactionBundle
- type MsgBitCloutTxn
- func DbGetAllMempoolTxnsSortedByTimeAdded(handle *badger.DB) (_mempoolTxns []*MsgBitCloutTxn, _error error)
- func DbGetMempoolTxn(db *badger.DB, mempoolTx *MempoolTx) *MsgBitCloutTxn
- func DbGetMempoolTxnWithTxn(txn *badger.Txn, mempoolTx *MempoolTx) *MsgBitCloutTxn
- func ExtractBitcoinExchangeTransactionsFromBitcoinBlock(bitcoinBlock *wire.MsgBlock, burnAddress string, params *BitCloutParams) (_txns []*MsgBitCloutTxn, _err error)
- func (msg *MsgBitCloutTxn) Copy() (*MsgBitCloutTxn, error)
- func (msg *MsgBitCloutTxn) FromBytes(data []byte) error
- func (msg *MsgBitCloutTxn) GetMsgType() MsgType
- func (msg *MsgBitCloutTxn) Hash() *BlockHash
- func (msg *MsgBitCloutTxn) MarshalJSON() ([]byte, error)
- func (msg *MsgBitCloutTxn) Sign(privKey *btcec.PrivateKey) (*btcec.Signature, error)
- func (msg *MsgBitCloutTxn) String() string
- func (msg *MsgBitCloutTxn) ToBytes(preSignature bool) ([]byte, error)
- func (msg *MsgBitCloutTxn) UnmarshalJSON(data []byte) error
- type MsgBitCloutVerack
- type MsgBitCloutVersion
- type MsgType
- type MsgWithError
- type NFTBidEntry
- func DBGetNFTBidEntries(handle *badger.DB, nftPostHash *BlockHash, serialNumber uint64) (_nftBidEntries []*NFTBidEntry)
- func DBGetNFTBidEntriesForPKID(handle *badger.DB, bidderPKID *PKID) (_nftBidEntries []*NFTBidEntry)
- func DBGetNFTBidEntriesPaginated(handle *badger.DB, nftHash *BlockHash, serialNumber uint64, ...) (_bidEntries []*NFTBidEntry)
- func DBGetNFTBidEntryForNFTBidKey(db *badger.DB, nftBidKey *NFTBidKey) *NFTBidEntry
- func DBGetNFTBidEntryForNFTBidKeyWithTxn(txn *badger.Txn, nftBidKey *NFTBidKey) *NFTBidEntry
- type NFTBidKey
- type NFTBidMetadata
- type NFTBidTxindexMetadata
- type NFTEntry
- func DBGetNFTEntriesForPKID(handle *badger.DB, ownerPKID *PKID) (_nftEntries []*NFTEntry)
- func DBGetNFTEntriesForPostHash(handle *badger.DB, nftPostHash *BlockHash) (_nftEntries []*NFTEntry)
- func DBGetNFTEntryByNFTOwnershipDetails(db *badger.DB, ownerPKID *PKID, isForSale bool, bidAmountNanos uint64, ...) *NFTEntry
- func DBGetNFTEntryByNFTOwnershipDetailsWithTxn(txn *badger.Txn, ownerPKID *PKID, isForSale bool, bidAmountNanos uint64, ...) *NFTEntry
- func DBGetNFTEntryByPostHashSerialNumber(db *badger.DB, postHash *BlockHash, serialNumber uint64) *NFTEntry
- func DBGetNFTEntryByPostHashSerialNumberWithTxn(txn *badger.Txn, postHash *BlockHash, serialNumber uint64) *NFTEntry
- type NFTKey
- type NetworkType
- type OperationType
- type OrphanBlock
- type PKID
- func DBGetPKIDForUsername(db *badger.DB, username []byte) *PKID
- func DBGetPKIDForUsernameWithTxn(txn *badger.Txn, username []byte) *PKID
- func DbGetPKIDsFollowingYou(handle *badger.DB, yourPKID *PKID) (_pkids []*PKID, _err error)
- func DbGetPKIDsYouFollow(handle *badger.DB, yourPKID *PKID) (_pkids []*PKID, _err error)
- func PublicKeyToPKID(publicKey []byte) *PKID
- type PKIDEntry
- type Peer
- func (pp *Peer) AddBitCloutMessage(bitcloutMessage BitCloutMessage, inbound bool)
- func (pp *Peer) Address() string
- func (pp *Peer) Connected() bool
- func (pp *Peer) Disconnect()
- func (pp *Peer) HandleGetBlocks(msg *MsgBitCloutGetBlocks)
- func (pp *Peer) HandleGetTransactionsMsg(getTxnMsg *MsgBitCloutGetTransactions)
- func (pp *Peer) HandleInv(msg *MsgBitCloutInv)
- func (pp *Peer) HandleTransactionBundleMessage(msg *MsgBitCloutTransactionBundle)
- func (pp *Peer) HelpHandleInv(msg *MsgBitCloutInv)
- func (pp *Peer) IP() string
- func (pp *Peer) IsOutbound() bool
- func (pp *Peer) IsSyncCandidate() bool
- func (pp *Peer) MaybeDequeueBitCloutMessage() *BitCloutMessageMeta
- func (pp *Peer) MinFeeRateNanosPerKB() uint64
- func (pp *Peer) NegotiateVersion(versionNegotiationTimeout time.Duration) error
- func (pp *Peer) NewVersionMessage(params *BitCloutParams) *MsgBitCloutVersion
- func (pp *Peer) NumBlocksToSend() uint32
- func (pp *Peer) Port() uint16
- func (pp *Peer) QueueMessage(bitcloutMessage BitCloutMessage)
- func (pp *Peer) ReadBitCloutMessage() (BitCloutMessage, error)
- func (pp *Peer) Start()
- func (pp *Peer) StartBitCloutMessageProcessor()
- func (pp *Peer) StartingBlockHeight() uint32
- func (pp *Peer) String() string
- func (pp *Peer) WriteBitCloutMessage(msg BitCloutMessage) error
- type PkMapKey
- type PostEntry
- type PostEntryReaderState
- type PrivateMessageMetadata
- type PrivateMessageTxindexMetadata
- type ProfileEntry
- func DBGetPaginatedProfilesByBitCloutLocked(db *badger.DB, startBitCloutLockedNanos uint64, startProfilePubKeyy []byte, ...) (_profilePublicKeys [][]byte, _profileEntries []*ProfileEntry, _err error)
- func DBGetProfileEntryForPKID(db *badger.DB, pkid *PKID) *ProfileEntry
- func DBGetProfileEntryForPKIDWithTxn(txn *badger.Txn, pkid *PKID) *ProfileEntry
- func DBGetProfileEntryForUsername(db *badger.DB, username []byte) *ProfileEntry
- func DBGetProfileEntryForUsernameWithTxn(txn *badger.Txn, username []byte) *ProfileEntry
- func DBGetProfilesByUsernamePrefixAndBitCloutLocked(db *badger.DB, usernamePrefix string, utxoView *UtxoView) (_profileEntries []*ProfileEntry, _err error)
- type PurchaseSupplyIntervalStart
- type RecloutEntry
- type RecloutKey
- type RuleError
- type Server
- func (srv *Server) BroadcastTransaction(txn *MsgBitCloutTxn) ([]*MempoolTx, error)
- func (srv *Server) ExpireRequests()
- func (srv *Server) GetBitcoinManager() *BitcoinManager
- func (srv *Server) GetBlockProducer() *BitCloutBlockProducer
- func (srv *Server) GetBlockchain() *Blockchain
- func (srv *Server) GetBlocks(pp *Peer, maxHeight int)
- func (srv *Server) GetConnectionManager() *ConnectionManager
- func (srv *Server) GetMempool() *BitCloutMempool
- func (srv *Server) GetMiner() *BitCloutMiner
- func (srv *Server) GetStatsdClient() *statsd.Client
- func (srv *Server) HasProcessedFirstTransactionBundle() bool
- func (srv *Server) ProcessSingleTxnWithChainLock(pp *Peer, txn *MsgBitCloutTxn) ([]*MempoolTx, error)
- func (srv *Server) ResetRequestQueues()
- func (srv *Server) Start()
- func (srv *Server) StartStatsdReporter()
- func (srv *Server) Stop()
- func (srv *Server) VerifyAndBroadcastTransaction(txn *MsgBitCloutTxn) error
- type ServerMessage
- type ServerReply
- type ServiceFlag
- type SingleAddr
- type SingleStake
- type StakeEntry
- type StakeEntryStats
- type StakeIDType
- type SubmitPostMetadata
- type SubmitPostTxindexMetadata
- type SummaryStats
- type SwapIdentityMetadataa
- type SwapIdentityOperationType
- type SwapIdentityTxindexMetadata
- type SwitchPeerMsg
- type SyncState
- type TXIndex
- type TransactionMetadata
- func ComputeTransactionMetadata(txn *MsgBitCloutTxn, utxoView *UtxoView, blockHash *BlockHash, ...) (*TransactionMetadata, error)
- func ConnectTxnAndComputeTransactionMetadata(txn *MsgBitCloutTxn, utxoView *UtxoView, blockHash *BlockHash, ...) (*TransactionMetadata, error)
- func DbGetTxindexTransactionRefByTxID(handle *badger.DB, txID *BlockHash) *TransactionMetadata
- func DbGetTxindexTransactionRefByTxIDWithTxn(txn *badger.Txn, txID *BlockHash) *TransactionMetadata
- type TxnType
- type UnconnectedTx
- type UpdateBitcoinUSDExchangeRateMetadataa
- func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) FromBytes(dataa []byte) error
- func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) GetTxnType() TxnType
- func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) New() BitCloutTxnMetadata
- func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) ToBytes(preSignature bool) ([]byte, error)
- type UpdateGlobalParamsMetadata
- type UpdateNFTMetadata
- type UpdateProfileMetadata
- type UpdateProfileTxindexMetadata
- type UsernameMapKey
- type UtxoEntry
- type UtxoKey
- type UtxoOperation
- type UtxoType
- type UtxoView
- func (bav *UtxoView) ConnectBlock(bitcloutBlock *MsgBitCloutBlock, txHashes []*BlockHash, verifySignatures bool) ([][]*UtxoOperation, error)
- func (bav *UtxoView) ConnectTransaction(txn *MsgBitCloutTxn, txHash *BlockHash, txnSizeBytes int64, blockHeight uint32, ...) (_utxoOps []*UtxoOperation, _totalInput uint64, _totalOutput uint64, ...)
- func (bav *UtxoView) CopyUtxoView() (*UtxoView, error)
- func (bav *UtxoView) DisconnectBlock(bitcloutBlock *MsgBitCloutBlock, txHashes []*BlockHash, ...) error
- func (bav *UtxoView) DisconnectTransaction(currentTxn *MsgBitCloutTxn, txnHash *BlockHash, utxoOpsForTxn []*UtxoOperation, ...) error
- func (bav *UtxoView) FlushToDb() error
- func (bav *UtxoView) FlushToDbWithTxn(txn *badger.Txn) error
- func (bav *UtxoView) GetAcceptNFTBidHistoryForNFTKey(nftKey *NFTKey) *[]*NFTBidEntry
- func (bav *UtxoView) GetAllNFTBidEntries(nftPostHash *BlockHash, serialNumber uint64) []*NFTBidEntry
- func (bav *UtxoView) GetAllPosts() (_corePosts []*PostEntry, _commentsByPostHash map[BlockHash][]*PostEntry, ...)
- func (bav *UtxoView) GetAllProfiles(readerPK []byte) (_profiles map[PkMapKey]*ProfileEntry, ...)
- func (bav *UtxoView) GetBalanceEntryForHODLerPubKeyAndCreatorPubKey(hodlerPubKey []byte, creatorPubKey []byte) (_balanceEntry *BalanceEntry, _hodlerPKID *PKID, _creatorPKID *PKID)
- func (bav *UtxoView) GetBitcloutBalanceNanosForPublicKey(publicKey []byte) (_balance uint64, _err error)
- func (bav *UtxoView) GetCommentEntriesForParentStakeID(parentStakeID []byte) (_commentEntries []*PostEntry, _err error)
- func (bav *UtxoView) GetCurrentUSDCentsPerBitcoin() uint64
- func (bav *UtxoView) GetDBHighAndLowBidEntriesForNFT(nftHash *BlockHash, serialNumber uint64) (_highBidEntry *NFTBidEntry, _lowBidEntry *NFTBidEntry)
- func (bav *UtxoView) GetDBHighAndLowBidsForNFT(nftHash *BlockHash, serialNumber uint64) (_highBid uint64, _lowBid uint64)
- func (bav *UtxoView) GetDiamondEntriesForSenderToReceiver(receiverPublicKey []byte, senderPublicKey []byte) (_diamondEntries []*DiamondEntry, _err error)
- func (bav *UtxoView) GetDiamondEntryForDiamondKey(diamondKey *DiamondKey) *DiamondEntry
- func (bav *UtxoView) GetDiamondEntryMapForPublicKey(publicKey []byte, fetchYouDiamonded bool) (_pkidToDiamondsMap map[PKID][]*DiamondEntry, _err error)
- func (bav *UtxoView) GetDiamondSendersForPostHash(postHash *BlockHash) (_pkidToDiamondLevel map[PKID]int64, _err error)
- func (bav *UtxoView) GetFollowEntriesForPublicKey(publicKey []byte, getEntriesFollowingPublicKey bool) (_followEntries []*FollowEntry, _err error)
- func (bav *UtxoView) GetFollowEntryForFollowerPublicKeyCreatorPublicKey(followerPublicKey []byte, creatorPublicKey []byte) *FollowEntry
- func (bav *UtxoView) GetHighAndLowBidsForNFTCollection(nftHash *BlockHash) (_highBid uint64, _lowBid uint64)
- func (bav *UtxoView) GetHighAndLowBidsForNFTSerialNumber(nftHash *BlockHash, serialNumber uint64) (_highBid uint64, _lowBid uint64)
- func (bav *UtxoView) GetLikedByReader(readerPK []byte, postHash *BlockHash) bool
- func (bav *UtxoView) GetLikesForPostHash(postHash *BlockHash) (_likerPubKeys [][]byte, _err error)
- func (bav *UtxoView) GetLimitedMessagesForUser(publicKey []byte) (_messageEntries []*MessageEntry, _err error)
- func (bav *UtxoView) GetMessagesForUser(publicKey []byte) (_messageEntries []*MessageEntry, _err error)
- func (bav *UtxoView) GetNFTBidEntriesForPKID(bidderPKID *PKID) (_nftBidEntries []*NFTBidEntry)
- func (bav *UtxoView) GetNFTBidEntryForNFTBidKey(nftBidKey *NFTBidKey) *NFTBidEntry
- func (bav *UtxoView) GetNFTEntriesForPKID(ownerPKID *PKID) []*NFTEntry
- func (bav *UtxoView) GetNFTEntriesForPostHash(nftPostHash *BlockHash) []*NFTEntry
- func (bav *UtxoView) GetNFTEntryForNFTKey(nftKey *NFTKey) *NFTEntry
- func (bav *UtxoView) GetPKIDForPublicKey(publicKey []byte) *PKIDEntry
- func (bav *UtxoView) GetParentPostEntriesForPostEntry(postEntry *PostEntry, maxDepth uint32, rootFirst bool) (_parentPostEntries []*PostEntry, _truncatedTree bool)
- func (bav *UtxoView) GetPostEntryForPostHash(postHash *BlockHash) *PostEntry
- func (bav *UtxoView) GetPostEntryReaderState(readerPK []byte, postEntry *PostEntry) *PostEntryReaderState
- func (bav *UtxoView) GetPostsPaginatedForPublicKeyOrderedByTimestamp(publicKey []byte, startPostHash *BlockHash, limit uint64, mediaRequired bool) (_posts []*PostEntry, _err error)
- func (bav *UtxoView) GetProfileEntryForPKID(pkid *PKID) *ProfileEntry
- func (bav *UtxoView) GetProfileEntryForPublicKey(publicKey []byte) *ProfileEntry
- func (bav *UtxoView) GetProfileEntryForUsername(nonLowercaseUsername []byte) *ProfileEntry
- func (bav *UtxoView) GetPublicKeyForPKID(pkid *PKID) []byte
- func (bav *UtxoView) GetQuoteRecloutsForPostHash(postHash *BlockHash) (_quoteReclouterPubKeys [][]byte, ...)
- func (bav *UtxoView) GetRecloutPostEntryStateForReader(readerPK []byte, postHash *BlockHash) (string, bool)
- func (bav *UtxoView) GetRecloutsForPostHash(postHash *BlockHash) (_reclouterPubKeys [][]byte, _err error)
- func (bav *UtxoView) GetSpendableBitcloutBalanceNanosForPublicKey(pkBytes []byte, tipHeight uint32) (_spendableBalance uint64, _err error)
- func (bav *UtxoView) GetUnspentUtxoEntrysForPublicKey(pkBytes []byte) ([]*UtxoEntry, error)
- func (bav *UtxoView) GetUtxoEntryForUtxoKey(utxoKey *UtxoKey) *UtxoEntry
- func (bav *UtxoView) HelpConnectCreatorCoinBuy(txn *MsgBitCloutTxn, txHash *BlockHash, blockHeight uint32, ...) (_totalInput uint64, _totalOutput uint64, _creatorCoinReturnedNanos uint64, ...)
- func (bav *UtxoView) HelpConnectCreatorCoinSell(txn *MsgBitCloutTxn, txHash *BlockHash, blockHeight uint32, ...) (_totalInput uint64, _totalOutput uint64, _bitCloutReturnedNanos uint64, ...)
- func (bav *UtxoView) ValidateDiamondsAndGetNumBitCloutNanos(senderPublicKey []byte, receiverPublicKey []byte, diamondPostHash *BlockHash, ...) (_numBitCloutNanos uint64, _netNewDiamonds int64, _err error)
- func (bav *UtxoView) ValidateDiamondsAndGetNumCreatorCoinNanos(senderPublicKey []byte, receiverPublicKey []byte, diamondPostHash *BlockHash, ...) (_numCreatorCoinNanos uint64, _netNewDiamonds int64, _err error)
Constants ¶
const ( // MaxOrphansInMemory is the maximum number of orphan blocks that we're willing to keep in memory. We set // a maximum here in order to prevent memory exhaustion from someone sending us too // many unconnectedTxns. MaxOrphansInMemory = 100 // MaxBlockIndexNodes needs to allow the block index to grow large enough to accommodate multiple // forks of material length while allowing us to avoid an out-of-memory issue due to // a "disk-fill" attack. Notice that because we will only ever download blocks // after we have a header chain that has beaten all other header chains we're aware // of, the common case for an attack will be someone sending us long useless header // chains that we never actually download blocks for. This results in the block index // bloating up (indefinitely if we don't prune it) due to storing useless headers // but not resulting in the downloading of any blocks, which is a good thing. // // At ten minute block times, 5,000,000 comes out to roughly 95 years worth of blocks, // which seems like a reasonable limit for now (if we had 25 years of blocks, we'd still // have room for multiple forks each an entire history's length with this value). If // each node takes up 100 bytes of space this amounts to around 500MB, which also seems // like a reasonable size. MaxBlockIndexNodes = 5000000 )
const ( StatusNone BlockStatus = 0 // Headers must always be Validated or ValidateFailed. We // don't store orphan headers and therefore any header that we do // have in our node index will be known definitively to be valid or // invalid one way or the other. StatusHeaderValidated = 1 << iota StatusHeaderValidateFailed StatusBlockProcessed StatusBlockStored StatusBlockValidated StatusBlockValidateFailed // These statuses are only used for Bitcoin header blocks in the BitcoinManager, // not BitClout blocks. As such, you should only see these referenced in the BitcoinManager. // We include them here because overloading the BitClout data structures to make it // so that the BitcoinManager can use them is easier than defining whole new data // structures that are incompatible with existing methods like LatestLocator(). If // Go supported generics, this would probably not be necessary but it doesn't and // so this is the path of least resistance. StatusBitcoinHeaderValidated StatusBitcoinHeaderValidateFailed )
const ( // Uint64Dec decrements a uint64 by one. Uint64Dec = ^uint64(0) // Uint32Dec decrements a uint32 by one. Uint32Dec = ^uint32(0) )
const ( // ConfigDirVendorName is the enclosing folder for user data. // It's required to created a ConfigDir. ConfigDirVendorName = "bitclout" // ConfigDirAppName is the folder where we keep user data. ConfigDirAppName = "bitclout" // UseridLengthBytes is the number of bytes of entropy to use for // a userid. UseridLengthBytes = 32 // These constants are used by the DNS seed code to pick a random last // seen time. SecondsIn3Days int32 = 24 * 60 * 60 * 3 SecondsIn4Days int32 = 24 * 60 * 60 * 4 // MessagesToFetchPerCall is used to limit the number of messages to fetch // when getting a user's inbox. MessagesToFetchPerInboxCall = 10000 )
const ( // This is the header version that the blockchain started with. HeaderVersion0 = uint32(0) // This version made several changes to the previous header encoding format: // - The Nonce field was expanded to 64 bits // - Another ExtraNonce field was added to provide *another* 64 bits of entropy, // for a total of 128 bits of entropy in the header that miners can twiddle. // - The header height was expanded to 64 bits // - The TstampSecs were expanded to 64 bits // - All fields were moved from encoding in little-endian to big-endian // // The benefit of this change is that miners can hash over a wider space without // needing to twiddle ExtraData ever. // // At the time of this writing, the intent is to deploy it in a backwards-compatible // fashion, with the eventual goal of phasing out blocks with the previous version. HeaderVersion1 = uint32(1) CurrentHeaderVersion = HeaderVersion1 )
const ( // Key in transaction's extra data map that points to a post that the current transaction is reclouting RecloutedPostHash = "RecloutedPostHash" // Key in transaction's extra map -- The presence of this key indicates that this post is a reclout with a quote. IsQuotedRecloutKey = "IsQuotedReclout" // Keys for a GlobalParamUpdate transaction's extra data map. USDCentsPerBitcoinKey = "USDCentsPerBitcoin" MinNetworkFeeNanosPerKBKey = "MinNetworkFeeNanosPerKB" CreateProfileFeeNanosKey = "CreateProfileFeeNanos" CreateNFTFeeNanosKey = "CreateNFTFeeNanos" MaxCopiesPerNFTKey = "MaxCopiesPerNFT" ForbiddenBlockSignaturePubKeyKey = "ForbiddenBlockSignaturePubKey" DiamondLevelKey = "DiamondLevel" DiamondPostHashKey = "DiamondPostHash" )
Defines keys that may exist in a transaction's ExtraData map
const ( // MinNetworkFeeNanosPerKBValue - Minimum value to which the minimum network fee per KB can be set. MinNetworkFeeNanosPerKBValue = 0 // MaxNetworkFeeNanosPerKBValue - Maximum value to which the maximum network fee per KB can be set. MaxNetworkFeeNanosPerKBValue = 100 * NanosPerUnit // MinCreateProfileFeeNanos - Minimum value to which the create profile fee can be set. MinCreateProfileFeeNanos = 0 // MaxCreateProfileFeeNanos - Maximum value to which the create profile fee can be set. MaxCreateProfileFeeNanos = 100 * NanosPerUnit // Min/MaxCreateNFTFeeNanos - Min/max value to which the create NFT fee can be set. MinCreateNFTFeeNanos = 0 MaxCreateNFTFeeNanos = 100 * NanosPerUnit // Min/MaxMaxCopiesPerNFTNanos - Min/max value to which the create NFT fee can be set. MinMaxCopiesPerNFT = 1 MaxMaxCopiesPerNFT = 10000 )
Define min / max possible values for GlobalParams.
const ( ChainTypeBitCloutBlock = iota ChainTypeBitcoinHeader )
const ( // MaxTotalTransactionSizeBytes is the maximum number of bytes the pool can store // across all of its transactions. Once this limit is reached, transactions must // be evicted from the pool based on their feerate before new transactions can be // added. MaxTotalTransactionSizeBytes = 250000000 // 250MB // UnconnectedTxnExpirationInterval is how long we wait before automatically removing an // unconnected transaction. UnconnectedTxnExpirationInterval = time.Minute * 5 // The maximum number of unconnected transactions the pool will store. MaxUnconnectedTransactions = 10000 // The maximum number of bytes a single unconnected transaction can take up MaxUnconnectedTxSizeBytes = 100000 )
const ( // MaxAddrsPerAddrMsg is the maximum number of addresses we allow in a single // addr message from a peer. MaxAddrsPerAddrMsg = 1000 // AddrRelayIntervalSeconds is the amount of time we wait before relaying each // batch of addresses we've received recently. AddrRelayIntervalSeconds = 60 // RebroadcastNodeAddrIntervalMinutes is how often we broadcast our own address // to our peers. RebroadcastNodeAddrIntervalMinutes = 24 * 60 )
const ( // MaxBitCloutInputSizeBytes is the size required to encode an BitCloutInput. // 32 bytes for the TxID and 4 bytes for the Index = 36 bytes. Note // that because the index is encoded as a uvarint, this size represents // a maximum. MaxBitCloutInputSizeBytes = 32 + 4 // MaxBitCloutOutputSizeBytes is the size required to encode an BitCloutOutput. // It is 33 bytes for the public key and 8 bytes for the amount // = 41 bytes. Note that because the amount is encoded as a uvarint, // this size represents a maximum. MaxBitCloutOutputSizeBytes = btcec.PubKeyBytesLenCompressed + 8 )
const ( NanosPerUnit = uint64(1000000000) BlocksPerYear = uint32(12 * 24 * 365) BlocksPerDay = uint32(12 * 24) // Every 1M BitClout we sell causes the price to increase by a factor of 2. TrancheSizeNanos = uint64(1000000000000000) // When exchanging Bitcoin for BitClout, we don't allow transactions to create // less than this amount. This avoids issues around small transactions that // exploit floating point errors. MinNanosToCreate = 50 // The price of BitClout at the beginning. StartBitCloutPriceUSDCents = 50 SatoshisPerBitcoin = 100000000 // The minimum and maximum Bitcoin prices, used as a sanity-check. MinUSDCentsPerBitcoin = 100 * 100 MaxUSDCentsPerBitcoin = 1000000 * 100 // Used for sanity checks for now. This is not necessarily the actual the max supply. MaxNanos = uint64(30000000) * NanosPerUnit )
const ( MaxVarintLen16 = 3 MaxVarintLen32 = 5 MaxVarintLen64 = 10 )
MaxVarintLenN is the maximum length of a varint-encoded N-bit integer.
const (
FloatPrecision uint = 53
)
const HashSizeBytes = 32
const ( // MaxBlocksInFlight is the maximum number of blocks that can be requested // from a peer. MaxBlocksInFlight = 250 )
const MaxMessagePayload = (1024 * 1024 * 100) // 100MB
MaxMessagePayload is the maximum size alowed for a message payload.
const (
MaxUsernameLengthBytes = 25
)
const OutputSizeBytes = 33 + 8
OutputSizeBytes is the size of an BitCloutOutput in bytes. 33 bytes for the public key and 8 bytes for the uint64.
const SECURE_MIDDLEWARE_RESTRICTIVE_CONTENT_SECURITY_POLICY = "default-src 'self'"
Variables ¶
var ( // Note: Can be updated by various functions. It's a global variable sorry. // TODO: We can turn this into a struct if we have more command-specific timeouts // and pass it as an argument down the call stack. BitcoinGetHeadersTimeout = 3 * time.Second BitcoinHeaderUpdateInterval = 5 * time.Second )
var ( // SalomonFixBlockHeight defines a block height where the protocol implements // two changes: // (1) The protocol now prints founder reward for all buy transactions instead // of just when creators reach a new all time high. // This was decided in order to provide lasting incentive for creators // to utilize the protocol. // (2) A fix was created to deal with a bug accidentally triggered by @salomon. // After a series of buys and sells @salomon was left with a single creator coin // nano in circulation and a single BitClout nano locked. This caused a detach // between @salomon's bonding curve and others on the protocol. As more buys and sells // continued, @salomon's bonding curve continued to detach further and further from its peers. // At its core, @salomon had too few creator coins in circulation. This fix introduces // this missing supply back into circulation as well as prevented detached Bancor bonding // curves from coming into existence. // ^ It was later decided to leave Salomon's coin circulation alone. A fix was introduced // to prevent similar cases from occurring again, but @salomon is left alone. SalomonFixBlockHeight = uint32(15270) // BitCloutFounderRewardBlockHeight defines a block height where the protocol switches from // paying the founder reward in the founder's own creator coin to paying in BitClout instead. BitCloutFounderRewardBlockHeight = uint32(21869) // BuyCreatorCoinAfterDeletedBalanceEntryFixBlockHeight defines a block height after which the protocol will create // a new BalanceEntry when a user purchases a Creator Coin and their current BalanceEntry is deleted. // The situation in which a BalanceEntry reaches a deleted state occurs when a user transfers all their holdings // of a certain creator to another public key and subsequently purchases that same creator within the same block. // This resolves a bug in which users would purchase creator coins after transferring all holdings within the same // block and then the creator coins would be added to a deleted balance. When the Balance Entries are flushed to // the database, the user would lose the creator coins they purchased. BuyCreatorCoinAfterDeletedBalanceEntryFixBlockHeight = uint32(39713) // ParamUpdaterProfileUpdateFixBlockHeight defines a block height after which the protocol uses the update profile // txMeta's ProfilePublicKey when the Param Updater is creating a profile for ProfilePublicKey. ParamUpdaterProfileUpdateFixBlockHeight = uint32(39713) // UpdateProfileFixBlockHeight defines the height at which a patch was added to prevent user from // updating the profile entry for arbitrary public keys that do not have existing profile entries. UpdateProfileFixBlockHeight = uint32(46165) // BrokenNFTBidsFixBlockHeight defines the height at which the bitclout balance index takes effect // for accepting NFT bids. This is used to fix a fork that was created by nodes running with a corrupted // bitclout balance index, allowing bids to be submitted that were greater than the user's bitclout balance. BrokenNFTBidsFixBlockHeight = uint32(46917) // BitCloutDiamondsBlockHeight defines the height at which diamonds will be given in CLOUT // rather than in creator coin. // Triggers: 3pm PT on 8/16/2021 BitCloutDiamondsBlockHeight = uint32(52112) )
var ( UsernameRegex = regexp.MustCompile("^[a-zA-Z0-9_]+$") // Profile pics are Base64 encoded plus ": ; ," used in the mime type spec. ProfilePicRegex = regexp.MustCompile("^[a-zA-Z0-9+/:;,]+$") TikTokShortURLRegex = regexp.MustCompile("^.*(vm\\.tiktok\\.com/)([A-Za-z0-9]{6,12}).*") TikTokFullURLRegex = regexp.MustCompile("^.*((tiktok\\.com/)(v/)|(@[A-Za-z0-9_-]{2,24}/video/)|(embed/v2/))(\\d{0,30}).*") )
var ( ArchitectPubKeyBase58Check = "BC1YLg3oh6Boj8e2boCo1vQCYHLk1rjsHF6jthBdvSw79bixQvKK6Qa" // This is the public key corresponding to the BitcoinBurnAddress on mainnet. BurnPubKeyBase58Check = "BC1YLjWBf2qnDJmi8HZzzCPeXqy4dCKq95oqqzerAyW8MUTbuXTb1QT" GenesisBlock = MsgBitCloutBlock{ Header: &MsgBitCloutHeader{ Version: 0, PrevBlockHash: &BlockHash{}, TransactionMerkleRoot: mustDecodeHexBlockHash("4b71d103dd6fff1bd6110bc8ed0a2f3118bbe29a67e45c6c7d97546ad126906f"), TstampSecs: uint64(1610948544), Height: uint64(0), Nonce: uint64(0), }, Txns: []*MsgBitCloutTxn{ { TxInputs: []*BitCloutInput{}, TxOutputs: SeedBalances, TxnMeta: &BlockRewardMetadataa{ ExtraData: []byte( "They came here, to the New World. World 2.0, version 1776."), }, }, }, } GenesisBlockHashHex = "5567c45b7b83b604f9ff5cb5e88dfc9ad7d5a1dd5818dd19e6d02466f47cbd62" GenesisBlockHash = mustDecodeHexBlockHash(GenesisBlockHashHex) ParamUpdaterPublicKeys = map[PkMapKey]bool{ MakePkMapKey(MustBase58CheckDecode(ArchitectPubKeyBase58Check)): true, MakePkMapKey(MustBase58CheckDecode("BC1YLiXwGTte8oXEEVzm4zqtDpGRx44Y4rqbeFeAs5MnzsmqT5RcqkW")): true, MakePkMapKey(MustBase58CheckDecode("BC1YLgGLKjuHUFZZQcNYrdWRrHsDKUofd9MSxDq4NY53x7vGt4H32oZ")): true, MakePkMapKey(MustBase58CheckDecode("BC1YLj8UkNMbCsmTUTx5Z2bhtp8q86csDthRmK6zbYstjjbS5eHoGkr")): true, MakePkMapKey(MustBase58CheckDecode("BC1YLgD1f7yw7Ue8qQiW7QMBSm6J7fsieK5rRtyxmWqL2Ypra2BAToc")): true, MakePkMapKey(MustBase58CheckDecode("BC1YLfz4GH3Gfj6dCtBi8bNdNTbTdcibk8iCZS75toUn4UKZaTJnz9y")): true, MakePkMapKey(MustBase58CheckDecode("BC1YLfoSyJWKjHGnj5ZqbSokC3LPDNBMDwHX3ehZDCA3HVkFNiPY5cQ")): true, } )
GenesisBlock defines the genesis block used for the BitClout maainnet and testnet
var ( QuotedRecloutVal = []byte{1} NotQuotedRecloutVal = []byte{0} )
var ( IsGraylisted = []byte{1} IsBlacklisted = []byte{1} )
var ( // The readOnlyUtxoView will update after the number of seconds specified here OR // the number of transactions specified here, whichever comes first. An update // resets both counters. // // We make these vars rather than const for testing ReadOnlyUtxoViewRegenerationIntervalSeconds = float64(1.0) ReadOnlyUtxoViewRegenerationIntervalTxns = int64(1000) // LowFeeTxLimitBytesPerTenMinutes defines the number of bytes per 10 minutes of "low fee" // transactions the mempool will tolerate before it starts rejecting transactions // that fail to meet the MinTxFeePerKBNanos threshold. LowFeeTxLimitBytesPerTenMinutes = 150000 // Allow 150KB per minute in low-fee txns. )
var ( // These transactions are simply here to bootstrap the profiles on the network. We had // some people testing things before it went live and wanted to preserve their profiles. SeedTxns = []string{} TestSeedTxns = []string{ "015e71a8a3b43fddb2cb9d487116338ffc8a089be76ce55b5fd16f7e20e3f47ebb000103aad5affbeee6118a91b914495f2bd0abffd0ac4782c2139a3ced0e353aa4ae49da7a068a20000762616c616a69731a3c703e747769747465722e636f6d2f62616c616a69733c2f703edf1f646174613a696d6167652f6a7065673b6261736536342c2f396a2f327743454141674742676347425167484277634a4351674b4442514e4441734c44426b534577385548526f6648683061484277674a43346e49434973497877634b4463704c4441784e44513048796335505467795043347a4e44494243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f4141424549414751415a414d4249674143455145444551482f7841476941414142425145424151454241514141414141414141414141514944424155474277674a436773514141494241774d4342414d4642515145414141426651454341774145455155534954464242684e525951636963525179675a476843434e4373634556557448774a444e69636f494a4368595847426b614a53596e4b436b714e4455324e7a67354f6b4e4552555a4853456c4b55315256566c64595756706a5a47566d5a326870616e4e3064585a3365486c3667345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f716171797337533174726534756272437738544678736649796372533039545631746659326472683475506b3565626e364f6e7138664c7a39505832392f6a352b674541417745424151454241514542415141414141414141414543417751464267634943516f4c455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f415061714b4b4d554146464648656741724d31727842706e682b32576655626c596735784847427565512b69714f542f41434663763852764878384a515132646973556d70334b6c6c4d764b776f4f4e784838524a3644323572784b396b3137786a657463586f6b75626c2f6b524a4d7156547163486f427766595a59347851423631716e7877384f5753736c7062334e334f4239304655516656763841616d384e2f46375364616e534f356c74724d75514172376c4f536363453848394b385930587772642b4b4e6353783062543175436f4264324a45435a343345396476314f546a69757a732f6778724c366d624f613349695253383871756f67633956566568395058337851423732724b36686c594d7036454867307465642b4835727277536e396e5874764f4e50334b49354c69596c687a3878554867714377393864754b39452f484e41425252525141744846464641435555744a514155645342533144647a6931733537672f38736f326b2f49452f77424b41504c62505459504748784d6b757232454745764967336b4b776a69796971423179784c6b6e2f437655443455306357567a6152326363635679686a6c32714d6c434d46515430424848487236313466384a333148567646736d71346b6b74394f676c6e534b4d457449584a4155456e4753636e6e6976554e61755048733976492b6c33476a576268437867614b53575350324c3872752f444641485736586f2b6e364c5a72616164615257304b67446247754d344741536570507561745453724247585a584948397853782f4963317a76677134312b62523258784463576339326a63535732506d552f3367414144394b79746138512b4a3766574a76374d4f697a574b714367637973787a3359714d4139652b4d55415876487470623674344c6e6b61586244437958445344494b71724173523379426b3439735646344e31523956384c5755307362527a704749706b62727555446e38657634314264617464613334583150547458734873356269786d4d63304c6834704d4b6337574249427a324a7a5758384d373058656e616a47522b3874706f6f6e4f63352f644b66356c767a6f41376d69696c6f414b4b4b4b41456f7061536742617a64654262517278414d37343968474d35424942483467347252714b35682b3057386b4f6346317744364873667a6f41356e34582b48573850324771776d4e6c4275676b6538446473564163456a726773772f4374505566437a7a617061366c50712b6f7969327933326447594c49782f3255494834592f4876544e4e3175574456622b30466d6d48564c75504d6f5142577970427a334471335156646e6e753954426a597869412f6569694a4959656a76787837415a2b6f6f4157317649493765565239706d615253486c6951754d386a6876346950555a35724558773232705132306474724e2f614a6163524e6253756762414149594167412b716b5a7963383130613269716f4453535a2f77426c746f2f4143713777584670634765336b4b7351417a624e7759446f4855646364694f61414456724a6f2f434772724737795379573072466e473073517077534f6d6341633435726a50684a7072576e686d34765a485a704e51754463454850413644723378585a334774734c4f51584e744538624c73667972674837334851674876533658617732576e5257317648356345513252726e4f4642774f66776f41755555555541464c69696967424b4b576b6f414b4f3946464146413238635775777a42522b2b67654d3539517763667a6170314d4c74734e354e757a3978704e702f4c414e564e58756862477a4b4b306c783536736b61444a5a656a2f6f33356b4372766d2b65676c524575625a786c53754d6a38447766304e4144785a322b442b35567339537733452f69615930554d4b2f386644776a303833414834484e526b5747666d67436e304d4a422f6c546c43352f30617a56542f66644e6748395451425876315734736f6f6b6c636d61346a5153734275474733456a4939464e5831554b67555a77426a6e72564e5a5264366b4657525a46737752497939504e5959782b43352f373646586141436969696742614b4b50776f41536969766e2f414f49586a2f786270766937556446743955614332676b2b517752694e74704149426247652b4f74414876747850466177505063537044436779306b6a42565565354e6342346c2b4d50686e5259474668634c71393252387364733379412f375439422b4754587a74714f7033757059463366334e797a4e3879764d7a2f6e6b6d71766c4c437042366e6f4b4150706e345758643534773054565045656f794c39766e752f4a673272386c756b574756564870754a4a3961363636747271654e727253646c766568735845442f635a752b3465762b304f534d56792f7752486b6541594c567475384d3078412f7742706d4838314e6478717a783246744c71545863566f734346705a4a76395755485a763645636a333655415a367936384a7843644d743258484d77754e696a2f674f436169764876476d537a38784a6275515a4e7462457173612f774236522f76626659594a7244384b664537536648476f5461665a585a7335567946526b4f2b5565714d65423334786d75323257656b574538345552777871303072395332426b7354314a774f706f413841316278394a34492b4b3839724377754e4b746f59724f36695142664d59444c4f423259466a6a3871396330507868346638526f447065715154502f7a7959374a422f774142626d766b37554c32585639617664546d623537715a37673768335a69522b6c5269507a477a76773436464f4d554166615051386969766c50512f696e3471384f4f74762f41476c4a6332364841697550336f78376275522b424665362b427669435047706b5347316a67654251307761546b357a3978526e6a703150656744754b4b5369674376663330476e57636c3163797048476e566e4f426e734b2b512f4645332f41425074516e74377837714b5335636965513879416b6e4a3631394e66456d79612b2b486574526f32313067383154366253442f41434272356a38523664467046326c684664435a746b636a507377446c6338653349363830415a3855697167437141657541436169754a585a6c546b44647a6e4171504c37386e6e36442b56575462454a6c786a75445142394a66434f36537a384761464b3771493556757265527a324b4f30696b2f6876726e664862613538522f433271367a424b396e346373464d746a616e68722f59666d6c663055444f3056642b44735547752f44753730753733474f432f634d46624232756f6247527941637344374531612b4d757477364c344c68304b30437850666b524b69444153424d5a2b672b36763530416563664348775a633633667a366e6d534f307465456c336c6633352b36526a6e4b416c76726756363538515045747a59664448573757396662716769573233714d435a5a4732695266596a646b646a6b656c63743842395a4c323271614849774c52737435467832623557483567666e566e3438583061614870476e74747a5063744b337273526638574835554165426252457a6c7541427836553172686b494233344a3639525669634b3879746b6263347a394b626454774e45565162736359365541567849584c6771583534794b2b67766770345a6974744a6b312b614d66616267744644496b755159754d67714f683344767a58694f67576e397058456b4a6c696a4372764d6b37375555444136386e754f42583052384c76446a364a7042757266567865324e2b676b38725951497051634e7450636359375a774b414f2f6f70614b414d627854382f68793968494253614d784e6b5a34595950343831386b367239387365544849554830782f774457723632385466384149436d2b712f7a72354a31582f6c722f414e64322f6b61414d637a4f534d48475053725379755967704a507a3479547a564772612f63482f4146306f4139342f5a2b6b59326576785a2b5153774f42376c5748394258492f4779396e6c386679784f2b5937654f4b4f4e66514664782f566a58562f732f66367278422f7651667965754d2b4e482f41435557392b6b502f6f746141462b4564334e423854394e6a6a62437a7779787944315861542f4d4374663436584d736e6a61317432624d55476e6f794c36466e596e2b512f4b734834552f386c5430582f646b2f7744526256736648442f6b66302f374230582f414b453141486c666d47545a45796772752f4774473567686874564b524c6b6e6b6e6d7374503841584a2f76567358332f48716c414768704869613674644d753950743757786957555a615a4950336e48624f6666307a3731395465484c4333307a7737703970616f5669574257414a7963734e7850356b3138666164392b622f645038712b79394d2f35424e6c2f313752662b674367433352525251422f2f32513d3de807d461002103aad5affbeee6118a91b914495f2bd0abffd0ac4782c2139a3ced0e353aa4ae4900463044022041123e82f809b41e566782a3f672ba78e7fead560a3cac5a0c2ce7738aefd41e02204af70a96b05b5e12b3503d41e106606ea5c57c0d754158165fcd14ee668c56b7", "01f0a8bf832ff02ee8bf0936db0666c9c1af7bc36ab57c747fe9bd2108902cc8f3000103aad5affbeee6118a91b914495f2bd0abffd0ac4782c2139a3ced0e353aa4ae49d07405ce040000bc047b22426f6479223a225c75303033636469765c75303033655c7530303363705c753030336554686973206973206120746573742e20486572655c75303032362333393b7320746865204b6c65696e20666f75722d67726f75703a5c7530303363696d67207372633d5c2268747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f392f39372f4b6c65696e5f666f75722d67726f75702533425f4361796c65795f7461626c652533425f73756267726f75705f6f665f53345f253238656c656d656e74735f302532433125324336253243372532392e7376672f32303070782d4b6c65696e5f666f75722d67726f75702533425f4361796c65795f7461626c652533425f73756267726f75705f6f665f53345f253238656c656d656e74735f302532433125324336253243372532392e7376672e706e675c2220616c743d5c227376672e706e675c225c7530303365205c75303033632f705c75303033655c7530303363705c75303033655c75303033636120687265663d5c2268747470733a2f2f656e2e77696b6970656469612e6f72672f77696b692f4b6c65696e5f666f75722d67726f75705c222072656c3d5c226e6f666f6c6c6f775c225c753030336568747470733a2f2f656e2e77696b6970656469612e6f72672f77696b692f4b6c65696e5f666f75722d67726f7570205c75303033632f615c75303033655c75303033632f705c75303033655c75303033632f6469765c7530303365227de807d46182bdd490cbb6e7a016002103aad5affbeee6118a91b914495f2bd0abffd0ac4782c2139a3ced0e353aa4ae49004630440220195f30b5afa46a8c854286a1bf4b3c484c0761c03dbbaf6658f05dfaadd421e702201359806b6d632d1fc9735d5f0652ecaf75767bb3d09f3873363143f60387890d", "019006717275a77fb150188e4522187065cfbc771ae47cf609f536956cb740df6f020102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be4c1ddeb170583020000f1017b22426f6479223a225c753030336368325c753030336541207461737465206f662066726565646f6d2063616e206d616b6520796f7520756e656d706c6f7961626c6520666f72206c6966655c753030336362725c75303033655c75303033632f68325c75303033655c75303033636469765c75303033655c7530303363696d67207372633d5c2268747470733a2f2f692e7974696d672e636f6d2f76692f35617665495a456c6d734d2f6d617872657364656661756c742e6a70675c2220616c743d5c226d617872657364656661756c742e6a70675c225c7530303365205c75303033632f6469765c7530303365227de807d461b189e7e9d7e8e99e16002102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be40046304402200ce37e660dfa13a9e6bb55a92f5522f43e01e9a8db662c94b54f7fde9aabefde0220531302c99524f744e669eb7742750857eeb766a07ee89a0fcebffef4335dd380", "01c8e71ed7bbc785fbb014ebbf21a45b411f28dbb1be528c1f72712f1bbd819fa8000102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be4ceaaeb1706f51a0008766c6164696d697200e31a646174613a696d6167652f6a7065673b6261736536342c2f396a2f327743454141674742676347425167484277634a4351674b4442514e4441734c44426b534577385548526f6648683061484277674a43346e49434973497877634b4463704c4441784e44513048796335505467795043347a4e44494243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f4141424549414573415a414d4249674143455145444551482f7841476941414142425145424151454241514141414141414141414141514944424155474277674a436773514141494241774d4342414d4642515145414141426651454341774145455155534954464242684e525951636963525179675a476843434e4373634556557448774a444e69636f494a4368595847426b614a53596e4b436b714e4455324e7a67354f6b4e4552555a4853456c4b55315256566c64595756706a5a47566d5a326870616e4e3064585a3365486c3667345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f716171797337533174726534756272437738544678736649796372533039545631746659326472683475506b3565626e364f6e7138664c7a39505832392f6a352b674541417745424151454241514542415141414141414141414543417751464267634943516f4c455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f41504438303544544f314f5470534b366a7761565430706e7255397243626935696858724977583836426f3662777234516b312b565a7271593231687577584179386d4f7577663150483172325052664450672f5372666246346468756d364e4c654d5a585035384438414b352f526f3067736f6767323844414136416442585132643742396f386e37516d2f70744a727a5a3469626c377578364650445135627a473674384e76436e694f316b2f7336322f73612b41796a524e6d4e6a3771655079785869586958773171666854552f73577077624759626f33427973712f336c5070587638414c6370417059796f75665671354834673278316a77704d585979535749382b4167357750346839434d2f6b4b306f346d584e797a366d6466435255584b4234715a4f4b694c356f592b394d4a7230447a6863304e77545463386970722b50794c32574c2b366636564e396246637235655968794b4d696d5a6f7a5645682f44546f786d676a3933546f686b564639446f55666551673731306e676d316a7539644964555a6f344864413534794d44383845317a593731712b4864554f6a3635615878424b5274687776557152672f7a714b6962673069714c536d6d396a313278674d396d4556796a5979434f745248514c6a7a2f41445074443767516435427a2f50485771396a716b4631494c2b336c64344a574f474b3753656534375630563365547459683765487a6e5567695064743344767a586c7136756a316c613130564e52307536613653534f59694d375142754b37654f54304f54557374764d746d304e367764586a5a584b6a2b457152302f4772756d616c4a65704a4a505a74417531514e357a7550394b77664632745132756936684e35717249497a46437537424c74787750624a2f4b7031756b74796e626c626c7365486e6a6a303470704e4b656e576d4531375a38384f4235725438524b453132354136664b662f4852575154576e34686666724d726735796b5a2f3841484257542f697839482b6876482b424c315835534d374e47615a6d6a507657706757796e2b6a4530747375564e5373762b676b303679584d5a72427939316e70716e2b38697649716763742b4e4f6a483361756162706c3571743662577774704c6963676b4a474d6e48716653756d58345a654b6f6a4573326e787846756f6534544b2f55416b6971636b747a434d4e55546544395245576d74424f7045586e4d71766a6a6e422f72585672625863397635746c6379507a38346a75504b782b50616f5044386567785742384c617578302f55726432594e4e494e73724e7a6c473645644f4436567a6b326f7757657358466c61547335686c614c664753466b77635a466364536b2b5a795231557138624b4c334f346a6a314f3274773933634d426e4152335279332f4167425843654c70497232385246473559304b6c76636e4a727576442b6c535879704e4f353873454576492b45583854785847654934625a64587649725734676e6a535674725179623132354f4d48765745564a53352b683079634a707762314f42754944412b436367394455445674586b4f3846652b4f4b647048672f584e64686561787374384b6e486d5049714b5437466a7a2b46656e436f6d727338657252635a57534d426a78567a56574c337537316a542f414e42464f316e5272375174516179314345527a716f6241594d47553943434f434b70334c6c354153663456483656567279545246375163583566715238305a4e4e7a526e33717a4d33594c64377132454d52547a484f46447571412f69534257705a364e6232635a2f74445662614a6765597263475a2f707867412f6a58506b354f505374337733706333695058725054496e43764f34566e592f6455444a5076674138566b6f4b327032564d544c6e7648533268332f41494f307a543757306c75744e467952636346376a415a73487342304761374270316d5569596c6d3735593830532b48786f5670486232323537574e51456475575564743376373944584e367a717161626154586330677847506b6a2f7648734b345a336c4a6e5a536b6c424f357a6e78415741616c7049756f4565315865485346747262636a7636342f437558306a7737724775582f2f41424b374b65544d6a415368534634353550544f4b7058577058477058472b6438675a32676e4f4d3831374838492f476c705a61524c6f326f794349514d30304d6836624479775066673950726975326e4677676b7a7a6130314f6f3549383238565776696d796e6a734e5a4e35354b6a3931356d566a59663750474b69384b7461616672476454684531724c47555a577a67636a6b456335474b2b705a4470327536566c6c6875374364417973774452794b5231482b4e654466466653744e304b37307550544c564c654e684c77766341726a2b5a71756c694533653548652b4664426d6d6975374c575761325935613345666d534165675966314661646c71467a4e644b746c617157414f576d4b694b41442b4841364848714d3135786233525268496b3677734477532b30316f326572726433506c586c2b493432484c42507645644d6e76584e557074367061486f554b385637736e7164623436304b665739434d376d4c37625949307165577077366457546e38783950657647584f534437563942364a4a466361636a4b356c2f684f57445a483172786e78543461766443316d346761306e2b796c79626558793232756e55594f4d635a77617644536573575a34324375706f352b6b707852676346534437696b326e30503556316e41614841596a72394b75326431505958554e31617974465043346b6a646571734f68716e4879546d704b676535394665472f47316e346c30574b376d6c696776455a596269497342686a774d5a366875333556795078566a305748534147486c616d307761336a6a66377939474c4c3041392f58474f39655a36456979612f5952754e794e637835553944387772582b4a6b7276342f31494d784954793158324777636671617a355065755770766c73637645635341383472566a6a456157383038544e62752b666b62617a41486b4139756e577379443775652b613648554f50446d6a34342f316e2f6f5272526b4830786f4d476e522b4372434853636d7746735049334e6b6c547a7966584a4f66657646766a59344f75365a45702f31646f5352365a632f345633587765755a7076682f50484a49575347376b534d482b46537174676669536678727a6a34754f7a654e63453543326b514874393430756f4938364c5a4f434f6c4b43696b4d565545486a4e4a363143354a3450536d467a313777566f63757257384d79615642645730772f312b7864716b443574782f684950623656662b4a576c36566f50684f4f4f794b322b705856796f6a6b684a517146423341592f6836412b7049394b58344e54534877753646323270645368567a774274552f7a4e637638565a704a4e547367376c68746b362f55437346424b65683054717555624d38372f747a56304a582b3037304563454764755031705037653166384136436c352f77422f322f787174666b2f616433646c42507561725a5072585263357a2f2f32513d3de807d461002102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be4004730450221008b352a6233e00b7ccfed62e40ab518b031f24ef2471bcee4b6a0c020d9c8c76602207e3a7ab017374854b3a0cfc34db7e9766a56e6d3a34f608e331cfb21582520c8", "011aa7e639a5c1c4f3923bdd5f36e0cc54c04bba68342de82e038cb212e7dc2e80020102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be494c0d72f06310000283c703e566c6164696d6972206861732066756e20706f7374696e67206e6577733c62723e3c2f703e00e807d461002102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be40046304402204aa9ab0a3e78524441609dfd9c0e028de0d9016a8d28fd54c3b55cbc2674db2002206e35dd4118449252967fa263e7e923015e39b168ae622d8625ce8f3051ef906b", "0141f58714ed013b1ee16e06dbe28b47f738ec159704269975a5dcbe0752138322010102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52f7dfcfaa06054e00208c86eede87a561553c5672ada25cc0724938d7134de5f8e81040a3cf177480a21e7b22426f6479223a2266666666666666666666666666666666666666227d00d461f2b692b0ace797a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce520046304402203cb2f4e486caf8bbc674781b976cb71f779da0cbe4d83b823eeaec1687e44c7f02200f78335ba3d4fee1625162ae71e224f84ca6e920c9989e25ad1f042dc88ab991", "0182d2f0b361e4f00161f81247bb27c173065a315b37c1b2a30dbb45b167c448e3000102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52fbddcfaa06054100207eba2b76e2b1851070f2740e25c1c70c64a228e226f0dff5734f19d3baca8224117b22426f6479223a226c617777776c227d00d46180df88abc5e797a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce5200473045022100bdd3b1348c8709c385a5ebbb7fda3f6ebd8fc368c8e95e2f7cdc1b0f6d00b4b002201e355fe9b04acd192b3e552eac667b7697d7c9913286ab8091b718a37e542308", "0147f91c232d725f915493355620709dd759ff8620452d2b145a17d6950cca4b38010102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52dd80f8fa0506e71d000b43727970746f5472756d702f3c703e4920414d20544845204245535420504552534f4e204f4e205448495320504c4154464f524d2121213c2f703ea31d646174613a696d6167652f6a7065673b6261736536342c2f396a2f327743454141674742676347425167484277634a4351674b4442514e4441734c44426b534577385548526f6648683061484277674a43346e49434973497877634b4463704c4441784e44513048796335505467795043347a4e44494243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f4141424549414751415a414d4249674143455145444551482f7841476941414142425145424151454241514141414141414141414141514944424155474277674a436773514141494241774d4342414d4642515145414141426651454341774145455155534954464242684e525951636963525179675a476843434e4373634556557448774a444e69636f494a4368595847426b614a53596e4b436b714e4455324e7a67354f6b4e4552555a4853456c4b55315256566c64595756706a5a47566d5a326870616e4e3064585a3365486c3667345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f716171797337533174726534756272437738544678736649796372533039545631746659326472683475506b3565626e364f6e7138664c7a39505832392f6a352b674541417745424151454241514542415141414141414141414543417751464267634943516f4c455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f414f692b4d5069582b7a644c743947743550333932664d6d414f4349683042396966304272784e726f7941687052763646683058324662587846316c6462386258313270486c4b5242486c7543715a476678362f6a57426257356c797952672b2b44696f6c4b37495553534f4568774e3252366e76567943324c6b63452f30716531302b5238626c7a5856615a6f6a4f46496a7839617a647a6f6843356957326d747838754165685061744b4c5357786e49493954585677364b45786e6731502f5a36727755552f685335724779676a6a704e4f38735a3446514e45454a36676a314f525858543251412b377a37566961685971716c6c47574866464371436c5254324d706f784b426a747a7a3142714a3430427943446a723378534e3573545a49497765445353346c2b5948424a344f4b3035726e504b6d346b7355757a47472b5850466574664432627a39456b5134506c79484848596976474a495a5558666a497a31577657506867386e3247354439474b6b66686b56634c6d556a3044416f7750536c78526a337261784a386777774d376c705474424f5170417961362f51744d2b314141634c363434726a596c437a446447514d392b4b377a5362703472634c4777585047514f61775453315a70474c62736a6654547257435256484c66537569302b4f4e59686852396177724333553757596b74366b354a72637470466a35504f4f657459637a6b7a73355646574e456846475770725252794a77617a376a5737464d52794d413550417752556158316934334c6468474842556d6d78786148584b4144672f685652376353416738357156376d4f515a527732546747677a4972424e347a744a7a6d736d624c597a4a64475275617248536f30626851635666625537627a6d426c36635a3756473135437a426b6c556a317a546a6447636d6e6f7a4f314b3152624d7156414937676331315077352f63466f54314959342f4556792b757a374c62654d594a4177666575693847466c31477763634b386367505074782f4c394b366f75364f476f724d394f41346f785551626755753456707a6f7a3557664e77303570775a376b69516c69547741525776706c7447484730644f4d314e66326b73576e736c735173684f30635a4f54314e50302b4d326b5563552f456f476135334b3650516c54355a58527078735647464f43505563556b75732f5a6c45666b504c4d352b564931334d7839753334303677635453685736567269326a57514d6971472f7659352f4f736c4b7a4b6b726e44333133346775575a5234595a6b50386254416e394b7a787032704759724e617952385a4731695150782f2f565870666b3344483547544872564339745a465a53386d543246564b55626145786a4b2b707a6d673239306c3669547a7533505139716c3854527a77334551686b6b546370425a6131724b46557651527a67302f57596c6c6e55594848576f586331656d68357264586a3238684d6e32356f6a3064454a42476670697569304856744e6d5a454e772b39683871797274592f6e5853573865457973616e334e52582b6d52586b5369346843674d47444b65515256707857706b34747655794e64496c736d57507363382f57756c30435a597276535931497a6c546a366a4e595637624567526a6c5467416a767a577034657335726a58496d4f504a74634e7a2f75344662306c7a5051354b2f75725539534536592b384b504f542b2b4b797830706136507178792f57456563724c495651424e3338594f4f6e4743507a724d6c6b616443374169524a43507771696e695951333777334a327779536c30596475324b747665326c7a644d4c5a6965686359774161382f37586b6575704b554c6b39764f384c3548424865756a7337337a6f3848466338792f506b437230475938484f5070536c7558485648524356554755775437316d617065724568643247515038414f4b55546c59386a705748715564334f4775493033694a6779702f65494e536d56796d70704a6b6e4a6c5a434f6334702b74544d6b443341552f4a676668584b32666950574c46705a6275785a494750794564562b6f7039783473754c6f78775232627949342b647359412f787254545968706e57576b6d4978774f6c4f7535564b383167615663797046484849434758672f30713764796c6b3436314679334571336c776937587a674b635a4e645a3459516d796c6c4947576647665841726c466745694a752f7668695055597276394e736d744e4e696a503373626a78334e642b4456356568354759797444314c426b7765744a357676556252746d6b387331363268345632654f7034664f735274634c7749474750553449712f64774c6150357139536356706174716b58674f3264627a5a4f4a326279496c487a6e312f41565731574b66374350744d4a696d43493749653251442f4931343034636b667a506f4d50506d6b794b326e38357335366442577a626a7a4f505431726c624363724c744a344a7270724f5651334c59394b354a486f775a64534d2b5946623776657035486941324c6a36656c56376f476359686b326e47633436566b7a3241747a766d315737436e37786a566344394b5564536d7a556131696c5678685366516e72564e374f4b493543716655656c557862366249344b2b495855676447565254477462555a4d5775795353486b624556686e2f50765776497262695a63614e4d68312b68715a347949386b6331485932386f634a4c634c4b765864747766787135644f7149514f6e63316c31427651302f444f6c513330725454676c6263676852305a7565746468494d566b65456f44466f6f6d624f626879347a2f6448412f6c57784a3372317350486c696a352f4679353576794b6a45687162754e4f6637314e72724f4b783832572b7233506a4c346a366663366951566e76496b57503841685350654d4b4b392f77444847682b666172714d532f63587935675037765a7677503647766d5051727a2b7a7466734c7739494c694f512f514d43612b306c45647842304478534c30504949492f77727a313730476d656e666b714a6f2b635a6f7a62546e726b486b56705756336e44416a4831726538622b465a4e4b757674454d5a617a632f492f58596637702f6f61344b5a70725a795559685431466356534469657054714a366f3941745a49356b2b384433344f4b5357304374754c6b44766e30726837445570625a3978636b64733130796131485043724e4b75635949724e4c716271535a6f2f32626179414f59304f6535417173326c787874694a4651483046527071614b7679754d65745176726c75736d412b653541717655624c61774e4143533350765459466c314f2f68735973683558326e483849376e38426d734b2b3851504e4b7363436b353448756670586f76677a773950706b4c582b6f4c69396d58416a50574a66512b35372b6c5852703838374935635458564f462b7031634d53515178777872694f4e51716a3041706b687a557537696f47363136305565424a3349474850536b775054394b632f7742377152394b622b4a72557a506a3448357858324e34467535623777506f74784f515a4874493978486641782f53766a67666648317237412b48502f4a5074442f3639457267702f437a30716e78493653356769757264345a34316b6963595a5747515258687669765372585464637562573356764b424741787a6a4e65374e3072786678332f77416a52646638422f6b4b552f684e6144393678773030616f53464655704352304a4658376e37782f4371456c656655305a337732497a4c4a356530534d4239616662707563416b6b66576f6a39327072582f41466c5a377330364550695741516547594c794a3357563777786b687363424e772f57765a506866346931447846345557665558575361462f4b4567474377413674366d76495046582f496c327638413245472f394669765376676e2f774169644c2f3138742f4956362b4753533037486a5976586675656c476f32342f4b704433706a663072704f4568666871626d6e5038416570745751662f5ae807d461002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce520047304502210099eeee29c1a51b4de0b8bfe42977dc95d76c168e75df83f4faa401f37743bc3102201f6d4f9239754fa58d1e67f2db6f86cf0977b78e8dc6dc24449e4ffaec34d2cd", "0176af9a4ea8a9783249fbad57743ee9f12ff10e5a02bac7e40d397162b69549a9000102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52c8fef7fa05055a0000497b22426f6479223a225c7530303363705c753030336554686973206973206120706f73742066726f6d207468652043727970746f5472756d705c75303033632f705c7530303365227df403d461d0e7f3a2a2fc97a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52004630440220151fb0af92ac4db9b3c0fcc35306df1c0f4e00c314802f8f7080b86ed6199f9502203c92d4e0ac33ee4981d1e8e1abb2dafea2e7cba4dccedc1d3cffaf919c5ccaa5", "014b161a70f82c0853ecbd42bf934e139eac1857675578f112c2ff3aa6ec5d9812020102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52f581af5f06500000473c703e4920414d20544845204245535420504552534f4e204f4e205448495320504c4154464f524d21212120414e4f544845522050524f46494c4520555044415445213c2f703e00e807d461002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce5200473045022100a5714789c19fbba22d8f5845ef8ffd53c48dd41995e283753ba0c67744b73cd2022026b806c5b756da02cbde6480888e9d88aeb83e6adf161cd2b0b21b23575f9454", "0147dc3c620db733240a309c01f501d0d01c21e7a5f795308dccc100b133869ec1000102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52fafdae5f057c00006b7b22426f6479223a225c753030336368315c7530303365414e4f5448455220504f53545c75303033632f68315c75303033655c75303033636469765c7530303365486f775c75303032362333393b732074686973206f6e653f5c75303033632f6469765c7530303365227df403d461ea95c6f8d98198a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce520046304402206d6335b5d7ecba50626411695f17955e523ea0d8ebec75c076aadbc95d6c439202203b3365c7c6ec5ab7565e64cdeae8f2b0a4932b7a1906339d55fd88d1db9afb9a", "013e42215a120a6e9d4848117f5829a2c4d9f692360fd14b78daea483a72d142dc000102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52f9fbae5f054600203e42215a120a6e9d4848117f5829a2c4d9f692360fd14b78daea483a72d142dc167b22426f6479223a226666666666666666666666227d00d461a682a4f9f18198a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce520046304402203ae6599a5b81e0c0a85cc5efbf008ed1e78a82c6152b2ad9127e10952faecbdd0220211475a8384c52d7a04781f7d704835e6ed8543a466551dd7c39187cecb714a0", } SeedBalances = []*BitCloutOutput{}/* 482 elements not displayed */ TestSeedBalances = []*BitCloutOutput{ { PublicKey: MustBase58CheckDecode("BC1YLjBxKjyopwRqZQkZaQKZbzq1peYv1F8rU2aNBQFe8eJR2eXR8B9"), AmountNanos: uint64(2000000 * NanosPerUnit), }, } // These Bitcoin transactions were goofed up by the original node UI, but the // engineers only realized after a lot of work was built on top of them. Thus we // forgive them. ForgivenBitcoinTransactions = map[string]bool{ "bfe30adc5c6c08aff09865e73830b89fa986d9f56f09f4415fabfbfef37bee10": true, "6d7159d63c97dae0ec653732d51eafd210bca56a33c4fc8c0dccd6cb5b4b0f90": true, "936c36162fdba0a10b8eebe8dd57bd36c59e5bd538d54d73ab24a76851c866e7": true, "b9200a85f7ab35d5a156f816e9825295ffd1a1e5717c38ac9c93851e7d14a0de": true, "37ecf332632c1acf6d96a3600eefc956b3f72dec71288da019db28fd718dd1e3": true, "804d0642b3871699fd472c0f73e7c718bce6c4f01ce8cf8a3321cf9a4ab3af49": true, "dcb647af197253c8ce1773a1c6ea4efb1c23a38e88e10799ac8cc58b122b96cc": true, "9153c91e734e48a93f2339a193d60fa48cc0dfb22b35f84af1d7e7355d4bbc9e": true, "af7f7659fb4c77d4c76ac026423bca20f291967d8dc20e91bf0c2515177aa99a": true, "454f85c1ba5df10ca7262b635ea23a50a49c349a7fb345b1088475df07f9ef2f": true, "73a63beb2e454e47e57fb6d0b680d988f8bb688e013deeba48eec21027d1773d": true, "369674aea1ac5702ea815e901e78089ee34e1e9d51734c94a624e91a2751d38d": true, "73e78ed21ac8fc631eb91f0a1b838a42fd1f72f7973a9516a42fc0e45ba09e58": true, "8bb99af443dd6879228a6f6f097e730efa0cbc62e9e89c65f40b1a9e2deba3d0": true, "ca52836e76720e0e81c7d2935cb9b01282254a00d8f5baebae0828b351461dfd": true, "ed79d6a043e8ac3eaf6ea2328e086205a537ff1273a30197074335ebb725bf67": true, "70bd88c78ffd9da21f63e39224d3ec024dd8d342cab61f187db104e2548a3076": true, "c2e7b1e9b5a534799c1ba925c21fa4683bb7a44ede40c6ab9b77e70fc261c8db": true, "4a4d01e56d108d97bc07817faa6373df9882107ec4a0ccafcc2e115a069a6008": true, "f321ae356faee722ff1f1672dad11004dffe87562a9edc60719eac9e4796e2d7": true, "601dc5680b20a2d10937427b201c6cad61d670e2c22796f2c36e5c347e496193": true, "cb302a9990108896a470a3c34e7d96e404b66fcb9526e969211f707d492cd9f7": true, "f82a4a05ca7da9ab26fe1e7321105d0d523acf3a4187e62d5572fe5886390203": true, "40e596de0e51df1e7bbad675e24d50ab3e16e63e91a19f1e6783cf7ab25c3fee": true, "934d5a06437b39a38069a90017c08dbb0dec8578948c89bf59468479efca5d9e": true, "e70fa2153b013e800f523812f857781660801c595edb95badcf86d92aa41f7c6": true, "e2ac93ad950a415f09d403dc2003b8d9b132a9b11de20b073c85a91333a3b1d5": true, "3078b51132bac78c035c5bb8e695944bed1a67f532264132d05497168a624a02": true, "e628a3964b42e19aa519f027598b540c34d55474829d736373b0e63c9b91a6b8": true, "539122319f7df2d889bb60a3efcdc4e7b7ee99ff9b65f8cfb321b32f35aa99a2": true, "6660d8384247a251c775a764a0f92b3c23caf8ad478b750416ae0a066dc85f46": true, "3d527f2f00593656d22fb0c9cc5adafff4d18d80216894285a89e16c862bbb75": true, "302cb3d71171c140a48d0ba1e959c7e20635e299732dd5bc22f4d4300f7638fa": true, "86a347c797ad1737181fb8399eb38c5afd2ee844fcb5bf218ee185508fd05610": true, "a35b15418cc0e242d6519a393a6fb02f9be8146c9cb81c8ae546fd5fdc243b64": true, "bea14e4e9c79bba458276d59ef44a1b9812e0dd9178cedf1fa4f5ff95be5a0ba": true, "86b8ae03587d3bdf453e62d392ae97975e7b870f0eaf9df5c27d0d35fbe40fd5": true, "710f6fd784e1f56e4d7491b8211d9000d59b3a67ea3b28f8d2428eb6ba4ac5c5": true, "d31f6ef25ddc7b57c593ccccf0e3f6c1d90038a6e5c6f774e55c308112de9f62": true, "347abfa07c259ae5346018ad306e5839ea876c3843cba8a09c299adb9aa2d9bc": true, "591c822b3b36d52e2fc9b1a51c9c1b5773f6eb92ba084ee4f94f4324c805f841": true, "db8c9762df9b073ea96d664302c728a5301e956e93a97083b4a51f40d35c4bd1": true, "191c0c6574a281cc859d1e72333c5d40fc3fbeecc81d8b83ddf20071b09998fa": true, "e319fdd87ecb625ea27a7baac61df4f70a9b83316d099ee323dc089e1d816ea7": true, "9fae0066e5835b214c0f46b9067c7cafecfa10e9722ad1949a222d73e09a0a47": true, "e3a074292538428d9e53c26ab682529b6a88318618e4e20d38afb55b1d0be3f6": true, "146cfea55cd39440a87771235347d79a4b0368c90bbddb5c8fab163de79be8c2": true, "c3f8be40a5d91f10db697508e06f40ea938fec3b88c4393b06c278280e5a665e": true, "819ff70052a9a577d63be71914a49bc84822b656e0c53479f05422c736771731": true, "33a015b1c0f27dacafd6aaffdb46752f71d1be7e5fb2ab607b71825949729fe7": true, "284a7764c18d5b4cb6a32c4389980611ddda26a3615224e41cadf5788540add0": true, "9f104f851b10cea3642f1182f2a09a813018e66f4456e190c1667a79080ded16": true, "611bf307520bf2382878fc61ce85c47b53faf9ccaee8ae7e2b4376df4f7d4bdf": true, "21005ab05bddd5069ca898763f6f54932679fbf939395af1042316bbb2744296": true, "795131dbb2915066089768818333aa3b67e6e6b16e319d6ed35e23d041b6b9c3": true, "b55ca83fa3a68e4188fdb49299ace1f15bc45d3d25885427a5cf6644d29f4ef9": true, "33f1cec9bdf3f2b945a37c872fe856f92395eec9a6dcbc526f2aa8d84176660b": true, "a1048dfad8acbdf24ab76edc90bfa3ae8761617c403713afa13a1bc19b778383": true, "2ac9ebbf12b0b406fa66cf2d4ed96f0c15625628766c176ae645eb9c2da2a977": true, "cdb965e165c2892834046e046c52e7199437156f1e5ced7fabfb268532805a81": true, "e41b9b4b7ca84cc9a7db094889eaffd27a99d5c4a7217e9b166109e1a2bdc8ea": true, "40a4154167edc9c3b39a2f09358da9a4b212760ddb801b011a40c158ff95517a": true, "209a75fd03783bdfa50d0204cddc8982a2301fcc35847c893b4f5586066e94ad": true, "58d9ef7545d462d5dca9620d54ad9b3f44c7102006239fae53b376a22a957ccd": true, "14d58d45e767d21682e649a1a2d8a9495197f1993281f82f87efff02c41d7497": true, "310f9997b43e627416ae0c9aa91338a822e61741f6932a6df8f80664fa806a82": true, "474b1b690b9e3e4c9de76bae3a9e21ec9ff8419a861b80b06dccd82ba95dbb77": true, "62942d8bb60901e1f4b73b0ae8c6a4c87186df9038cc8ef9b1e7b4abf78e9b64": true, "34a72c22b306b8b363ea35634530aa3af7381e2f7a67fe84a7100596c8e025c1": true, "5d73eb5f2aec65d372be13674658fa4bffd2de87a51eef9756378a226a3ad9e3": true, "b7dadf176a93e2a5da8263cc063e7b2370215b697bfd63a3cb1a956588b23c57": true, "6bedd82ce48017829f9ebfa5ac3dbc3fb5998bd6c2323faa0990e9daf7e0148a": true, "b765fdffb2d69380fd4357f87e9861f13755f062cedda1afa9dcc0b72c2a781d": true, "a6d96a22a56843e4df08489d45c2a9061d42d869642d08db32219883e06e9ad4": true, "c8e202fed8f725fb2ef76144208dcd06e76626019eb0c7d6fc827cae3792a848": true, } NukedBitcoinTransactions = map[string]bool{} // In early blocks there was a bug that allowed users to claim usernames that // weren't actually available. This map defines exceptions for these cases that // assign a new username to the profile. It maps transaction hashes to new // usernames. ForgivenProfileUsernameClaims = map[BlockHash]string{ *mustDecodeHexBlockHash("1f30c115192d72aa01149f08879db14158e66d859c1bd3bee3a2127cbd6f89fd"): "_nbatopshot", *mustDecodeHexBlockHash("8fe4f1ec5e5c53d610be773aa8e45680a3d7a55abf29aaab4e9ce2482e06c994"): "__nbatopshot", *mustDecodeHexBlockHash("3337781344dd5005541d028e8605bbc0851219d70b28d86a7f352877f3a1fde5"): "___nbatopshot", *mustDecodeHexBlockHash("5f52811f80c73764d887d7f82c6c233bb11da00a77dff11a85f7be851bd5745b"): "____nbatopshot", *mustDecodeHexBlockHash("02a3a9e28622b59ee59148847814deedb41b160c1edb5100b6964909351b4c04"): "_JulSwap", } )
var ( NaturalLogOfTwo = BigFloatLog(NewFloat().SetUint64(2)) DeflationBombBlockRewardAdjustmentBlockHeight = uint32(32060) MiningSupplyIntervals = []*MiningSupplyIntervalStart{ { StartBlockHeight: 0, BlockRewardNanos: 1 * NanosPerUnit, }, { StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight, BlockRewardNanos: NanosPerUnit * 3 / 4, }, { StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight + BlocksPerDay, BlockRewardNanos: NanosPerUnit / 2, }, { StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight + 2*BlocksPerDay, BlockRewardNanos: NanosPerUnit / 4, }, { StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight + 3*BlocksPerDay, BlockRewardNanos: NanosPerUnit / 8, }, { StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight + 4*BlocksPerDay, BlockRewardNanos: NanosPerUnit / 10, }, { StartBlockHeight: 15 * BlocksPerYear, BlockRewardNanos: NanosPerUnit / 20, }, { StartBlockHeight: 32 * BlocksPerYear, BlockRewardNanos: 0, }, } // This is used for various calculations but can be updated on the fly with a // special transaction type in the event that the Bitcoin price fluctuates // significantly. We make this a var rather than a const so that tests can // change the value. InitialUSDCentsPerBitcoinExchangeRate = uint64(3000000) )
var BitCloutMainnetParams = BitCloutParams{ NetworkType: NetworkType_MAINNET, ProtocolVersion: 1, MinProtocolVersion: 1, UserAgent: "Architect", DNSSeeds: []string{ "bitclout.coinbase.com", "bitclout.gemini.com", "bitclout.kraken.com", "bitclout.bitstamp.com", "bitclout.bitfinex.com", "bitclout.binance.com", "bitclout.hbg.com", "bitclout.okex.com", "bitclout.bithumb.com", "bitclout.upbit.com", }, DNSSeedGenerators: [][]string{ { "bitclout-seed-", ".io", }, }, GenesisBlock: &GenesisBlock, GenesisBlockHashHex: GenesisBlockHashHex, MinDifficultyTargetHex: "000001FFFF000000000000000000000000000000000000000000000000000000", MinChainWorkHex: "000000000000000000000000000000000000000000000000006314f9a85a949b", MaxTipAge: 24 * time.Hour, BitcoinDNSSeeds: []string{ "seed.bitcoin.sipa.be", "dnsseed.bluematt.me", "dnsseed.bitcoin.dashjr.org", "seed.bitcoinstats.com", "seed.bitnodes.io", "seed.bitcoin.jonasschnelli.ch", "seed.btc.petertodd.org", "seed.bitcoin.sprovoost.nl", "dnsseed.emzy.de", }, BitcoinMinChainWorkHex: "000000000000000000000000000000000000000007e99d77f246db819c3dfa96", BitcoinDefaultPort: "8333", BitcoinBtcdParams: &chaincfg.MainNetParams, BitcoinProtocolVersion: 70013, BitcoinBlocksPerRetarget: 2016, BitcoinPowLimitBits: 0x1d00ffff, BitcoinMinDiffReductionTime: 0, BitcoinTargetTimespanSecs: 1209600, BitcoinMinRetargetTimespanSecs: 1209600 / 4, BitcoinMaxRetargetTimespanSecs: 1209600 * 4, BitcoinMaxTipAge: 4 * time.Hour, BitcoinTimeBetweenBlocks: 10 * time.Minute, BitcoinMinBurnWorkBlockss: int64(1), MinerBitcoinMinBurnWorkBlockss: int64(3), BitcoinBurnAddress: "1PuXkbwqqwzEYo9SPGyAihAge3e9Lc71b", BitcoinMaxTstampOffsetSeconds: 2 * 60 * 60, BitcoinStartBlockNode: NewBlockNode( nil, mustDecodeHexBlockHashBitcoin("000000000000000000092d577cc673bede24b6d7199ee69c67eeb46c18fc978c"), 653184, _difficultyBitsToHash(386798414), big.NewInt(0), &MsgBitCloutHeader{ TstampSecs: 1602950620, Height: 0, }, StatusBitcoinHeaderValidated, ), BitcoinExchangeFeeBasisPoints: 10, BitcoinDoubleSpendWaitSeconds: 5.0, BitCloutNanosPurchasedAtGenesis: uint64(6000000000000000), DefaultSocketPort: uint16(17000), DefaultJSONPort: uint16(17001), DialTimeout: 30 * time.Second, VersionNegotiationTimeout: 30 * time.Second, BlockRewardMaturity: time.Hour * 3, V1DifficultyAdjustmentFactor: 10, TimeBetweenBlocks: 5 * time.Minute, TimeBetweenDifficultyRetargets: 24 * time.Hour, MaxDifficultyRetargetFactor: 4, Base58PrefixPublicKey: [3]byte{0xcd, 0x14, 0x0}, Base58PrefixPrivateKey: [3]byte{0x35, 0x0, 0x0}, MaxTstampOffsetSeconds: 2 * 60 * 60, MaxBlockSizeBytes: 16000000, MinerMaxBlockSizeBytes: 2000000, MiningIterationsPerCycle: 95000, MaxUsernameLengthBytes: MaxUsernameLengthBytes, MaxUserDescriptionLengthBytes: 20000, MaxProfilePicLengthBytes: 20000, MaxProfilePicDimensions: 100, MaxPrivateMessageLengthBytes: 10000, StakeFeeBasisPoints: 10 * 100, MaxPostBodyLengthBytes: 20000, MaxPostSubLengthBytes: 140, MaxStakeMultipleBasisPoints: 10 * 100 * 100, MaxCreatorBasisPoints: 100 * 100, MaxNFTRoyaltyBasisPoints: 100 * 100, ParamUpdaterPublicKeys: ParamUpdaterPublicKeys, SeedTxns: SeedTxns, SeedBalances: SeedBalances, CreatorCoinTradeFeeBasisPoints: 1, CreatorCoinSlope: NewFloat().SetFloat64(0.003), CreatorCoinReserveRatio: NewFloat().SetFloat64(0.3333333), CreatorCoinAutoSellThresholdNanos: uint64(10), DeflationBombBlockHeight: 33783, }
BitCloutMainnetParams defines the BitClout parameters for the mainnet.
var BitCloutTestnetParams = BitCloutParams{ NetworkType: NetworkType_TESTNET, ProtocolVersion: 0, MinProtocolVersion: 0, UserAgent: "Architect", DNSSeeds: []string{ "dorsey.bitclout.com", }, DNSSeedGenerators: [][]string{}, BitcoinDNSSeeds: []string{ "testnet-seed.bitcoin.jonasschnelli.ch", "testnet-seed.bitcoin.schildbach.de", "seed.tbtc.petertodd.org", "testnet-seed.bluematt.me", "seed.testnet.bitcoin.sprovoost.nl", }, BitcoinMinChainWorkHex: "0000000000000000000000000000000000000000000000000000000000000000", BitcoinDefaultPort: "18333", BitcoinBtcdParams: &chaincfg.TestNet3Params, BitcoinProtocolVersion: 70013, BitcoinBlocksPerRetarget: 2016, BitcoinPowLimitBits: 0x1d00ffff, BitcoinMinDiffReductionTime: time.Minute * 20, BitcoinTargetTimespanSecs: 1209600, BitcoinMinRetargetTimespanSecs: 1209600 / 4, BitcoinMaxRetargetTimespanSecs: 1209600 * 4, BitcoinMaxTipAge: 4 * time.Hour, BitcoinTimeBetweenBlocks: 10 * time.Minute, BitcoinMinBurnWorkBlockss: int64(1), MinerBitcoinMinBurnWorkBlockss: int64(3), BitcoinBurnAddress: "mhziDsPWSMwUqvZkVdKY92CjesziGP3wHL", BitcoinExchangeFeeBasisPoints: 10, BitcoinDoubleSpendWaitSeconds: 5.0, BitCloutNanosPurchasedAtGenesis: uint64(6000000000000000), BitcoinMaxTstampOffsetSeconds: 2 * 60 * 60, BitcoinStartBlockNode: NewBlockNode( nil, mustDecodeHexBlockHashBitcoin("000000000000003aae8fb976056413aa1d863eb5bee381ff16c9642283b1da1a"), 1897056, _difficultyBitsToHash(424073553), big.NewInt(0), &MsgBitCloutHeader{ TstampSecs: 1607659152, Height: 0, }, StatusBitcoinHeaderValidated, ), DefaultSocketPort: uint16(18000), DefaultJSONPort: uint16(18001), DialTimeout: 30 * time.Second, VersionNegotiationTimeout: 30 * time.Second, GenesisBlock: &GenesisBlock, GenesisBlockHashHex: GenesisBlockHashHex, TimeBetweenBlocks: 1 * time.Minute, TimeBetweenDifficultyRetargets: 3 * time.Minute, MinDifficultyTargetHex: "0090000000000000000000000000000000000000000000000000000000000000", MinChainWorkHex: "0000000000000000000000000000000000000000000000000000000000000000", MaxTipAge: time.Hour * 24, MaxDifficultyRetargetFactor: 2, BlockRewardMaturity: 5 * time.Minute, V1DifficultyAdjustmentFactor: 10, MaxTstampOffsetSeconds: 2 * 60 * 60, MaxBlockSizeBytes: 1000000, MinerMaxBlockSizeBytes: 200000, Base58PrefixPublicKey: [3]byte{0x11, 0xc2, 0x0}, Base58PrefixPrivateKey: [3]byte{0x4f, 0x6, 0x1b}, MiningIterationsPerCycle: 9500, MaxUsernameLengthBytes: MaxUsernameLengthBytes, MaxUserDescriptionLengthBytes: 20000, MaxProfilePicLengthBytes: 20000, MaxProfilePicDimensions: 100, MaxPrivateMessageLengthBytes: 10000, StakeFeeBasisPoints: 5 * 100, MaxPostBodyLengthBytes: 50000, MaxPostSubLengthBytes: 140, MaxStakeMultipleBasisPoints: 10 * 100 * 100, MaxCreatorBasisPoints: 100 * 100, MaxNFTRoyaltyBasisPoints: 100 * 100, ParamUpdaterPublicKeys: ParamUpdaterPublicKeys, SeedTxns: TestSeedTxns, SeedBalances: TestSeedBalances, CreatorCoinTradeFeeBasisPoints: 1, CreatorCoinSlope: NewFloat().SetFloat64(0.003), CreatorCoinReserveRatio: NewFloat().SetFloat64(0.3333333), CreatorCoinAutoSellThresholdNanos: uint64(10), }
BitCloutTestnetParams defines the BitClout parameters for the testnet.
var (
InitialGlobalParamsEntry = GlobalParamsEntry{
USDCentsPerBitcoin: 0,
MinimumNetworkFeeNanosPerKB: 0,
CreateProfileFeeNanos: 0,
CreateNFTFeeNanos: 0,
MaxCopiesPerNFT: 0,
}
)
InitialGlobalParamsEntry to be used before ParamUpdater creates the first update.
var ( // "false" is used as a hack to indicate that an account should have a blue check mark. IsReserved = map[string]bool{}/* 14112 elements not displayed */ )
var MaxBitcoinHeadersPerMsg = uint32(2000)
MaxBitcoinHeadersPerMsg is the maximum number of headers Bitcoin allows in a getheaders response. It is used to determine whether a node has more headers to give us.
var MaxBlockRewardDataSizeBytes = 250
MaxBlockRewardDataSizeBytes is the maximum size allowed for a BLOCK_REWARD's ExtraData field.
var MaxHeadersPerMsg = uint32(2000)
MaxHeadersPerMsg is the maximum numbers allowed in a GetHeaders response.
var (
PostExtraDataConsensusKeys = [2]string{RecloutedPostHash, IsQuotedRecloutKey}
)
Defines values that may exist in a transaction's ExtraData map
Functions ¶
func Base58CheckDecode ¶
func Base58CheckDecodePrefix ¶
func Base58CheckEncode ¶
func Base58CheckEncode(input []byte, isPrivate bool, params *BitCloutParams) string
func BigFloatExp ¶
Exp returns a big.Float representation of exp(z).
func BigFloatLog ¶
Log returns the natural logarithm of x.
func BigFloatLog2 ¶
Log2 returns the binary logarithm of x. The special cases are the same as for Log.
func BigFloatPow ¶
Pow returns a big.Float representation of z**w.
func BigintToBytes ¶
func BitcoinTxnToString ¶
You can plop this into the BlockCypher decoder and it should work for you: https://live.blockcypher.com/btc/decodetx/
func BlockHashToBlockKey ¶
func BlockonomicsCheckRBF ¶
func BlocksPerDuration ¶
func BytesToBigint ¶
func CalcBlockRewardNanos ¶
CalcBlockRewardNanos computes the block reward for a given block height.
func CalcNanosToCreate ¶
func CalculateBitCloutToReturn ¶
func CalculateBitCloutToReturn( deltaCreatorCoinNanos uint64, currentCreatorCoinSupplyNanos uint64, currentBitCloutLockedNanos uint64, params *BitCloutParams) uint64
func CalculateCreatorCoinToMint ¶
func CalculateCreatorCoinToMint( bitcloutToSellNanos uint64, coinsInCirculationNanos uint64, bitcloutLockedNanos uint64, params *BitCloutParams) uint64
func CalculateCreatorCoinToMintBancor ¶
func CalculateCreatorCoinToMintBancor( deltaBitCloutNanos uint64, currentCreatorCoinSupplyNanos uint64, currentBitCloutLockedNanos uint64, params *BitCloutParams) uint64
func CalculateCreatorCoinToMintPolynomial ¶
func CalculateCreatorCoinToMintPolynomial( deltaBitCloutNanos uint64, currentCreatorCoinSupplyNanos uint64, params *BitCloutParams) uint64
func CheckTransactionSanity ¶
func CheckTransactionSanity(txn *MsgBitCloutTxn) error
func ComputeKeysFromSeed ¶
func ComputeKeysFromSeed(seedBytes []byte, index uint32, params *BitCloutParams) (_pubKey *btcec.PublicKey, _privKey *btcec.PrivateKey, _btcAddress string, _err error)
func ComputeMerkleRoot ¶
func ComputeMerkleRoot(txns []*MsgBitCloutTxn) (_merkle *BlockHash, _txHashes []*BlockHash, _err error)
func CreateBitcoinSpendTransaction ¶
func CreateBitcoinSpendTransaction( spendAmountSatoshis uint64, feeRateSatoshisPerKB uint64, pubKey *btcec.PublicKey, recipientAddrString string, params *BitCloutParams, utxoSource func(addr string, params *BitCloutParams) ([]*BitcoinUtxo, error)) (_txn *wire.MsgTx, _totalInput uint64, _fee uint64, _unsignedHashes []string, _err error)
func CreateUnsignedBitcoinSpendTransaction ¶
func CreateUnsignedBitcoinSpendTransaction( spendAmountSatoshis uint64, feeRateSatoshisPerKB uint64, spendAddrString string, recipientAddrString string, params *BitCloutParams, utxoSource func(addr string, params *BitCloutParams) ([]*BitcoinUtxo, error)) ( _txn *wire.MsgTx, _totalInput uint64, _fee uint64, _err error)
func DBDeleteCreatorCoinBalanceEntryMappings ¶
func DBDeleteCreatorCoinBalanceEntryMappings( handle *badger.DB, hodlerPKID *PKID, creatorPKID *PKID, params *BitCloutParams) error
func DBDeleteCreatorCoinBalanceEntryMappingsWithTxn ¶
func DBDeleteCreatorCoinBalanceEntryMappingsWithTxn( txn *badger.Txn, hodlerPKID *PKID, creatorPKID *PKID, params *BitCloutParams) error
func DBDeleteNFTBidMappings ¶
func DBDeleteNFTMappings ¶
func DBDeletePKIDMappingsWithTxn ¶
func DBDeletePKIDMappingsWithTxn( txn *badger.Txn, publicKey []byte, params *BitCloutParams) error
func DBDeletePostEntryMappings ¶
func DBDeletePostEntryMappings( handle *badger.DB, postHash *BlockHash, params *BitCloutParams) error
func DBDeletePostEntryMappingsWithTxn ¶
func DBDeletePostEntryMappingsWithTxn( txn *badger.Txn, postHash *BlockHash, params *BitCloutParams) error
func DBDeleteProfileEntryMappings ¶
func DBDeleteProfileEntryMappings( handle *badger.DB, pkid *PKID, params *BitCloutParams) error
func DBDeleteProfileEntryMappingsWithTxn ¶
func DBDeleteProfileEntryMappingsWithTxn( txn *badger.Txn, pkid *PKID, params *BitCloutParams) error
func DBGetAcceptedNFTBidEntriesByPostHashSerialNumber ¶
func DBGetAcceptedNFTBidEntriesByPostHashSerialNumber(db *badger.DB, postHash *BlockHash, serialNumber uint64) *[]*NFTBidEntry
func DBGetAcceptedNFTBidEntriesByPostHashSerialNumberWithTxn ¶
func DBGetAcceptedNFTBidEntriesByPostHashSerialNumberWithTxn( txn *badger.Txn, postHash *BlockHash, serialNumber uint64) *[]*NFTBidEntry
func DBGetAllPostsAndCommentsForPublicKeyOrderedByTimestamp ¶
func DBGetAllPostsAndCommentsForPublicKeyOrderedByTimestamp( handle *badger.DB, publicKey []byte, fetchEntries bool, minTimestampNanos uint64, maxTimestampNanos uint64) ( _tstamps []uint64, _postAndCommentHashes []*BlockHash, _postAndCommentEntries []*PostEntry, _err error)
Specifying minTimestampNanos gives you all posts after minTimestampNanos Pass minTimestampNanos = 0 && maxTimestampNanos = 0 if you want all posts Setting maxTimestampNanos = 0, will default maxTimestampNanos to the current time.
func DBGetAllPostsByTstamp ¶
func DBGetAllPostsByTstamp(handle *badger.DB, fetchEntries bool) ( _tstamps []uint64, _postHashes []*BlockHash, _postEntries []*PostEntry, _err error)
DBGetAllPostsByTstamp returns all the posts in the db with the newest posts first.
TODO(performance): This currently fetches all posts. We should implement some kind of pagination instead though.
func DBGetAllProfilesByCoinValue ¶
func DBGetAllProfilesByCoinValue(handle *badger.DB, fetchEntries bool) ( _lockedBitCloutNanos []uint64, _profilePublicKeys []*PKID, _profileEntries []*ProfileEntry, _err error)
DBGetAllProfilesByCoinValue returns all the profiles in the db with the highest coin values first.
TODO(performance): This currently fetches all profiles. We should implement some kind of pagination instead though.
func DBGetCommentPostHashesForParentStakeID ¶
func DBGetCommentPostHashesForParentStakeID( handle *badger.DB, stakeIDXXX []byte, fetchEntries bool) ( _tstamps []uint64, _commentPostHashes []*BlockHash, _commentPostEntryes []*PostEntry, _err error)
DBGetCommentPostHashesForParentStakeID returns all the comments, which are indexed by their stake ID rather than by their timestamp.
TODO(performance): This currently fetches all comments. We should implement something where we only get the comments for particular posts instead.
func DBGetPaginatedKeysAndValuesForPrefixWithTxn ¶
func DBGetPaginatedKeysAndValuesForPrefixWithTxn( dbTxn *badger.Txn, startPrefix []byte, validForPrefix []byte, maxKeyLen int, numToFetch int, reverse bool, fetchValues bool) ( _keysFound [][]byte, _valsFound [][]byte, _err error)
startPrefix specifies a point in the DB at which the iteration should start. It doesn't have to map to an exact key because badger will just binary search and start right before/after that location.
validForPrefix helps determine when the iteration should stop. The iteration stops at the last entry that has this prefix. Setting it to an empty byte string would cause the iteration to seek to the beginning of the db, whereas setting it to one of the _Prefix bytes would cause the iteration to stop at the last entry with that prefix.
maxKeyLen is required so we can pad the key with FF in the case the user wants to seek backwards. This is required due to a quirk of badgerdb. It is ignored if reverse == false.
numToFetch specifies the number of entries to fetch. If set to zero then it fetches all entries that match the validForPrefix passed in.
func DBGetPublicKeyForPKID ¶
func DBPutAcceptedNFTBidEntriesMapping ¶
func DBPutAcceptedNFTBidEntriesMapping(handle *badger.DB, nftKey NFTKey, nftBidEntries *[]*NFTBidEntry) error
func DBPutAcceptedNFTBidEntriesMappingWithTxn ¶
func DBPutAcceptedNFTBidEntriesMappingWithTxn(txn *badger.Txn, nftKey NFTKey, nftBidEntries *[]*NFTBidEntry) error
func DBPutCreatorCoinBalanceEntryMappings ¶
func DBPutCreatorCoinBalanceEntryMappings( handle *badger.DB, balanceEntry *BalanceEntry, params *BitCloutParams) error
func DBPutCreatorCoinBalanceEntryMappingsWithTxn ¶
func DBPutCreatorCoinBalanceEntryMappingsWithTxn( txn *badger.Txn, balanceEntry *BalanceEntry, params *BitCloutParams) error
func DBPutNFTBidEntryMappings ¶
func DBPutNFTBidEntryMappings(handle *badger.DB, nftEntry *NFTBidEntry) error
func DBPutNFTBidEntryMappingsWithTxn ¶
func DBPutNFTBidEntryMappingsWithTxn(txn *badger.Txn, nftBidEntry *NFTBidEntry) error
func DBPutNFTEntryMappings ¶
func DBPutPKIDMappingsWithTxn ¶
func DBPutPKIDMappingsWithTxn( txn *badger.Txn, publicKey []byte, pkidEntry *PKIDEntry, params *BitCloutParams) error
func DBPutPostEntryMappings ¶
func DBPutPostEntryMappings(handle *badger.DB, postEntry *PostEntry, params *BitCloutParams) error
func DBPutPostEntryMappingsWithTxn ¶
func DBPutPostEntryMappingsWithTxn( txn *badger.Txn, postEntry *PostEntry, params *BitCloutParams) error
func DBPutProfileEntryMappings ¶
func DBPutProfileEntryMappings( handle *badger.DB, profileEntry *ProfileEntry, pkid *PKID, params *BitCloutParams) error
func DBPutProfileEntryMappingsWithTxn ¶
func DBPutProfileEntryMappingsWithTxn( txn *badger.Txn, profileEntry *ProfileEntry, pkid *PKID, params *BitCloutParams) error
func DbBufForUtxoKey ¶
func DbDeleteAllMempoolTxns ¶
func DbDeleteAllMempoolTxns(handle *badger.DB) error
func DbDeleteAllMempoolTxnsWithTxn ¶
func DbDeleteAllMempoolTxnsWithTxn(txn *badger.Txn) error
func DbDeleteDiamondMappings ¶
func DbDeleteDiamondMappings(handle *badger.DB, diamondEntry *DiamondEntry) error
func DbDeleteDiamondMappingsWithTxn ¶
func DbDeleteDiamondMappingsWithTxn(txn *badger.Txn, diamondEntry *DiamondEntry) error
func DbDeleteFollowMappings ¶
func DbDeleteFollowMappingsWithTxn ¶
Note this deletes the follow for the follower *and* followed since a mapping should exist for each.
func DbDeleteLikeMappings ¶
func DbDeleteLikeMappingsWithTxn ¶
func DbDeleteLikeMappingsWithTxn( txn *badger.Txn, userPubKey []byte, likedPostHash BlockHash) error
Note this deletes the like for the user *and* the liked post since a mapping should exist for each.
func DbDeleteMempoolTxn ¶
func DbDeleteMempoolTxnKey ¶
func DbDeleteMessageEntryMappingsWithTxn ¶
func DbDeleteMessageEntryMappingsWithTxn( txn *badger.Txn, publicKey []byte, tstampNanos uint64) error
Note this deletes the message for the sender *and* receiver since a mapping should exist for each.
func DbDeleteRecloutMappings ¶
func DbDeleteRecloutMappingsWithTxn ¶
func DbDeleteRecloutMappingsWithTxn( txn *badger.Txn, userPubKey []byte, recloutedPostHash BlockHash) error
Note this deletes the reclout for the user *and* the reclouted post since a mapping should exist for each.
func DbDeleteTxindexTransactionMappings ¶
func DbDeleteTxindexTransactionMappings( handle *badger.DB, txn *MsgBitCloutTxn, params *BitCloutParams) error
func DbDeleteTxindexTransactionMappingsWithTxn ¶
func DbDeleteTxindexTransactionMappingsWithTxn( dbTxn *badger.Txn, txn *MsgBitCloutTxn, params *BitCloutParams) error
func DbExistsBitcoinBurnTxID ¶
func DbGetBalanceEntriesHodlingYou ¶
func DbGetBalanceEntriesHodlingYou(pkid *PKIDEntry, fetchProfiles bool, filterOutZeroBalances bool, utxoView *UtxoView) ( _entriesHodlingYou []*BalanceEntry, _profilesHodlingYou []*ProfileEntry, _err error)
DbGetBalanceEntriesHodlingYou fetchs the BalanceEntries that hodl the pkid passed in.
func DbGetBalanceEntriesYouHodl ¶
func DbGetBalanceEntriesYouHodl(pkid *PKIDEntry, fetchProfiles bool, filterOutZeroBalances bool, utxoView *UtxoView) ( _entriesYouHodl []*BalanceEntry, _profilesYouHodl []*ProfileEntry, _err error)
DbGetBalanceEntriesHodlingYou fetchs the BalanceEntries that the passed in pkid hodls.
func DbGetCreatorCoinBalanceEntriesForPubKey ¶
func DbGetCreatorCoinBalanceEntriesForPubKey( pkid *PKIDEntry, fetchProfiles bool, filterOutZeroBalances bool, utxoView *UtxoView) ( _entriesYouHodl []*BalanceEntry, _entriesThatHodlYou []*BalanceEntry, _profilesYouHodl []*ProfileEntry, _profilesThatHodlYou []*ProfileEntry, _err error)
DbGetCreatorCoinBalanceEntriesForPubKeyWithTxn finds the BalanceEntries corresponding to the public key passed in. It fetched both the entries corresponding to the profiles that *you HODL* and the entries corresponding to the profiles that *HODL you*.
func DbGetNanosPurchased ¶
func DbGetNanosPurchased(handle *badger.DB) uint64
func DbGetNanosPurchasedWithTxn ¶
func DbGetNanosPurchasedWithTxn(txn *badger.Txn) uint64
func DbGetPKIDsThatDiamondedYouMap ¶
func DbGetPKIDsThatDiamondedYouMap(handle *badger.DB, yourPKID *PKID, fetchYouDiamonded bool) ( _pkidToDiamondsMap map[PKID][]*DiamondEntry, _err error)
This function returns a map of PKIDs that gave diamonds to a list of DiamondEntrys that contain post hashes.
func DbGetPubKeysYouFollow ¶
func DbGetTxindexFullTransactionByTxID ¶
func DbGetTxindexFullTransactionByTxID( txindexDBHandle *badger.DB, blockchainDBHandle *badger.DB, txID *BlockHash) ( _txn *MsgBitCloutTxn, _txnMeta *TransactionMetadata)
DbGetTxindexFullTransactionByTxID TODO: This makes lookups inefficient when blocks are large. Shouldn't be a problem for a while, but keep an eye on it.
func DbGetUSDCentsPerBitcoinExchangeRate ¶
func DbGetUSDCentsPerBitcoinExchangeRate(handle *badger.DB) uint64
func DbGetUSDCentsPerBitcoinExchangeRateWithTxn ¶
func DbGetUSDCentsPerBitcoinExchangeRateWithTxn(txn *badger.Txn) uint64
func DbPutDiamondMappings ¶
func DbPutDiamondMappings( handle *badger.DB, diamondEntry *DiamondEntry) error
func DbPutDiamondMappingsWithTxn ¶
func DbPutDiamondMappingsWithTxn( txn *badger.Txn, diamondEntry *DiamondEntry) error
func DbPutFollowMappings ¶
func DbPutFollowMappingsWithTxn ¶
Note that this adds a mapping for the follower *and* the pub key being followed.
func DbPutGlobalParamsEntry ¶
func DbPutGlobalParamsEntry(handle *badger.DB, globalParamsEntry GlobalParamsEntry) error
func DbPutGlobalParamsEntryWithTxn ¶
func DbPutGlobalParamsEntryWithTxn(txn *badger.Txn, globalParamsEntry GlobalParamsEntry) error
func DbPutLikeMappings ¶
func DbPutLikeMappingsWithTxn ¶
Note that this adds a mapping for the user *and* the liked post.
func DbPutMempoolTxn ¶
func DbPutMempoolTxnWithTxn ¶
func DbPutMessageEntry ¶
func DbPutMessageEntry(handle *badger.DB, messageEntry *MessageEntry) error
func DbPutMessageEntryWithTxn ¶
func DbPutMessageEntryWithTxn( txn *badger.Txn, messageEntry *MessageEntry) error
Note that this adds a mapping for the sender *and* the recipient.
func DbPutNanosPurchased ¶
func DbPutRecloutMappings ¶
func DbPutRecloutMappings( handle *badger.DB, userPubKey []byte, recloutedPostHash BlockHash, recloutEntry RecloutEntry) error
func DbPutRecloutMappingsWithTxn ¶
func DbPutRecloutMappingsWithTxn( txn *badger.Txn, userPubKey []byte, recloutedPostHash BlockHash, recloutEntry RecloutEntry) error
Note that this adds a mapping for the user *and* the reclouted post.
func DbPutTxindexTip ¶
func DbPutTxindexTipWithTxn ¶
func DbPutTxindexTransaction ¶
func DbPutTxindexTransaction( handle *badger.DB, txID *BlockHash, txnMeta *TransactionMetadata) error
func DbPutTxindexTransactionMappings ¶
func DbPutTxindexTransactionMappings( handle *badger.DB, bitcloutTxn *MsgBitCloutTxn, params *BitCloutParams, txnMeta *TransactionMetadata) error
func DbPutTxindexTransactionMappingsWithTxn ¶
func DbPutTxindexTransactionMappingsWithTxn( dbTx *badger.Txn, txn *MsgBitCloutTxn, params *BitCloutParams, txnMeta *TransactionMetadata) error
func DbPutTxindexTransactionWithTxn ¶
func DbPutTxindexTransactionWithTxn( txn *badger.Txn, txID *BlockHash, txnMeta *TransactionMetadata) error
func DbTxindexTxIDKey ¶
func DecodeUint32 ¶
func DecodeUint64 ¶
func DecryptBytesWithPrivateKey ¶
func DecryptBytesWithPrivateKey(bytesToDecrypt []byte, privKey *ecdsa.PrivateKey) ([]byte, error)
func Diff ¶
func Diff(expected interface{}, actual interface{}) string
Diff returns a diff of both values as long as both are of the same type and are a struct, map, slice, array or string. Otherwise it returns an empty string.
func EncodeUint64 ¶
func EnumerateKeysForPrefix ¶
func EstimateBitcoinTxFee ¶
func ExtractBitcoinBurnTransactionsFromBitcoinBlockWithMerkleProofs ¶
func ExtractBitcoinBurnTransactionsFromBitcoinBlockWithMerkleProofs( bitcoinBlock *wire.MsgBlock, burnAddress string, params *BitCloutParams) ( _txns []*wire.MsgTx, _merkleProofs [][]*merkletree.ProofPart, _err error)
func FlushMempoolToDb ¶
func FlushMempoolToDbWithTxn ¶
func GetBadgerDbPath ¶
GetBadgerDbPath returns the path where we store the badgerdb data.
func GetBitCloutNanosDiamondLevelMapAtBlockHeight ¶
Each diamond level is worth a fixed amount of BitClout. These amounts can be changed in the future by simply returning a new set of values after a particular block height.
func GetBlockIndex ¶
func GetCreatorCoinNanosForDiamondLevelAtBlockHeight ¶
func GetCreatorCoinNanosForDiamondLevelAtBlockHeight( coinsInCirculationNanos uint64, bitcloutLockedNanos uint64, diamondLevel int64, blockHeight int64, params *BitCloutParams) uint64
At a particular diamond level, a fixed amount of BitClout is converted into creator coins and then sent to a user. This function computes the amount of creator coins required for a particular level.
func GetDataDir ¶
func GetDataDir(params *BitCloutParams) string
GetDataDir gets the user data directory where we store files in a cross-platform way.
func GetReorgBlocks ¶
func GetUtxoNumEntries ¶
func GetUtxoNumEntries(handle *badger.DB) uint64
func GetUtxoNumEntriesWithTxn ¶
func GetUtxoNumEntriesWithTxn(txn *badger.Txn) uint64
func GetUtxoOperationsForBlock ¶
func GetUtxoOperationsForBlock(handle *badger.DB, blockHash *BlockHash) ([][]*UtxoOperation, error)
func GetUtxoOperationsForBlockWithTxn ¶
func GetUtxoOperationsForBlockWithTxn(txn *badger.Txn, blockHash *BlockHash) ([][]*UtxoOperation, error)
func HashToBigint ¶
func HashToStakeID ¶
func HeaderSizeBytes ¶
func HeaderSizeBytes() int
func IPToNetAddr ¶
func IPToNetAddr(ipStr string, addrMgr *addrmgr.AddrManager, params *BitCloutParams) (*wire.NetAddress, error)
func InitDbWithBitCloutGenesisBlock ¶
func InitDbWithBitCloutGenesisBlock(params *BitCloutParams, handle *badger.DB) error
InitDbWithGenesisBlock initializes the database to contain only the genesis block.
func InitializeSecureMiddleware ¶
func InitializeSecureMiddleware(allowedHosts []string, isDevelopment bool, contentSecurityPolicy string) *secure.Secure
allowedHost is expected to be of the form "bitclout.com" See comments in this function for a description of these params
Note: FeaturePolicy is apparently renamed to PermissionsPolicy. Maybe we should fork secure.go and add that. https://scotthelme.co.uk/goodbye-feature-policy-and-hello-permissions-policy/
func IsBitcoinTestnet ¶
func IsBitcoinTestnet(params *BitCloutParams) bool
func IsControlMessage ¶
IsControlMessage is used by functions to determine whether a particular message is a control message. This is useful, for example, in disallowing external Peers from manipulating our node by sending control messages of their own.
func IsForgivenBitcoinTransaction ¶
func IsForgivenBitcoinTransaction(txn *MsgBitCloutTxn) bool
func IsNukedBitcoinTransaction ¶
func IsNukedBitcoinTransaction(txn *MsgBitCloutTxn) bool
func IsQuotedReclout ¶
func IsRestrictedPubKey ¶
func IsRuleError ¶
IsRuleError returns true if the error is any of the errors specified above.
func IsUnminedBitcoinExchange ¶
func IsUnminedBitcoinExchange(txnMeta *BitcoinExchangeMetadata) bool
func IsVanillaReclout ¶
Return true if postEntry is a vanilla reclout. A vanilla reclout is a post that reclouts another post, but does not have a body.
func LogDBSummarySnapshot ¶
func LogDBSummarySnapshot(db *badger.DB)
func MakeDirIfNonExistent ¶
This function attempts to make the file path provided. Returns an =errors if a parent directory in the path does not exist or another error is encountered. User permissions are set to "rwx" so that it can be manipulated. See: https://stackoverflow.com/questions/14249467/os-mkdir-and-os-mkdirall-permission-value/31151508
func MustBase58CheckDecode ¶
func PKIDToPublicKey ¶
func PkToString ¶
func PkToString(pk []byte, params *BitCloutParams) string
func PkToStringBoth ¶
func PkToStringMainnet ¶
func PkToStringTestnet ¶
func PrivToString ¶
func PrivToString(priv []byte, params *BitCloutParams) string
func PutBestHash ¶
func PutBestHashWithTxn ¶
func PutBlock ¶
func PutBlock(bitcloutBlock *MsgBitCloutBlock, handle *badger.DB) error
func PutBlockWithTxn ¶
func PutBlockWithTxn(txn *badger.Txn, bitcloutBlock *MsgBitCloutBlock) error
func PutHeightHashToNodeInfo ¶
func PutPubKeyUtxoKeyWithTxn ¶
func PutUtxoOperationsForBlockWithTxn ¶
func PutUtxoOperationsForBlockWithTxn(txn *badger.Txn, blockHash *BlockHash, utxoOpsForBlock [][]*UtxoOperation) error
func PutUvarint ¶
PutUvarint encodes a uint64 into buf and returns the number of bytes written. If the buffer is too small, PutUvarint will panic.
func PutVarint ¶
PutVarint encodes an int64 into buf and returns the number of bytes written. If the buffer is too small, PutVarint will panic.
func RandomBytes ¶
RandomBytes returns a []byte with random values.
func RandomBytesHex ¶
RandomBytesHex returns a hex string representing numBytes of entropy.
func ReadUvarint ¶
ReadUvarint reads an encoded unsigned integer from r and returns it as a uint64.
func ReadVarint ¶
ReadVarint reads an encoded signed integer from r and returns it as an int64.
func SerializeBlockNode ¶
func StartDBSummarySnapshots ¶
func StartDBSummarySnapshots(db *badger.DB)
func Uvarint ¶
Uvarint decodes a uint64 from buf and returns that value and the number of bytes read (> 0). If an error occurred, the value is 0 and the number of bytes n is <= 0 meaning:
n == 0: buf too small n < 0: value larger than 64 bits (overflow) and -n is the number of bytes read
func Varint ¶
Varint decodes an int64 from buf and returns that value and the number of bytes read (> 0). If an error occurred, the value is 0 and the number of bytes n is <= 0 with the following meaning:
n == 0: buf too small n < 0: value larger than 64 bits (overflow) and -n is the number of bytes read
func WriteMessage ¶
func WriteMessage(ww io.Writer, msg BitCloutMessage, networkType NetworkType) ([]byte, error)
WriteMessage takes an io.Writer and serializes and writes the specified message to it. Returns an error if the message is malformed or invalid for any reason. Otherwise returns the payload that was written sans the header.
Types ¶
type AcceptNFTBidMetadata ¶
type AcceptNFTBidMetadata struct { NFTPostHash *BlockHash SerialNumber uint64 BidderPKID *PKID BidAmountNanos uint64 UnlockableText []byte // When an NFT owner accepts a bid, they must specify the bidder's UTXO inputs they will lock up // as payment for the purchase. This prevents the transaction from accidentally using UTXOs // that are used by future transactions. BidderInputs []*BitCloutInput }
func (*AcceptNFTBidMetadata) FromBytes ¶
func (txnData *AcceptNFTBidMetadata) FromBytes(dataa []byte) error
func (*AcceptNFTBidMetadata) GetTxnType ¶
func (txnData *AcceptNFTBidMetadata) GetTxnType() TxnType
func (*AcceptNFTBidMetadata) New ¶
func (txnData *AcceptNFTBidMetadata) New() BitCloutTxnMetadata
type AffectedPublicKey ¶
type BalanceEntry ¶
type BalanceEntry struct { // The PKID of the HODLer. This should never change after it's set initially. HODLerPKID *PKID // The PKID of the creator. This should never change after it's set initially. CreatorPKID *PKID // How much this HODLer owns of a particular creator coin. BalanceNanos uint64 // Has the hodler purchased any amount of this user's coin HasPurchased bool // contains filtered or unexported fields }
This struct is mainly used to track a user's balance of a particular creator coin. In the database, we store it as the value in a mapping that looks as follows: <HodlerPKID, CreatorPKID> -> HODLerEntry
func DBGetCreatorCoinBalanceEntryForCreatorPKIDAndHODLerPubKeyWithTxn ¶
func DBGetCreatorCoinBalanceEntryForCreatorPKIDAndHODLerPubKeyWithTxn( txn *badger.Txn, creatorPKID *PKID, hodlerPKID *PKID) *BalanceEntry
func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDs ¶
func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDs( handle *badger.DB, hodlerPKID *PKID, creatorPKID *PKID) *BalanceEntry
func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDsWithTxn ¶
func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDsWithTxn( txn *badger.Txn, hodlerPKID *PKID, creatorPKID *PKID) *BalanceEntry
func DbGetBalanceEntry ¶
func DbGetBalanceEntry(db *badger.DB, holder *PKID, creator *PKID) *BalanceEntry
DbGetBalanceEntry returns a balance entry from the database
func DbGetHolderPKIDCreatorPKIDToBalanceEntryWithTxn ¶
func DbGetHolderPKIDCreatorPKIDToBalanceEntryWithTxn(txn *badger.Txn, holder *PKID, creator *PKID) *BalanceEntry
func GetSingleBalanceEntryFromPublicKeys ¶
func GetSingleBalanceEntryFromPublicKeys(holder []byte, creator []byte, utxoView *UtxoView) (*BalanceEntry, error)
GetSingleBalanceEntryFromPublicKeys fetchs a single balance entry of a holder's creator coin. Returns nil if the balance entry never existed.
type BalanceEntryMapKey ¶
func MakeCreatorCoinBalanceKey ¶
func MakeCreatorCoinBalanceKey(hodlerPKID *PKID, creatorPKID *PKID) BalanceEntryMapKey
func (BalanceEntryMapKey) String ¶
func (mm BalanceEntryMapKey) String() string
type BasicTransferMetadata ¶
type BasicTransferMetadata struct { }
func (*BasicTransferMetadata) FromBytes ¶
func (txnData *BasicTransferMetadata) FromBytes(data []byte) error
func (*BasicTransferMetadata) GetTxnType ¶
func (txnData *BasicTransferMetadata) GetTxnType() TxnType
func (*BasicTransferMetadata) New ¶
func (txnData *BasicTransferMetadata) New() BitCloutTxnMetadata
type BasicTransferTxindexMetadata ¶
type BasicTransferTxindexMetadata struct { TotalInputNanos uint64 TotalOutputNanos uint64 FeeNanos uint64 UtxoOpsDump string UtxoOps []*UtxoOperation }
type BitCloutBlockProducer ¶
type BitCloutBlockProducer struct {
// contains filtered or unexported fields
}
func NewBitCloutBlockProducer ¶
func NewBitCloutBlockProducer( _minBlockUpdateIntervalSeconds uint64, _maxBlockTemplatesToCache uint64, _blockProducerSeed string, _mempool *BitCloutMempool, _chain *Blockchain, _bitcoinManager *BitcoinManager, _params *BitCloutParams) (*BitCloutBlockProducer, error)
func (*BitCloutBlockProducer) AddBlockTemplate ¶
func (bitcloutBlockProducer *BitCloutBlockProducer) AddBlockTemplate(block *MsgBitCloutBlock, diffTarget *BlockHash)
func (*BitCloutBlockProducer) GetCopyOfRecentBlock ¶
func (bitcloutBlockProducer *BitCloutBlockProducer) GetCopyOfRecentBlock(blockID string) (*MsgBitCloutBlock, error)
func (*BitCloutBlockProducer) GetHeadersAndExtraDatas ¶
func (*BitCloutBlockProducer) GetLatestBlockTemplateStats ¶
func (bbp *BitCloutBlockProducer) GetLatestBlockTemplateStats() *BlockTemplateStats
func (*BitCloutBlockProducer) GetRecentBlock ¶
func (bitcloutBlockProducer *BitCloutBlockProducer) GetRecentBlock(blockHash *BlockHash) *MsgBitCloutBlock
func (*BitCloutBlockProducer) SignBlock ¶
func (bitcloutBlockProducer *BitCloutBlockProducer) SignBlock(blockFound *MsgBitCloutBlock) error
func (*BitCloutBlockProducer) Start ¶
func (bitcloutBlockProducer *BitCloutBlockProducer) Start()
func (*BitCloutBlockProducer) Stop ¶
func (bitcloutBlockProducer *BitCloutBlockProducer) Stop()
func (*BitCloutBlockProducer) UpdateLatestBlockTemplate ¶
func (bitcloutBlockProducer *BitCloutBlockProducer) UpdateLatestBlockTemplate() error
type BitCloutBodySchema ¶
Within a post, the body typically has a particular schema defined below.
type BitCloutInput ¶
type BitCloutInput UtxoKey
BitCloutInput represents a single unspent output from a previous txn. For that reason it specifies the previous txn and the index in that txn where the output appears by simply aliasing UtxoKey.
func NewBitCloutInput ¶
func NewBitCloutInput() *BitCloutInput
func (*BitCloutInput) String ¶
func (bitcloutInput *BitCloutInput) String() string
type BitCloutMempool ¶
type BitCloutMempool struct {
// contains filtered or unexported fields
}
BitCloutMempool is the core mempool object. It's what any outside service should use to aggregate transactions and mine them into blocks.
func NewBitCloutMempool ¶
func NewBitCloutMempool(_bc *Blockchain, _rateLimitFeerateNanosPerKB uint64, _minFeerateNanosPerKB uint64, _blockCypherAPIKey string, _runReadOnlyViewUpdater bool, _dataDir string, _mempoolDumpDir string) *BitCloutMempool
Create a new pool with no transactions in it.
func (*BitCloutMempool) BlockUntilReadOnlyViewRegenerated ¶
func (mp *BitCloutMempool) BlockUntilReadOnlyViewRegenerated()
func (*BitCloutMempool) CheckSpend ¶
func (mp *BitCloutMempool) CheckSpend(op UtxoKey) *MsgBitCloutTxn
func (*BitCloutMempool) Count ¶
func (mp *BitCloutMempool) Count() int
Returns an estimate of the number of txns in the mempool. This is an estimate because it looks up the number from a readOnly view, which updates at regular intervals and *not* every time a txn is added to the pool.
func (*BitCloutMempool) DumpTxnsToDB ¶
func (mp *BitCloutMempool) DumpTxnsToDB()
func (*BitCloutMempool) EvictUnminedBitcoinTransactions ¶
func (*BitCloutMempool) FetchTransaction ¶
func (mp *BitCloutMempool) FetchTransaction(txHash *BlockHash) *MempoolTx
func (*BitCloutMempool) GetAugmentedUniversalView ¶
func (mp *BitCloutMempool) GetAugmentedUniversalView() (*UtxoView, error)
GetAugmentedUniversalView creates a view that just connects everything in the mempool... TODO(performance): We should make a read-only version of the universal view that you can get from the mempool.
func (*BitCloutMempool) GetAugmentedUtxoViewForPublicKey ¶
func (mp *BitCloutMempool) GetAugmentedUtxoViewForPublicKey(pkBytes []byte, optionalTxn *MsgBitCloutTxn) (*UtxoView, error)
GetAugmentedUtxoViewForPublicKey creates a UtxoView that has connected all of the transactions that could result in utxos for the passed-in public key plus all of the dependencies of those transactions. This is useful for when we want to validate a transaction that builds on a transaction that has not yet been mined into a block. It is also useful for when we want to fetch all the unspent UtxoEntrys factoring in what's been spent by transactions in the mempool.
func (*BitCloutMempool) GetMempoolSummaryStats ¶
func (mp *BitCloutMempool) GetMempoolSummaryStats() (_summaryStatsMap map[string]*SummaryStats)
func (*BitCloutMempool) GetTransaction ¶
func (mp *BitCloutMempool) GetTransaction(txId *BlockHash) (txn *MempoolTx)
func (*BitCloutMempool) GetTransactionsOrderedByTimeAdded ¶
func (mp *BitCloutMempool) GetTransactionsOrderedByTimeAdded() (_poolTxns []*MempoolTx, _unconnectedTxns []*UnconnectedTx, _err error)
Acquires a read lock before returning the transactions.
func (*BitCloutMempool) InefficientRemoveTransaction ¶
func (mp *BitCloutMempool) InefficientRemoveTransaction(tx *MsgBitCloutTxn)
func (*BitCloutMempool) IsTransactionInPool ¶
func (mp *BitCloutMempool) IsTransactionInPool(hash *BlockHash) bool
Whether or not a txn is in the pool. Safe for concurrent access.
func (*BitCloutMempool) LoadTxnsFromDB ¶
func (mp *BitCloutMempool) LoadTxnsFromDB()
func (*BitCloutMempool) MempoolTxs ¶
func (mp *BitCloutMempool) MempoolTxs() []*MempoolTx
Returns all MempoolTxs from the readOnly view.
func (*BitCloutMempool) OpenTempDBAndDumpTxns ¶
func (mp *BitCloutMempool) OpenTempDBAndDumpTxns() error
func (*BitCloutMempool) ProcessTransaction ¶
func (mp *BitCloutMempool) ProcessTransaction(tx *MsgBitCloutTxn, allowUnconnectedTxn bool, rateLimit bool, peerID uint64, verifySignatures bool) ([]*MempoolTx, error)
ProcessTransaction is the main function called by outside services to potentially add a transaction to the mempool. It will try to add the txn to the main pool, and then try to add it as an unconnected txn if that fails.
func (*BitCloutMempool) ProcessUnconnectedTransactions ¶
func (mp *BitCloutMempool) ProcessUnconnectedTransactions(acceptedTx *MsgBitCloutTxn, rateLimit bool, verifySignatures bool) []*MempoolTx
ProcessUnconnectedTransactions tries to see if any unconnectedTxns can now be added to the pool.
func (*BitCloutMempool) PublicKeyTxnMap ¶
func (mp *BitCloutMempool) PublicKeyTxnMap(publicKey []byte) (txnMap map[BlockHash]*MempoolTx)
func (*BitCloutMempool) RegenerateReadOnlyView ¶
func (mp *BitCloutMempool) RegenerateReadOnlyView() error
func (*BitCloutMempool) StartMempoolDBDumper ¶
func (mp *BitCloutMempool) StartMempoolDBDumper()
func (*BitCloutMempool) StartReadOnlyUtxoViewRegenerator ¶
func (mp *BitCloutMempool) StartReadOnlyUtxoViewRegenerator()
func (*BitCloutMempool) Stop ¶
func (mp *BitCloutMempool) Stop()
func (*BitCloutMempool) TryAcceptTransaction ¶
func (mp *BitCloutMempool) TryAcceptTransaction(tx *MsgBitCloutTxn, rateLimit bool, verifySignatures bool) ([]*BlockHash, *MempoolTx, error)
This is the main function used for adding a new txn to the pool. It will run all needed validation on the txn before adding it, and it will only accept the txn if these validations pass.
The ChainLock must be held for reading calling this function.
func (*BitCloutMempool) TxHashes ¶
func (mp *BitCloutMempool) TxHashes() []*BlockHash
Returns the hashes of all the txns in the pool using the readOnly view, which could be slightly out of date.
func (*BitCloutMempool) UpdateAfterConnectBlock ¶
func (mp *BitCloutMempool) UpdateAfterConnectBlock(blk *MsgBitCloutBlock) (_txnsAddedToMempool []*MempoolTx)
UpdateAfterConnectBlock updates the mempool after a block has been added to the blockchain. It does this by basically removing all known transactions in the block from the mempool as follows:
- Build a map of all of the transactions in the block indexed by their hash.
- Create a new mempool object.
- Iterate through all the transactions in the mempool and add the transactions to the new pool object *only if* they don't appear in the block. Do this for transactions in the pool and in the unconnectedTx pool.
- Compute which transactions were newly-accepted into the pool by effectively diffing the new pool's transactions with the old pool's transactions.
- Once the new pool object is up-to-date, the fields of the new pool object replace the fields of the original pool object.
- Return the newly added transactions computed earlier.
TODO: This is fairly inefficient but the story is the same as for UpdateAfterDisconnectBlock.
func (*BitCloutMempool) UpdateAfterDisconnectBlock ¶
func (mp *BitCloutMempool) UpdateAfterDisconnectBlock(blk *MsgBitCloutBlock)
UpdateAfterDisconnectBlock updates the mempool to reflect that a block has been disconnected from the blockchain. It does this by basically adding all the transactions in the block back to the mempool as follows:
- A new pool object is created containing no transactions.
- The block's transactions are added to this new pool object. This is done in order to minimize dependency-related conflicts with transactions already in the mempool.
- Then the transactions in the original pool are layered on top of the block's transactions in the new pool object. Again this is done to avoid dependency issues since the ordering of <block txns> followed by <original mempool txns> is much less likely to have issues.
- Then, once the new pool object is up-to-date, the fields of the new pool object replace the fields of the original pool object.
This function is safe for concurrent access. It is assumed the ChainLock is held before this function is a accessed.
TODO: This is fairly inefficient and basically only necessary because computing a transaction's dependencies is a little shaky. If we end up making the dependency detection logic more robust then we could come back here and change this so that we're not effectively reprocessing the entire mempool every time we have a new block. But until then doing it this way significantly reduces complexity and should hold up for a while.
type BitCloutMessage ¶
type BitCloutMessage interface { // The following methods allow one to convert a message struct into // a byte slice and back. Example usage: // // params := &BitCloutTestnetParams // msgType := MsgTypeVersion // byteSlice := []byte{0x00, ...} // // msg := NewMessage(msgType) // err := msg.FromBytes(byteSlice) // newByteSlice, err := msg.ToBytes(false) // // The data format is intended to be compact while allowing for efficient // transmission over the wire and storage in a database. // // The preSignature field specifies whether the message should be fully // serialized or whether it should be serialized in such a way that it // can be signed (which involves, for example, not serializing signature // fields). ToBytes(preSignature bool) ([]byte, error) FromBytes(data []byte) error // Each Message has a particular type. GetMsgType() MsgType }
BitCloutMessage is the interface that a message we send on the wire must implement.
func NewMessage ¶
func NewMessage(msgType MsgType) BitCloutMessage
func ReadMessage ¶
func ReadMessage(rr io.Reader, networkType NetworkType) (BitCloutMessage, []byte, error)
ReadMessage takes an io.Reader and de-serializes a single message from it. Returns an error if the message is malformed or invalid for any reason. Otherwise returns a formed message object and the raw byte payload from which it was derived.
type BitCloutMessageMeta ¶
type BitCloutMessageMeta struct { BitCloutMessage BitCloutMessage Inbound bool }
type BitCloutMiner ¶
type BitCloutMiner struct { PublicKeys []*btcec.PublicKey BlockProducer *BitCloutBlockProducer // contains filtered or unexported fields }
func NewBitCloutMiner ¶
func NewBitCloutMiner(_minerPublicKeys []string, _numThreads uint32, _blockProducer *BitCloutBlockProducer, _params *BitCloutParams) (*BitCloutMiner, error)
func (*BitCloutMiner) MineAndProcessSingleBlock ¶
func (bitcloutMiner *BitCloutMiner) MineAndProcessSingleBlock(threadIndex uint32, mempoolToUpdate *BitCloutMempool) (_block *MsgBitCloutBlock, _err error)
func (*BitCloutMiner) Start ¶
func (bitcloutMiner *BitCloutMiner) Start()
func (*BitCloutMiner) Stop ¶
func (bitcloutMiner *BitCloutMiner) Stop()
type BitCloutOutput ¶
type BitCloutOutput struct { // Outputs always compensate a specific public key. PublicKey []byte // The amount of BitClout to send to this public key. AmountNanos uint64 }
func (*BitCloutOutput) String ¶
func (bitcloutOutput *BitCloutOutput) String() string
type BitCloutParams ¶
type BitCloutParams struct { // The network type (mainnet, testnet, etc). NetworkType NetworkType // The current protocol version we're running. ProtocolVersion uint64 // The minimum protocol version we'll allow a peer we connect to // to have. MinProtocolVersion uint64 // Used as a "vanity plate" to identify different BitClout // clients. Mainly useful in analyzing the network at // a meta level, not in the protocol itself. UserAgent string // The list of DNS seed hosts to use during bootstrapping. DNSSeeds []string // A list of DNS seed prefixes and suffixes to use during bootstrapping. // These prefixes and suffixes will be scanned and all IPs found will be // incorporated into the address manager. DNSSeedGenerators [][]string // BitcoinDNSSeeds is a list of seed hosts to use to bootstrap connections // to Bitcoin nodes. We connect to Bitcoin nodes to support the exchange // functionality that allows people to buy BitClout with Bitcoin. BitcoinDNSSeeds []string // The minimum amount of work a Bitcoin chain can have before we consider // it valid. BitcoinMinChainWorkHex string // The default port to connect to bitcoin nodes on. BitcoinDefaultPort string // The network parameter for Bitcoin messages as defined by the btcd library. // Useful for certain function calls we make to this library. BitcoinBtcdParams *chaincfg.Params // The version of the Bitcoin protocol we use. BitcoinProtocolVersion uint32 BitcoinBlocksPerRetarget uint32 BitcoinPowLimitBits uint32 // Testnet only. Ignored if set to zero. BitcoinMinDiffReductionTime time.Duration BitcoinTargetTimespanSecs uint32 BitcoinMinRetargetTimespanSecs uint32 BitcoinMaxRetargetTimespanSecs uint32 // The maximum number of seconds in a future a Bitcoin block timestamp is allowed // to be before it is rejected. BitcoinMaxTstampOffsetSeconds uint64 // This value is used to determine whether or not the Bitcoin tip is up-to-date. // If the Bitcoin tip's timestamp is greater than this value then a node should // assume that it needs to download more Bitcoin headers from its peers before it // is current. BitcoinMaxTipAge time.Duration // The time between Bitcoin blocks (=10m normally) BitcoinTimeBetweenBlocks time.Duration // When someone wants to convert BitClout to Bitcoin, they send Bitcoin to the burn address // and then create a transaction on the BitClout chain referencing the burn from the // Bitcoin chain. This variable is the number of blocks that must be mined on top // of the initial Bitcoin burn before the corresponding BitClout transaction can be // validated on the BitClout chain. // // Note that, in order to make validation consistent across all nodes, even nodes // whose Bitcoin tip may be slightly behind, we define a very specific way of // computing how much work has been done for a given Bitcoin block. We define this // as follows: // - Compute the first Bitcoin block that has a timestamp less than MaxTipAge. // Call this block the StalestBitcoinBlock. // * Note that any node that believes itself to be up-to-date will be able to // define a StalestBitcoinBlock that should be consistent with all other nodes // that have a roughly similar timestamp (+/- one block in edge cases due to // the timestamp being off). // - Suppose we have a Bitcoin burn transaction that was mined into a block. Define // the work that has been done on this block as: // * BitcoinWork = (StalestBitcoinBlock.Height - BitcoinBurnTransactionBlockHeight) // // Defining the BitcoinWork in this way ensures that the following holds: // - For a given Bitcoin transaction, if a particular node believes its Bitcoin tip // to be up-to-date, then the BitcoinWork it computes for that transaction will be // consistent with all other nodes that believe their Bitcoin tip to be up-to-date // (+/- one block due to the timestamps being slightly off). // - Note that if a particular node does *not* believe its // Bitcoin tip to be up-to-date, it will not process any Bitcoin burn transactions // and so it does not matter that it cannot compute a value for BitcoinWork. // // Note that if we did not define BitcoinWork the way we do above and instead // defined it relative to a particular node's Bitcoin tip, for example, then // nodes could have vastly different values for BitcoinWork for the same transaction, // which would cause them to disagree about which Bitcoin burn transactions // are valid and which aren't. // // Given the above definition for BitcoinWork, miners can assure with near-certainty // that a block containing a Bitcoin burn transaction will be accepted by 100% of nodes // that are up-to-date as long as they ensure that all of the Bitcoin burn transactions // that they mine into their block have (BitcoinWork >= BitcoinMinBurnWorkBlocks + 1). Note that // nodes whose Bitcoin tip is not up-to-date will not process blocks until their tip // is up-to-date, which means they will also eventually accept this block as well (and // will not reject the block before they are up-to-date). Note also that using // BitcoinMinBurnWorkBlocks+1 rather than BitcoinMinBurnWorkBlocks is a good idea because it protects // against situations where nodes have slightly out-of-sync timestamps. In particular, // any node whose timestamp is between: // - (minerTstamp - minTimeBetweenBlocks) <= nodeTimestamp <= infinity // - where: // * minTimeBetweenBlocks = ( // StalestBitcoinBlock.TImestamp - BlockRightBeforeStalestBitcoinBlock.Timestamp) // * Note minTimeBetweenBlocks will be ~10m on average. // Will believe an BitClout block containing a Bitcoin burn transaction to be valid if the // Miner computes that // - BitcoinWork >= BitcoinMinBurnWorkBlocks+1 // // If the miner wants to ride the edge, she can mine transactions when // BitcoinWork >= BitcoinMinBurnWorkBlocks (without hte +1 buffer). However, in this case // nodes who have timesatamps within: // - nodeTstamp <= minerTstamp - minTimeBetweenBlocks // - where minTImeBetweenBlocks is defined as above // will initially reject any BitClout blocks that contain such Bitcoin burn transactions, // which puts the block at risk of not being the main chain, particularly if other // miners prefer not to build on such blocks due to the risk of rejection. BitcoinMinBurnWorkBlockss int64 MinerBitcoinMinBurnWorkBlockss int64 // Because we use the Bitcoin header chain only to process exchanges from // BTC to BitClout, we don't need to worry about Bitcoin blocks before a certain // point, which is specified by this node. This is basically used to make // header download more efficient but it's important to note that if for // some reason there becomes a different main chain that is stronger than // this one, then we will still switch to that one even with this parameter // set such as it is. BitcoinStartBlockNode *BlockNode // The base58Check-encoded Bitcoin address that users must send Bitcoin to in order // to purchase BitClout. Note that, unfortunately, simply using an all-zeros or // mostly-all-zeros address or public key doesn't work and, in fact, I found that // using almost any address other than this one also doesn't work. BitcoinBurnAddress string // This is a fee in basis points charged on BitcoinExchange transactions that gets // paid to the miners. Basically, if a user burned enough Satoshi to create 100 BitClout, // and if the BitcoinExchangeFeeBasisPoints was 1%, then 99 BitClout would be allocated to // the user's public key while 1 BitClout would be left as a transaction fee to the miner. BitcoinExchangeFeeBasisPoints uint64 // The amount of time to wait for a Bitcoin txn to broadcast throughout the Bitcoin // network before checking for double-spends. BitcoinDoubleSpendWaitSeconds float64 // This field allows us to set the amount purchased at genesis to a non-zero // value. BitCloutNanosPurchasedAtGenesis uint64 // Port used for network communications among full nodes. DefaultSocketPort uint16 // Port used for the limited JSON API that supports light clients. DefaultJSONPort uint16 // The amount of time we wait when connecting to a peer. DialTimeout time.Duration // The amount of time we wait to receive a version message from a peer. VersionNegotiationTimeout time.Duration // The genesis block to use as the base of our chain. GenesisBlock *MsgBitCloutBlock // The expected hash of the genesis block. Should align with what one // would get from actually hashing the provided genesis block. GenesisBlockHashHex string // How often we target a single block to be generated. TimeBetweenBlocks time.Duration // How many blocks between difficulty retargets. TimeBetweenDifficultyRetargets time.Duration // Block hashes, when interpreted as big-endian big integers, must be // values less than or equal to the difficulty // target. The difficulty target is expressed below as a big-endian // big integer and is adjusted every TargetTimePerBlock // order to keep blocks generating at consistent intervals. MinDifficultyTargetHex string // We will reject chains that have less than this amount of total work, // expressed as a hexadecimal big-endian bigint. Useful for preventing // disk-fill attacks, among other things. MinChainWorkHex string // This is used for determining whether we are still in initial block download. // If our tip is older than this, we continue with IBD. MaxTipAge time.Duration // Do not allow the difficulty to change by more than a factor of this // variable during each adjustment period. MaxDifficultyRetargetFactor int64 // Amount of time one must wait before a block reward can be spent. BlockRewardMaturity time.Duration // When shifting from v0 blocks to v1 blocks, we changed the hash function to // CloutHash, which is technically easier. Thus we needed to apply an adjustment // factor in order to phase it in. V1DifficultyAdjustmentFactor int64 // The maximum number of seconds in a future a block timestamp is allowed // to be before it is rejected. MaxTstampOffsetSeconds uint64 // The maximum number of bytes that can be allocated to transactions in // a block. MaxBlockSizeBytes uint64 // It's useful to set the miner maximum block size to a little lower than the // maximum block size in certain cases. For example, on initial launch, setting // it significantly lower is a good way to avoid getting hit by spam blocks. MinerMaxBlockSizeBytes uint64 // In order to make public keys more human-readable, we convert // them to base58. When we do that, we use a prefix that makes // the public keys to become more identifiable. For example, all // mainnet public keys start with "X" because we do this. Base58PrefixPublicKey [3]byte Base58PrefixPrivateKey [3]byte // MaxFetchBlocks is the maximum number of blocks that can be fetched from // a peer at one time. MaxFetchBlocks uint32 MiningIterationsPerCycle uint64 // bitclout MaxUsernameLengthBytes uint64 MaxUserDescriptionLengthBytes uint64 MaxProfilePicLengthBytes uint64 MaxProfilePicDimensions uint64 MaxPrivateMessageLengthBytes uint64 StakeFeeBasisPoints uint64 MaxPostBodyLengthBytes uint64 MaxPostSubLengthBytes uint64 MaxStakeMultipleBasisPoints uint64 MaxCreatorBasisPoints uint64 MaxNFTRoyaltyBasisPoints uint64 ParamUpdaterPublicKeys map[PkMapKey]bool // A list of transactions to apply when initializing the chain. Useful in // cases where we want to hard fork or reboot the chain with specific // transactions applied. SeedTxns []string // A list of balances to initialize the blockchain with. This is useful for // testing and useful in the event that the devs need to hard fork the chain. SeedBalances []*BitCloutOutput // This is a small fee charged on creator coin transactions. It helps // prevent issues related to floating point calculations. CreatorCoinTradeFeeBasisPoints uint64 // These two params define the "curve" that we use when someone buys/sells // creator coins. Effectively, this curve amounts to a polynomial of the form: // - currentCreatorCoinPrice ~= slope * currentCreatorCoinSupply^(1/reserveRatio-1) // Buys and sells effectively take the integral of the curve in opposite directions. // // To better understand where this curve comes from and how it works, check out // the following links. They are all well written so don't be intimidated/afraid to // dig in and read them: // - Primer on bonding curves: https://medium.com/@simondlr/tokens-2-0-curved-token-bonding-in-curation-markets-1764a2e0bee5 // - The Uniswap v2 white paper: https://whitepaper.io/document/600/uniswap-whitepaper // - The Bancor white paper: https://whitepaper.io/document/52/bancor-whitepaper // - Article relating Bancor curves to polynomial curves: https://medium.com/@aventus/token-bonding-curves-547f3a04914 // - Derivations of the Bancor supply increase/decrease formulas: https://blog.relevant.community/bonding-curves-in-depth-intuition-parametrization-d3905a681e0a // - Implementations of Bancor equations in Solidity with code: https://yos.io/2018/11/10/bonding-curves/ // - Bancor is flawed blog post discussing Bancor edge cases: https://hackingdistributed.com/2017/06/19/bancor-is-flawed/ // - A mathematica equation sheet with tests that walks through all the // equations. You will need to copy this into a Mathematica notebook to // run it: https://pastebin.com/raw/M4a1femY CreatorCoinSlope *big.Float CreatorCoinReserveRatio *big.Float // CreatorCoinAutoSellThresholdNanos defines two things. The first is the minimum amount // of creator coins a user must purchase in order for a transaction to be valid. Secondly // it defines the point at which a sell operation will auto liquidate all remaining holdings. // For example if I hold 1000 nanos of creator coins and sell x nanos such that // 1000 - x < CreatorCoinAutoSellThresholdNanos, we auto liquidate the remaining holdings. // It does this to prevent issues with floating point rounding that can arise. // This value should be chosen such that the chain is resistant to "phantom nanos." Phantom nanos // are tiny amounts of CreatorCoinsInCirculation/BitCloutLocked which can cause // the effective reserve ratio to deviate from the expected reserve ratio of the bancor curve. // A higher CreatorCoinAutoSellThresholdNanos makes it prohibitively expensive for someone to // attack the bancor curve to any meaningful measure. CreatorCoinAutoSellThresholdNanos uint64 // The most deflationary event in BitClout history has yet to come... DeflationBombBlockHeight uint64 }
BitCloutParams defines the full list of possible parameters for the BitClout network.
func (*BitCloutParams) EnableRegtest ¶
func (params *BitCloutParams) EnableRegtest()
EnableRegtest allows for local development and testing with incredibly fast blocks with block rewards that can be spent as soon as they are mined. It also removes the default testnet seeds
type BitCloutTxnMetadata ¶
type BitCloutTxnMetadata interface { ToBytes(preSignature bool) ([]byte, error) FromBytes(data []byte) error New() BitCloutTxnMetadata GetTxnType() TxnType }
func NewTxnMetadata ¶
func NewTxnMetadata(txType TxnType) (BitCloutTxnMetadata, error)
type BitcoinExchangeMetadata ¶
type BitcoinExchangeMetadata struct { // The Bitcoin transaction that sends Bitcoin to the designated burn address. BitcoinTransaction *wire.MsgTx // The hash of the Bitcoin block in which the Bitcoin transaction was mined. BitcoinBlockHash *BlockHash // The Bitcoin mekle root corresponding to the block in which the BitcoinTransaction // above was mined. Note that it is not strictly necessary to include this field // since we can look it up from the Bitcoin header if we know the BitcoinBlockHash. // However, having it here is convenient and allows us to do more validation prior // to looking up the header in the Bitcoin header chain. BitcoinMerkleRoot *BlockHash // This is a merkle proof that shows that the BitcoinTransaction above, with // hash equal to BitcoinTransactionHash, exists in the block with hash equal // to BitcoinBlockHash. This is effectively a path through a Merkle tree starting // from BitcoinTransactionHash as a leaf node and finishing with BitcoinMerkleRoot // as the root. BitcoinMerkleProof []*merkletree.ProofPart }
func (*BitcoinExchangeMetadata) FromBytes ¶
func (txnData *BitcoinExchangeMetadata) FromBytes(data []byte) error
func (*BitcoinExchangeMetadata) GetTxnType ¶
func (txnData *BitcoinExchangeMetadata) GetTxnType() TxnType
func (*BitcoinExchangeMetadata) New ¶
func (txnData *BitcoinExchangeMetadata) New() BitCloutTxnMetadata
type BitcoinExchangeTxindexMetadata ¶
type BitcoinExchangeTxindexMetadata struct { BitcoinSpendAddress string // BitCloutOutputPubKeyBase58Check = TransactorPublicKeyBase58Check SatoshisBurned uint64 // NanosCreated = 0 OR TotalOutputNanos+FeeNanos NanosCreated uint64 // TotalNanosPurchasedBefore = TotalNanosPurchasedAfter - NanosCreated TotalNanosPurchasedBefore uint64 TotalNanosPurchasedAfter uint64 BitcoinTxnHash string }
type BitcoinManager ¶
type BitcoinManager struct { // These should only be accessed after acquiring the BitcoinManagerLock. // // headerIndex contains a reference to all Bitcoin headers we've downloaded including // ones that are not on the main chain. BitcoinHeaderIndexLock deadlock.RWMutex ExpectedResponsesLock deadlock.RWMutex // A channel that takes new <IP>:<Port> strings to connect to. When an address // is found on this channel, the existing peer is dropped and a new peer is // connected to. If a connection to the new peer fails then the switch is not // completed. SwitchPeerChan chan *SwitchPeerMsg // contains filtered or unexported fields }
func NewBitcoinManager ¶
func NewBitcoinManager(_db *badger.DB, _params *BitCloutParams, _timeSource btcdchain.MedianTimeSource, _btcDataDir string, _updateChan chan *ServerMessage, _connectPeer string) ( *BitcoinManager, error)
func (*BitcoinManager) AddSeeds ¶
func (bm *BitcoinManager) AddSeeds()
func (*BitcoinManager) BroadcastTxn ¶
func (bm *BitcoinManager) BroadcastTxn(txn *wire.MsgTx)
func (*BitcoinManager) BroadcastTxnAndCheckAdded ¶
func (bm *BitcoinManager) BroadcastTxnAndCheckAdded( txn *wire.MsgTx, timeoutSecs int) (_err error)
func (*BitcoinManager) BroadcastTxnAndCheckAddedRedundant ¶
func (*BitcoinManager) FullyValidateHeaderAtIndex ¶
func (bm *BitcoinManager) FullyValidateHeaderAtIndex(index int) (_finished bool, _err error)
Acquires the BitcoinHeaderIndexLock for writing.
func (*BitcoinManager) FullyValidateHeaders ¶
func (bm *BitcoinManager) FullyValidateHeaders() error
Acquires the BitcoinHeaderIndexLock for writing in its call to FullyValidateHeaderAtIndex.
func (*BitcoinManager) GetAddrManager ¶
func (bm *BitcoinManager) GetAddrManager() *addrmgr.AddrManager
func (*BitcoinManager) GetBitcoinBlockNode ¶
func (bm *BitcoinManager) GetBitcoinBlockNode(hash *BlockHash) *BlockNode
GetBitcoinBlockNode returns the BlockNode corresponding to the given hash if the hash is in the main Bitcoin header chain. Otherwise it returns nil. The caller is free to read the contents of the BlockNode but if they should *not* modify it.
func (*BitcoinManager) GetBitcoinBurnWorkBlocks ¶
func (bm *BitcoinManager) GetBitcoinBurnWorkBlocks(blockHeight uint32) int64
Note that the amount of work must be determined based on the oldest time-current block that we have rather than the tip. If we aren't time-current or if the height passed in is greater than that of the oldest time-current Bitcoin block then a negative value, specifying the number of blocks this height is *behing* the oldest time-current block, is returned. When the height is equal to that of the oldest time-current block, zero is returned.
func (*BitcoinManager) HandleBitcoinHeaders ¶
func (bm *BitcoinManager) HandleBitcoinHeaders(conn net.Conn, msg *wire.MsgHeaders) error
Acquires the BitcoinHeaderIndexLock through calls to various functions.
func (*BitcoinManager) HeaderAtHeight ¶
func (bm *BitcoinManager) HeaderAtHeight(blockHeight uint32) *BlockNode
func (*BitcoinManager) HeaderForHash ¶
func (bm *BitcoinManager) HeaderForHash(hash *BlockHash) *BlockNode
func (*BitcoinManager) HeaderTip ¶
func (bm *BitcoinManager) HeaderTip() *BlockNode
func (*BitcoinManager) IsCurrent ¶
func (bm *BitcoinManager) IsCurrent(considerCumWork bool) bool
func (*BitcoinManager) MaybeRequestBitcoinBlock ¶
func (bm *BitcoinManager) MaybeRequestBitcoinBlock(conn net.Conn, hash chainhash.Hash)
func (*BitcoinManager) ProcessBitcoinBlock ¶
func (bm *BitcoinManager) ProcessBitcoinBlock(bitcoinBlock *wire.MsgBlock)
func (*BitcoinManager) ProcessBitcoinHeaderFull ¶
func (bm *BitcoinManager) ProcessBitcoinHeaderFull(bitcoinHeader *wire.BlockHeader, params *BitCloutParams) ( _isMainChain bool, _isOrphan bool, _err error)
Acquires the BitcoinHeaderIndexLock for writing.
func (*BitcoinManager) ProcessBitcoinHeaderQuick ¶
func (bm *BitcoinManager) ProcessBitcoinHeaderQuick(bitcoinHeader *wire.BlockHeader, params *BitCloutParams) ( _isMainChain bool, _isOrphan bool, _err error)
ProcessBitcoinHeaderQuick processes a Bitcoin header without checking its proof of work, leaving that to be done in a later post-processing step.
Holds the BitcoinHeaderIndexLock for writing.
func (*BitcoinManager) RequestBitcoinBlock ¶
func (bm *BitcoinManager) RequestBitcoinBlock(blockHash chainhash.Hash)
func (*BitcoinManager) RequestBitcoinTxn ¶
func (bm *BitcoinManager) RequestBitcoinTxn(txHash chainhash.Hash)
func (*BitcoinManager) ResetBitcoinHeaderIndex ¶
func (bm *BitcoinManager) ResetBitcoinHeaderIndex() error
func (*BitcoinManager) SendGetHeaders ¶
func (bm *BitcoinManager) SendGetHeaders(conn net.Conn)
Same as _sendGetHeaders but holds the HeaderIndexLock for reading
func (*BitcoinManager) SetHeaderIndexAndBestChainListMap ¶
func (bm *BitcoinManager) SetHeaderIndexAndBestChainListMap( bestChain []*BlockNode, headerIndex map[BlockHash]*BlockNode)
func (*BitcoinManager) Start ¶
func (bm *BitcoinManager) Start()
func (*BitcoinManager) SyncConn ¶
func (bm *BitcoinManager) SyncConn() net.Conn
type BitcoinUtxo ¶
func BlockCypherExtractBitcoinUtxosFromResponse ¶
func BlockCypherExtractBitcoinUtxosFromResponse( apiData *BlockCypherAPIFullAddressResponse, addrString string, params *BitCloutParams) ( []*BitcoinUtxo, error)
func BlockCypherUtxoSource ¶
func BlockCypherUtxoSource(addrString string, params *BitCloutParams) ( []*BitcoinUtxo, error)
func FrontendBlockCypherUtxoSource ¶
func FrontendBlockCypherUtxoSource( apiData *BlockCypherAPIFullAddressResponse, addrString string, params *BitCloutParams) ( []*BitcoinUtxo, error)
The frontend passes in the apiData. We do this so that our server doesn't get rate-limited by the free tier.
type BlockCypherAPIFullAddressResponse ¶
type BlockCypherAPIFullAddressResponse struct { Address string `json:"address"` // Balance data ConfirmedBalance int64 `json:"balance"` UnconfirmedBalance int64 `json:"unconfirmed_balance"` FinalBalance int64 `json:"final_balance"` // Transaction data Txns []*BlockCypherAPITxnResponse `json:"txs"` HasMore bool `json:"hasMore"` Error string `json:"error"` }
func GetBlockCypherAPIFullAddressResponse ¶
func GetBlockCypherAPIFullAddressResponse(addrString string, params *BitCloutParams) ( _apiData *BlockCypherAPIFullAddressResponse, _err error)
type BlockCypherAPIInputResponse ¶
type BlockCypherAPIInputResponse struct { PrevTxIDHex string `json:"prev_hash"` Index int64 `json:"output_index"` ScriptHex string `json:"script"` AmountSatoshis int64 `json:"output_value"` Sequence int64 `json:"sequence"` Addresses []string `json:"addresses"` ScriptType string `json:"script_type"` Age int64 `json:"age"` }
type BlockCypherAPITxnResponse ¶
type BlockCypherAPITxnResponse struct { BlockHashHex string `json:"block_hash"` BlockHeight int64 `json:"block_height"` LockTime int64 `json:"lock_time"` TxIDHex string `json:"hash"` Inputs []*BlockCypherAPIInputResponse `json:"inputs"` Outputs []*BlockCypherAPIOutputResponse `json:"outputs"` Confirmations int64 `json:"confirmations"` DoubleSpend bool `json:"double_spend"` }
type BlockHash ¶
type BlockHash [HashSizeBytes]byte
BlockHash is a convenient alias for a block hash.
func BigintToHash ¶
func CalcNextDifficultyTarget ¶
func CalcNextDifficultyTarget( lastNode *BlockNode, version uint32, params *BitCloutParams) (*BlockHash, error)
CalcNextDifficultyTarget computes the difficulty target expected of the next block.
func ComputeTransactionHashes ¶
func ComputeTransactionHashes(txns []*MsgBitCloutTxn) ([]*BlockHash, error)
func CopyBytesIntoBlockHash ¶
func DbGetAllBitcoinBurnTxIDs ¶
func DbGetAllBitcoinBurnTxIDs(handle *badger.DB) (_bitcoinBurnTxIDs []*BlockHash)
func DbGetBestHash ¶
func DbGetPostHashesYouLike ¶
func DbGetTxindexTip ¶
func DbGetTxindexTip(handle *badger.DB) *BlockHash
func ExpectedWorkForBlockHash ¶
The number of hashing attempts in expectation it would take to produce the hash passed in. This is computed as:
E(min(X_i, ..., X_n)) where: - n = (number of attempted hashes) and - the X_i are all U(0, MAX_HASH)
-> E(min(X_i, ..., X_n)) = MAX_HASH / (n + 1) -> E(n) ~= MAX_HASH / min_hash - 1
- where min_hash is the block hash
We approximate this as MAX_HASH / (min_hash + 1), adding 1 to min_hash in order to mitigate the possibility of a divide-by-zero error.
The value returned is the expected number of hashes performed to produce the input hash formatted as a big-endian big integer that uses the BlockHash type for convenience (though it is likely to be much lower in terms of magnitude than a typical BlockHash object).
func FindLowestHash ¶
func FindLowestHash( blockHeaderr *MsgBitCloutHeader, iterations uint64) ( lowestHash *BlockHash, lowestNonce uint64, ee error)
FindLowestHash Mine for a given number of iterations and return the lowest hash value found and its associated nonce. Hashing starts at the value of the Nonce set on the blockHeader field when it is passed and increments the value of the passed blockHeader field as it iterates. This makes it easy to continue a subsequent batch of iterations after we return.
func MustDecodeHexBlockHash ¶
func NewBlockHash ¶
func ProofOfWorkHash ¶
ProofOfWorkHash is a hash function designed for computing BitClout block hashes. It seems the optimal hash function is one that satisfies two properties:
- It is not computable by any existing ASICs. If this property isn't satisfied then miners with pre-existing investments in ASICs for other coins can very cheaply mine on our chain for a short period of time to pull off a 51% attack. This has actually happened with "merge-mined" coins like Namecoin.
- If implemented on an ASIC, there is an "orders of magnitude" speed-up over using a CPU or GPU. This is because ASICs require some amount of capital expenditure up-front in order to mine, which then aligns the owner of the ASIC to care about the health of the network over a longer period of time. In contrast, a hash function that is CPU or GPU-mineable can be attacked with an AWS fleet early on. This also may result in a more eco-friendly chain, since the hash power will be more bottlenecked by up-front CapEx rather than ongoing electricity cost, as is the case with GPU-mined coins.
Note that our pursuit of (2) above runs counter to existing dogma which seeks to prioritize "ASIC-resistance" in hash functions.
Given the above, the hash function chosen is a simple twist on sha3 that we don't think any ASIC exists for currently. Note that creating an ASIC for this should be relatively straightforward, however, which allows us to satisfy property (2) above.
func Sha256DoubleHash ¶
func StakeIDToHash ¶
type BlockNode ¶
type BlockNode struct { // Pointer to a node representing the block's parent. Parent *BlockNode // The hash computed on this block. Hash *BlockHash // Height is the position in the block chain. Height uint32 // The difficulty target for this block. Used to compute the next // block's difficulty target so it can be validated. DifficultyTarget *BlockHash // A computation of the total amount of work that has been performed // on this chain, including the current node. CumWork *big.Int // The block header. Header *MsgBitCloutHeader // Status holds the validation state for the block and whether or not // it's stored in the database. Status BlockStatus }
Add some fields in addition to the header to aid in the selection of the best chain.
func DeserializeBlockNode ¶
func GetBestChain ¶
func GetHeightHashToNodeInfo ¶
func NewBlockNode ¶
func NewBlockNode( parent *BlockNode, hash *BlockHash, height uint32, difficultyTarget *BlockHash, cumWork *big.Int, header *MsgBitCloutHeader, status BlockStatus) *BlockNode
TODO: Height not needed in this since it's in the header.
func (*BlockNode) RelativeAncestor ¶
RelativeAncestor returns the ancestor block node a relative 'distance' blocks before this node. This is equivalent to calling Ancestor with the node's height minus provided distance.
This function is safe for concurrent access.
type BlockProducerInfo ¶
func (*BlockProducerInfo) Deserialize ¶
func (bpi *BlockProducerInfo) Deserialize(data []byte) error
func (*BlockProducerInfo) Serialize ¶
func (bpi *BlockProducerInfo) Serialize() []byte
func (*BlockProducerInfo) String ¶
func (bpi *BlockProducerInfo) String() string
type BlockRewardMetadataa ¶
type BlockRewardMetadataa struct { // A block reward txn has an ExtraData field that can be between // zero and 100 bytes long. It can theoretically contain anything // but in practice it's likely that miners will use this field to // update the merkle root of the block, which may make the block // easier to mine (namely by allowing the Nonce in the header to // be shorter). ExtraData []byte }
func (*BlockRewardMetadataa) FromBytes ¶
func (txnData *BlockRewardMetadataa) FromBytes(dataa []byte) error
func (*BlockRewardMetadataa) GetTxnType ¶
func (txnData *BlockRewardMetadataa) GetTxnType() TxnType
func (*BlockRewardMetadataa) New ¶
func (txnData *BlockRewardMetadataa) New() BitCloutTxnMetadata
type BlockStatus ¶
type BlockStatus uint32
func (BlockStatus) String ¶
func (blockStatus BlockStatus) String() string
type BlockTemplateStats ¶
type BlockTemplateStats struct { // The number of txns in the block template. TxnCount uint32 // The final txn we attempted to put in the block. FailingTxnHash string // The reason why the final txn failed to add. FailingTxnError string // The "Added" time on a transaction changes every time a block is mined so we record // the first time added val we are aware of for a specific txn hash here. FailingTxnOriginalTimeAdded time.Time // The time since the failing txn was added to the mempool. FailingTxnMinutesSinceAdded float64 }
type Blockchain ¶
type Blockchain struct { // Protects most of the fields below this point. ChainLock deadlock.RWMutex // contains filtered or unexported fields }
func NewBlockchain ¶
func NewBlockchain( _trustedBlockProducerPublicKeyStrs []string, _trustedBlockProducerStartHeight uint64, _params *BitCloutParams, _timeSource chainlib.MedianTimeSource, _db *badger.DB, _bitcoinManager *BitcoinManager, _server *Server) (*Blockchain, error)
NewBlockchain returns a new blockchain object. It initializes some in-memory data structures by reading from the db. It also initializes the db if it hasn't been initialized in the past. This function should only be called once per db, and one should never run two blockhain objects over the same db at the same time as they will likely step on each other and become inconsistent.
func (*Blockchain) AddInputsAndChangeToTransaction ¶
func (bc *Blockchain) AddInputsAndChangeToTransaction( txArg *MsgBitCloutTxn, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _totalInputAdded uint64, _spendAmount uint64, _totalChangeAdded uint64, _fee uint64, _err error)
AddInputsAndChangeToTransaction fetches and adds utxos to the transaction passed in to meet the desired spend amount while also satisfying the desired minimum fee rate. Additionally, if it's worth it, this function will add a change output sending excess BitClout back to the spend public key. Note that the final feerate of the transaction after calling this function may exceed the minimum feerate requested. This can happen if the signature occupies fewer bytes than the expected maximum number of bytes or if the change output occupies fewer bytes than the expected maximum (though there could be other ways for this to happen).
The transaction passed in should not have any inputs on it before calling this function (an error is returned if it does). Additionally, the output of the transaction passed in is assumed to be the amount the caller wishes us to find inputs for.
An error is returned if there is not enough input associated with this public key to satisfy the transaction's output (subject to the minimum feerate).
func (*Blockchain) AddInputsAndChangeToTransactionWithSubsidy ¶
func (bc *Blockchain) AddInputsAndChangeToTransactionWithSubsidy( txArg *MsgBitCloutTxn, minFeeRateNanosPerKB uint64, inputSubsidy uint64, mempool *BitCloutMempool, additionalFees uint64) ( _totalInputAdded uint64, _spendAmount uint64, _totalChangeAdded uint64, _fee uint64, _err error)
func (*Blockchain) BestChain ¶
func (bc *Blockchain) BestChain() []*BlockNode
func (*Blockchain) BlockTip ¶
func (bc *Blockchain) BlockTip() *BlockNode
func (*Blockchain) ChainState ¶
func (bc *Blockchain) ChainState() SyncState
func (*Blockchain) CopyBestChain ¶
func (bc *Blockchain) CopyBestChain() ([]*BlockNode, map[BlockHash]*BlockNode)
func (*Blockchain) CopyBestHeaderChain ¶
func (bc *Blockchain) CopyBestHeaderChain() ([]*BlockNode, map[BlockHash]*BlockNode)
func (*Blockchain) CopyBlockIndex ¶
func (bc *Blockchain) CopyBlockIndex() map[BlockHash]*BlockNode
func (*Blockchain) CreateAcceptNFTBidTxn ¶
func (bc *Blockchain) CreateAcceptNFTBidTxn( UpdaterPublicKey []byte, NFTPostHash *BlockHash, SerialNumber uint64, BidderPKID *PKID, BidAmountNanos uint64, EncryptedUnlockableTextBytes []byte, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateBasicTransferTxnWithDiamonds ¶
func (bc *Blockchain) CreateBasicTransferTxnWithDiamonds( SenderPublicKey []byte, DiamondPostHash *BlockHash, DiamondLevel int64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _spendAmount uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateCreateNFTTxn ¶
func (bc *Blockchain) CreateCreateNFTTxn( UpdaterPublicKey []byte, NFTPostHash *BlockHash, NumCopies uint64, HasUnlockable bool, IsForSale bool, MinBidAmountNanos uint64, NFTFee uint64, NFTRoyaltyToCreatorBasisPoints uint64, NFTRoyaltyToCoinBasisPoints uint64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateCreatorCoinTransferTxn ¶
func (bc *Blockchain) CreateCreatorCoinTransferTxn( UpdaterPublicKey []byte, ProfilePublicKey []byte, CreatorCoinToTransferNanos uint64, RecipientPublicKey []byte, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateCreatorCoinTransferTxnWithDiamonds ¶
func (bc *Blockchain) CreateCreatorCoinTransferTxnWithDiamonds( SenderPublicKey []byte, ReceiverPublicKey []byte, DiamondPostHash *BlockHash, DiamondLevel int64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateCreatorCoinTxn ¶
func (bc *Blockchain) CreateCreatorCoinTxn( UpdaterPublicKey []byte, ProfilePublicKey []byte, OperationType CreatorCoinOperationType, BitCloutToSellNanos uint64, CreatorCoinToSellNanos uint64, BitCloutToAddNanos uint64, MinBitCloutExpectedNanos uint64, MinCreatorCoinExpectedNanos uint64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateFollowTxn ¶
func (bc *Blockchain) CreateFollowTxn( senderPublicKey []byte, followedPublicKey []byte, isUnfollow bool, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateLikeTxn ¶
func (bc *Blockchain) CreateLikeTxn( userPublicKey []byte, likedPostHash BlockHash, isUnlike bool, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateMaxSpend ¶
func (bc *Blockchain) CreateMaxSpend( senderPkBytes []byte, recipientPkBytes []byte, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInputAdded uint64, _spendAmount uint64, _fee uint64, _err error)
func (*Blockchain) CreateNFTBidTxn ¶
func (bc *Blockchain) CreateNFTBidTxn( UpdaterPublicKey []byte, NFTPostHash *BlockHash, SerialNumber uint64, BidAmountNanos uint64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreatePrivateMessageTxn ¶
func (bc *Blockchain) CreatePrivateMessageTxn( senderPublicKey []byte, recipientPublicKey []byte, unencryptedMessageText string, encryptedMessageText string, tstampNanos uint64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateSubmitPostTxn ¶
func (bc *Blockchain) CreateSubmitPostTxn( updaterPublicKey []byte, postHashToModify []byte, parentStakeID []byte, body []byte, recloutPostHashBytes []byte, isQuotedReclout bool, tstampNanos uint64, postExtraData map[string][]byte, isHidden bool, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateSwapIdentityTxn ¶
func (bc *Blockchain) CreateSwapIdentityTxn( UpdaterPublicKeyBytes []byte, FromPublicKeyBytes []byte, ToPublicKeyBytes []byte, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateUpdateBitcoinUSDExchangeRateTxn ¶
func (bc *Blockchain) CreateUpdateBitcoinUSDExchangeRateTxn( updaterPublicKey []byte, usdCentsPerbitcoin uint64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateUpdateGlobalParamsTxn ¶
func (bc *Blockchain) CreateUpdateGlobalParamsTxn(updaterPublicKey []byte, usdCentsPerBitcoin int64, createProfileFeesNanos int64, createNFTFeesNanos int64, maxCopiesPerNFT int64, minimumNetworkFeeNanosPerKb int64, forbiddenPubKey []byte, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateUpdateNFTTxn ¶
func (bc *Blockchain) CreateUpdateNFTTxn( UpdaterPublicKey []byte, NFTPostHash *BlockHash, SerialNumber uint64, IsForSale bool, MinBidAmountNanos uint64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) CreateUpdateProfileTxn ¶
func (bc *Blockchain) CreateUpdateProfileTxn( UpdaterPublicKeyBytes []byte, OptionalProfilePublicKeyBytes []byte, NewUsername string, NewDescription string, NewProfilePic string, NewCreatorBasisPoints uint64, NewStakeMultipleBasisPoints uint64, IsHidden bool, AdditionalFees uint64, minFeeRateNanosPerKB uint64, mempool *BitCloutMempool) ( _txn *MsgBitCloutTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)
func (*Blockchain) DB ¶
func (bc *Blockchain) DB() *badger.DB
func (*Blockchain) EstimateDefaultFeeRateNanosPerKB ¶
func (bc *Blockchain) EstimateDefaultFeeRateNanosPerKB( medianThreshold float64, minFeeRateNanosPerKB uint64) uint64
func (*Blockchain) GetBlock ¶
func (bc *Blockchain) GetBlock(blockHash *BlockHash) *MsgBitCloutBlock
Don't need a lock because blocks don't get removed from the db after they're added
func (*Blockchain) GetBlockAtHeight ¶
func (bc *Blockchain) GetBlockAtHeight(height uint32) *MsgBitCloutBlock
func (*Blockchain) GetBlockNodesToFetch ¶
func (*Blockchain) GetSpendableUtxosForPublicKey ¶
func (bc *Blockchain) GetSpendableUtxosForPublicKey(spendPublicKeyBytes []byte, mempool *BitCloutMempool, referenceUtxoView *UtxoView) ([]*UtxoEntry, error)
func (*Blockchain) HasBlock ¶
func (bc *Blockchain) HasBlock(blockHash *BlockHash) bool
func (*Blockchain) HasHeader ¶
func (bc *Blockchain) HasHeader(headerHash *BlockHash) bool
func (*Blockchain) HeaderAtHeight ¶
func (bc *Blockchain) HeaderAtHeight(blockHeight uint32) *BlockNode
func (*Blockchain) HeaderLocatorWithNodeHash ¶
func (bc *Blockchain) HeaderLocatorWithNodeHash(blockHash *BlockHash) ([]*BlockHash, error)
func (*Blockchain) HeaderTip ¶
func (bc *Blockchain) HeaderTip() *BlockNode
func (*Blockchain) LatestHeaderLocator ¶
func (bc *Blockchain) LatestHeaderLocator() []*BlockHash
LatestHeaderLocator calls LatestLocator in order to fetch a locator for the best header chain.
func (*Blockchain) LatestLocator ¶
func (bc *Blockchain) LatestLocator(tip *BlockNode) []*BlockHash
LatestLocator returns a block locator for the passed block node. The passed node can be nil in which case the block locator for the current tip associated with the view will be returned.
BlockLocator is used to help locate a specific block. The algorithm for building the block locator is to add the hashes in reverse order until the genesis block is reached. In order to keep the list of locator hashes to a reasonable number of entries, first the most recent previous 12 block hashes are added, then the step is doubled each loop iteration to exponentially decrease the number of hashes as a function of the distance from the block being located.
For example, assume a block chain with a side chain as depicted below:
genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18 \-> 16a -> 17a
The block locator for block 17a would be the hashes of blocks: [17a 16a 15 14 13 12 11 10 9 8 7 6 4 genesis]
Caller is responsible for acquiring the ChainLock before calling this function.
func (*Blockchain) LocateBestBlockChainHeaders ¶
func (bc *Blockchain) LocateBestBlockChainHeaders(locator []*BlockHash, stopHash *BlockHash) []*MsgBitCloutHeader
LocateBestBlockChainHeaders returns the headers of the blocks after the first known block in the locator until the provided stop hash is reached, or up to a max of wire.MaxBlockHeadersPerMsg headers. Note that it returns the best headers considering only headers for which we have blocks (that is, it considers the best *block* chain we have rather than the best *header* chain). This is the correct thing to do because in general this function is called in order to serve a response to a peer's GetHeaders request.
In addition, there are two special cases:
- When no locators are provided, the stop hash is treated as a request for that header, so it will either return the header for the stop hash itself if it is known, or nil if it is unknown
- When locators are provided, but none of them are known, headers starting after the genesis block will be returned
This function is safe for concurrent access.
func (*Blockchain) MarkBlockInvalid ¶
func (bc *Blockchain) MarkBlockInvalid(node *BlockNode, errOccurred RuleError)
func (*Blockchain) ProcessBlock ¶
func (bc *Blockchain) ProcessBlock(bitcloutBlock *MsgBitCloutBlock, verifySignatures bool) (_isMainChain bool, _isOrphan bool, _err error)
Note: It is the caller's responsibility to ensure that the BitcoinManager is time-current prior to calling ProcessBlock on any transactions that require the BitcoinManager for validation (e.g. BitcoinExchange transactions). Failure to do so will cause ProcessBlock to error on blocks that could otherwise be valid if a time-current BitcoinManager were available. If it is known for sure that no BitcoinExchange transactions need to be validated then it is OK for the BitcoinManager to not be time-current and even for it to be nil entirely. This is useful e.g. for tests where we want to exercise ProcessBlock without setting up a time-current BitcoinManager.
func (*Blockchain) ProcessHeader ¶
func (bc *Blockchain) ProcessHeader(blockHeader *MsgBitCloutHeader, headerHash *BlockHash) (_isMainChain bool, _isOrphan bool, _err error)
ProcessHeader is a wrapper around processHeader, which does the leg-work, that acquires the ChainLock first.
func (*Blockchain) ProcessOrphanBlock ¶
func (bc *Blockchain) ProcessOrphanBlock(bitcloutBlock *MsgBitCloutBlock, blockHash *BlockHash) error
ProcessOrphanBlock runs some very basic validation on the orphan block and adds it to our orphan data structure if it passes. If there are too many orphan blocks in our data structure, it also evicts the oldest block to make room for this one.
TODO: Currently we only remove orphan blocks if we have too many. This means in a steady state we are potentially keeping MaxOrphansInMemory at all times, which is wasteful of resources. Better would be to clean up orphan blocks once they're too old or something like that.
func (*Blockchain) SetBestChain ¶
func (bc *Blockchain) SetBestChain(bestChain []*BlockNode)
func (*Blockchain) SetBestChainMap ¶
func (*Blockchain) ValidateTransaction ¶
func (bc *Blockchain) ValidateTransaction( txnMsg *MsgBitCloutTxn, blockHeight uint32, verifySignatures bool, checkMerkleProof bool, minBitcoinBurnWorkBlocks int64, mempool *BitCloutMempool) error
ValidateTransaction creates a UtxoView and sees if the transaction can be connected to it. If a mempool is provided, this function tries to find dependencies of the passed-in transaction in the pool and connect them before trying to connect the passed-in transaction.
type BlockonomicsRBFResponse ¶
type BroadcastTxn ¶
type CoinEntry ¶
type CoinEntry struct { // The amount the owner of this profile receives when there is a // "net new" purchase of their coin. CreatorBasisPoints uint64 // The amount of BitClout backing the coin. Whenever a user buys a coin // from the protocol this amount increases, and whenever a user sells a // coin to the protocol this decreases. BitCloutLockedNanos uint64 // The number of public keys who have holdings in this creator coin. // Due to floating point truncation, it can be difficult to simultaneously // reset CoinsInCirculationNanos and BitCloutLockedNanos to zero after // everyone has sold all their creator coins. Initially NumberOfHolders // is set to zero. Once it returns to zero after a series of buys & sells // we reset the BitCloutLockedNanos and CoinsInCirculationNanos to prevent // abnormal bancor curve behavior. NumberOfHolders uint64 // The number of coins currently in circulation. Whenever a user buys a // coin from the protocol this increases, and whenever a user sells a // coin to the protocol this decreases. CoinsInCirculationNanos uint64 // This field keeps track of the highest number of coins that has ever // been in circulation. It is used to determine when a creator should // receive a "founder reward." In particular, whenever the number of // coins being minted would push the number of coins in circulation // beyond the watermark, we allocate a percentage of the coins being // minted to the creator as a "founder reward." CoinWatermarkNanos uint64 }
This struct contains all the information required to support coin buy/sell transactions on profiles.
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func NewConnectionManager ¶
func NewConnectionManager( _params *BitCloutParams, _addrMgr *addrmgr.AddrManager, _listeners []net.Listener, _connectIps []string, _timeSource chainlib.MedianTimeSource, _targetOutboundPeers uint32, _maxInboundPeers uint32, _limitOneInboundConnectionPerIP bool, _ignoreUnminedBitcoinTxnsFromPeers bool, _blockCypherAPIKey string, _stallTimeoutSeconds uint64, _minFeeRateNanosPerKB uint64, _serverMessageQueue chan *ServerMessage, _srv *Server) *ConnectionManager
func (*ConnectionManager) ConnectPeer ¶
func (cmgr *ConnectionManager) ConnectPeer(conn net.Conn, persistentAddr *wire.NetAddress)
Connect either an INBOUND or OUTBOUND peer. If conn == nil, then we will set up an OUTBOUND peer. Otherwise we will use the conn to create an INBOUND peer. If the connectoin is OUTBOUND and the persistentAddr is set, then we will connect only to that addr. Otherwise, we will use the addrmgr to randomly select addrs and create OUTBOUND connections with them until we find a worthy peer.
func (*ConnectionManager) GetAddrManager ¶
func (cmgr *ConnectionManager) GetAddrManager() *addrmgr.AddrManager
func (*ConnectionManager) GetAllPeers ¶
func (cmgr *ConnectionManager) GetAllPeers() []*Peer
GetAllPeers holds the mtxPeerMaps lock for reading and returns a list containing pointers to all the active peers.
func (*ConnectionManager) RandomPeer ¶
func (cmgr *ConnectionManager) RandomPeer() *Peer
func (*ConnectionManager) RemovePeer ¶
func (cmgr *ConnectionManager) RemovePeer(pp *Peer)
Update our data structures to remove this peer.
func (*ConnectionManager) Start ¶
func (cmgr *ConnectionManager) Start()
func (*ConnectionManager) Stop ¶
func (cmgr *ConnectionManager) Stop()
type CreateNFTMetadata ¶
type CreateNFTMetadata struct { NFTPostHash *BlockHash NumCopies uint64 HasUnlockable bool IsForSale bool MinBidAmountNanos uint64 NFTRoyaltyToCreatorBasisPoints uint64 NFTRoyaltyToCoinBasisPoints uint64 }
func (*CreateNFTMetadata) FromBytes ¶
func (txnData *CreateNFTMetadata) FromBytes(dataa []byte) error
func (*CreateNFTMetadata) GetTxnType ¶
func (txnData *CreateNFTMetadata) GetTxnType() TxnType
func (*CreateNFTMetadata) New ¶
func (txnData *CreateNFTMetadata) New() BitCloutTxnMetadata
type CreatorCoinMetadataa ¶
type CreatorCoinMetadataa struct { // ProfilePublicKey is the public key of the profile that owns the // coin the person wants to operate on. Creator coins can only be // bought and sold if a valid profile exists. ProfilePublicKey []byte // OperationType specifies what the user wants to do with this // creator coin. OperationType CreatorCoinOperationType // Generally, only one of these will be used depending on the OperationType // set. In a Buy transaction, BitCloutToSellNanos will be converted into // creator coin on behalf of the user. In a Sell transaction, // CreatorCoinToSellNanos will be converted into BitClout. In an AddBitClout // operation, BitCloutToAddNanos will be aded for the user. This allows us to // support multiple transaction types with same meta field. BitCloutToSellNanos uint64 CreatorCoinToSellNanos uint64 BitCloutToAddNanos uint64 // When a user converts BitClout into CreatorCoin, MinCreatorCoinExpectedNanos // specifies the minimum amount of creator coin that the user expects from their // transaction. And vice versa when a user is converting CreatorCoin for BitClout. // Specifying these fields prevents the front-running of users' buy/sell. Setting // them to zero turns off the check. Give it your best shot, Ivan. MinBitCloutExpectedNanos uint64 MinCreatorCoinExpectedNanos uint64 }
func (*CreatorCoinMetadataa) FromBytes ¶
func (txnData *CreatorCoinMetadataa) FromBytes(dataa []byte) error
func (*CreatorCoinMetadataa) GetTxnType ¶
func (txnData *CreatorCoinMetadataa) GetTxnType() TxnType
func (*CreatorCoinMetadataa) New ¶
func (txnData *CreatorCoinMetadataa) New() BitCloutTxnMetadata
type CreatorCoinOperationType ¶
type CreatorCoinOperationType uint8
const ( CreatorCoinOperationTypeBuy CreatorCoinOperationType = 0 CreatorCoinOperationTypeSell CreatorCoinOperationType = 1 CreatorCoinOperationTypeAddBitClout CreatorCoinOperationType = 2 )
type CreatorCoinTransferMetadataa ¶
type CreatorCoinTransferMetadataa struct { // ProfilePublicKey is the public key of the profile that owns the // coin the person wants to transer. Creator coins can only be // transferred if a valid profile exists. ProfilePublicKey []byte CreatorCoinToTransferNanos uint64 ReceiverPublicKey []byte }
func (*CreatorCoinTransferMetadataa) FromBytes ¶
func (txnData *CreatorCoinTransferMetadataa) FromBytes(dataa []byte) error
func (*CreatorCoinTransferMetadataa) GetTxnType ¶
func (txnData *CreatorCoinTransferMetadataa) GetTxnType() TxnType
func (*CreatorCoinTransferMetadataa) New ¶
func (txnData *CreatorCoinTransferMetadataa) New() BitCloutTxnMetadata
type DiamondEntry ¶
type DiamondEntry struct { SenderPKID *PKID ReceiverPKID *PKID DiamondPostHash *BlockHash DiamondLevel int64 // contains filtered or unexported fields }
DiamondEntry stores the number of diamonds given by a sender to a post.
func DbGetDiamondEntriesForSenderToReceiver ¶
func DbGetDiamondEntriesForSenderToReceiver(handle *badger.DB, receiverPKID *PKID, senderPKID *PKID) ( _diamondEntries []*DiamondEntry, _err error)
This function returns a list of DiamondEntrys given by giverPKID to receiverPKID that contain post hashes.
func DbGetDiamondMappings ¶
func DbGetDiamondMappings( db *badger.DB, diamondReceiverPKID *PKID, diamondSenderPKID *PKID, diamondPostHash *BlockHash) *DiamondEntry
func DbGetDiamondMappingsWithTxn ¶
func DbGetDiamondMappingsWithTxn( txn *badger.Txn, diamondReceiverPKID *PKID, diamondSenderPKID *PKID, diamondPostHash *BlockHash) *DiamondEntry
type DiamondKey ¶
func MakeDiamondKey ¶
func MakeDiamondKey(senderPKID *PKID, receiverPKID *PKID, diamondPostHash *BlockHash) DiamondKey
func (*DiamondKey) String ¶
func (mm *DiamondKey) String() string
type ExpectedBitcoinResponse ¶
type ExpectedResponse ¶
ExpectedResponse is a struct used to enforce timeouts on peers. For example, if we send a GetBlocks message, we would expect a response within a given window and disconnect from the Peer if we don't get that response.
type FollowEntry ¶
type FollowEntry struct { // Note: It's a little redundant to have these in the entry because they're // already used as the key in the DB but it doesn't hurt for now. FollowerPKID *PKID FollowedPKID *PKID // contains filtered or unexported fields }
FollowEntry stores the content of a follow transaction.
type FollowKey ¶
func MakeFollowKey ¶
type FollowMetadata ¶
type FollowMetadata struct { // The public key to follow. FollowedPublicKey []byte // Set to true when a user is requesting to unfollow. IsUnfollow bool }
func (*FollowMetadata) FromBytes ¶
func (txnData *FollowMetadata) FromBytes(data []byte) error
func (*FollowMetadata) GetTxnType ¶
func (txnData *FollowMetadata) GetTxnType() TxnType
func (*FollowMetadata) New ¶
func (txnData *FollowMetadata) New() BitCloutTxnMetadata
type FollowTxindexMetadata ¶
type FollowTxindexMetadata struct {
IsUnfollow bool
}
type ForbiddenPubKeyEntry ¶
type ForbiddenPubKeyEntry struct { PubKey []byte // contains filtered or unexported fields }
Entry for a public key forbidden from signing blocks.
type GetDataRequestInfo ¶
GetDataRequestInfo is a data structure used to keep track of which transactions we've requested from a Peer.
type GlobalParamsEntry ¶
type GlobalParamsEntry struct { // The new exchange rate to set. USDCentsPerBitcoin uint64 // The new create profile fee CreateProfileFeeNanos uint64 // The fee to create a single NFT (NFTs with n copies incur n of these fees). CreateNFTFeeNanos uint64 // The maximum number of NFT copies that are allowed to be minted. MaxCopiesPerNFT uint64 // The new minimum fee the network will accept MinimumNetworkFeeNanosPerKB uint64 }
func DbGetGlobalParamsEntry ¶
func DbGetGlobalParamsEntry(handle *badger.DB) *GlobalParamsEntry
func DbGetGlobalParamsEntryWithTxn ¶
func DbGetGlobalParamsEntryWithTxn(txn *badger.Txn) *GlobalParamsEntry
type InvType ¶
type InvType uint32
InvType represents the allowed types of inventory vectors. See InvVect.
These constants define the various supported inventory vector types.
type InvVect ¶
InvVect defines an inventory vector which is used to describe data, as specified by the Type field, that a peer wants, has, or does not have to another peer.
type LikeEntry ¶
type LikeEntry struct { LikerPubKey []byte LikedPostHash *BlockHash // contains filtered or unexported fields }
LikeEntry stores the content of a like transaction.
type LikeKey ¶
func MakeLikeKey ¶
type LikeMetadata ¶
type LikeMetadata struct { // The post hash to like. LikedPostHash *BlockHash // Set to true when a user is requesting to unlike a post. IsUnlike bool }
func (*LikeMetadata) FromBytes ¶
func (txnData *LikeMetadata) FromBytes(data []byte) error
func (*LikeMetadata) GetTxnType ¶
func (txnData *LikeMetadata) GetTxnType() TxnType
func (*LikeMetadata) New ¶
func (txnData *LikeMetadata) New() BitCloutTxnMetadata
type LikeTxindexMetadata ¶
type MempoolTx ¶
type MempoolTx struct { Tx *MsgBitCloutTxn // TxMeta is the transaction metadata TxMeta *TransactionMetadata // Hash is a hash of the transaction so we don't have to recompute // it all the time. Hash *BlockHash // TxSizeBytes is the cached size of the transaction. TxSizeBytes uint64 // The time when the txn was added to the pool Added time.Time // The block height when the txn was added to the pool. It's generally set // to tip+1. Height uint32 // The total fee the txn pays. Cached for efficiency reasons. Fee uint64 // The fee rate of the transaction in nanos per KB. FeePerKB uint64 // contains filtered or unexported fields }
MempoolTx contains a transaction along with additional metadata like the fee and time added.
type MempoolTxFeeMinHeap ¶
type MempoolTxFeeMinHeap []*MempoolTx
MempoolTxFeeMinHeap is a priority queue based on transaction fee rate
func (MempoolTxFeeMinHeap) Len ¶
func (pq MempoolTxFeeMinHeap) Len() int
func (MempoolTxFeeMinHeap) Less ¶
func (pq MempoolTxFeeMinHeap) Less(i, j int) bool
func (*MempoolTxFeeMinHeap) Pop ¶
func (pq *MempoolTxFeeMinHeap) Pop() interface{}
func (*MempoolTxFeeMinHeap) Push ¶
func (pq *MempoolTxFeeMinHeap) Push(x interface{})
func (MempoolTxFeeMinHeap) Swap ¶
func (pq MempoolTxFeeMinHeap) Swap(i, j int)
type MessageEntry ¶
type MessageEntry struct { SenderPublicKey []byte RecipientPublicKey []byte EncryptedText []byte // TODO: Right now a sender can fake the timestamp and make it appear to // the recipient that she sent messages much earlier than she actually did. // This isn't a big deal because there is generally not much to gain from // faking a timestamp, and it's still impossible for a user to impersonate // another user, which is the important thing. Moreover, it is easy to fix // the timestamp spoofing issue: You just need to make it so that the nodes // index messages based on block height in addition to on the tstamp. The // reason I didn't do it yet is because it adds some complexity around // detecting duplicates, particularly if a transaction is allowed to have // zero inputs/outputs, which is advantageous for various reasons. TstampNanos uint64 // Indicates message encryption method // Version = 2 : message encrypted using shared secret // Version = 1 : message encrypted using public key Version uint8 // contains filtered or unexported fields }
MessageEntry stores the essential content of a message transaction.
func DbGetLimitedMessageEntriesForPublicKey ¶
func DbGetLimitedMessageEntriesForPublicKey(handle *badger.DB, publicKey []byte) ( _privateMessages []*MessageEntry, _err error)
func DbGetMessageEntriesForPublicKey ¶
func DbGetMessageEntriesForPublicKey(handle *badger.DB, publicKey []byte) ( _privateMessages []*MessageEntry, _err error)
func DbGetMessageEntry ¶
func DbGetMessageEntry(db *badger.DB, publicKey []byte, tstampNanos uint64) *MessageEntry
func DbGetMessageEntryWithTxn ¶
func DbGetMessageEntryWithTxn( txn *badger.Txn, publicKey []byte, tstampNanos uint64) *MessageEntry
type MessageKey ¶
func MakeMessageKey ¶
func MakeMessageKey(pk []byte, tstampNanos uint64) MessageKey
func (*MessageKey) String ¶
func (mm *MessageKey) String() string
func (*MessageKey) StringKey ¶
func (mm *MessageKey) StringKey(params *BitCloutParams) string
StringKey is useful for creating maps that need to be serialized to JSON.
type MsgBitCloutAddr ¶
type MsgBitCloutAddr struct { // The definition of NetAddress as defined by the btcd guys works fine for // our purposes. The only difference is that for BitClout nodes, the Service // flag in the NetAddress is as we define it above in ServiceFlag. // Note that we also rewrite the serialization logic as well to avoid // relying on potentially crusty Bitcoin-related work-arounds going forward. AddrList []*SingleAddr }
func (*MsgBitCloutAddr) FromBytes ¶
func (msg *MsgBitCloutAddr) FromBytes(data []byte) error
func (*MsgBitCloutAddr) GetMsgType ¶
func (msg *MsgBitCloutAddr) GetMsgType() MsgType
func (*MsgBitCloutAddr) String ¶
func (msg *MsgBitCloutAddr) String() string
type MsgBitCloutBitcoinManagerUpdate ¶
type MsgBitCloutBitcoinManagerUpdate struct { // Keep it simple for now. A BitcoinManagerUpdate just signals that // the BitcoinManager has added at least one block or done a reorg. // No serialization because we don't want this sent on the wire ever. TransactionsFound []*MsgBitCloutTxn }
func (*MsgBitCloutBitcoinManagerUpdate) FromBytes ¶
func (msg *MsgBitCloutBitcoinManagerUpdate) FromBytes(data []byte) error
func (*MsgBitCloutBitcoinManagerUpdate) GetMsgType ¶
func (msg *MsgBitCloutBitcoinManagerUpdate) GetMsgType() MsgType
type MsgBitCloutBlock ¶
type MsgBitCloutBlock struct { Header *MsgBitCloutHeader Txns []*MsgBitCloutTxn // This field is optional and provides the producer of the block the ability to sign it // with their private key. Doing this proves that this block was produced by a particular // entity, which can be useful for nodes that want to restrict who they accept blocks // from. BlockProducerInfo *BlockProducerInfo }
func GetBlock ¶
func GetBlock(blockHash *BlockHash, handle *badger.DB) (*MsgBitCloutBlock, error)
func GetBlockWithTxn ¶
func GetBlockWithTxn(txn *badger.Txn, blockHash *BlockHash) *MsgBitCloutBlock
func (*MsgBitCloutBlock) EncodeBlockCommmon ¶
func (msg *MsgBitCloutBlock) EncodeBlockCommmon(preSignature bool) ([]byte, error)
func (*MsgBitCloutBlock) EncodeBlockVersion0 ¶
func (msg *MsgBitCloutBlock) EncodeBlockVersion0(preSignature bool) ([]byte, error)
func (*MsgBitCloutBlock) EncodeBlockVersion1 ¶
func (msg *MsgBitCloutBlock) EncodeBlockVersion1(preSignature bool) ([]byte, error)
func (*MsgBitCloutBlock) FromBytes ¶
func (msg *MsgBitCloutBlock) FromBytes(data []byte) error
func (*MsgBitCloutBlock) GetMsgType ¶
func (msg *MsgBitCloutBlock) GetMsgType() MsgType
func (*MsgBitCloutBlock) Hash ¶
func (msg *MsgBitCloutBlock) Hash() (*BlockHash, error)
func (*MsgBitCloutBlock) String ¶
func (msg *MsgBitCloutBlock) String() string
type MsgBitCloutBlockAccepted ¶
type MsgBitCloutBlockAccepted struct {
// contains filtered or unexported fields
}
func (*MsgBitCloutBlockAccepted) FromBytes ¶
func (msg *MsgBitCloutBlockAccepted) FromBytes(data []byte) error
func (*MsgBitCloutBlockAccepted) GetMsgType ¶
func (msg *MsgBitCloutBlockAccepted) GetMsgType() MsgType
type MsgBitCloutDonePeer ¶
type MsgBitCloutDonePeer struct { }
func (*MsgBitCloutDonePeer) FromBytes ¶
func (msg *MsgBitCloutDonePeer) FromBytes(data []byte) error
func (*MsgBitCloutDonePeer) GetMsgType ¶
func (msg *MsgBitCloutDonePeer) GetMsgType() MsgType
type MsgBitCloutGetAddr ¶
type MsgBitCloutGetAddr struct { }
func (*MsgBitCloutGetAddr) FromBytes ¶
func (msg *MsgBitCloutGetAddr) FromBytes(data []byte) error
func (*MsgBitCloutGetAddr) GetMsgType ¶
func (msg *MsgBitCloutGetAddr) GetMsgType() MsgType
type MsgBitCloutGetBlocks ¶
type MsgBitCloutGetBlocks struct {
HashList []*BlockHash
}
func (*MsgBitCloutGetBlocks) FromBytes ¶
func (msg *MsgBitCloutGetBlocks) FromBytes(data []byte) error
func (*MsgBitCloutGetBlocks) GetMsgType ¶
func (msg *MsgBitCloutGetBlocks) GetMsgType() MsgType
func (*MsgBitCloutGetBlocks) String ¶
func (msg *MsgBitCloutGetBlocks) String() string
type MsgBitCloutGetHeaders ¶
func (*MsgBitCloutGetHeaders) FromBytes ¶
func (msg *MsgBitCloutGetHeaders) FromBytes(data []byte) error
func (*MsgBitCloutGetHeaders) GetMsgType ¶
func (msg *MsgBitCloutGetHeaders) GetMsgType() MsgType
func (*MsgBitCloutGetHeaders) String ¶
func (msg *MsgBitCloutGetHeaders) String() string
type MsgBitCloutGetTransactions ¶
type MsgBitCloutGetTransactions struct {
HashList []*BlockHash
}
func (*MsgBitCloutGetTransactions) FromBytes ¶
func (msg *MsgBitCloutGetTransactions) FromBytes(data []byte) error
func (*MsgBitCloutGetTransactions) GetMsgType ¶
func (msg *MsgBitCloutGetTransactions) GetMsgType() MsgType
func (*MsgBitCloutGetTransactions) String ¶
func (msg *MsgBitCloutGetTransactions) String() string
type MsgBitCloutHeader ¶
type MsgBitCloutHeader struct { // Note this is encoded as a fixed-width uint32 rather than a // uvarint or a uint64. Version uint32 // Hash of the previous block in the chain. PrevBlockHash *BlockHash // The merkle root of all the transactions contained within the block. TransactionMerkleRoot *BlockHash // The unix timestamp (in seconds) specifying when this block was // mined. TstampSecs uint64 // The height of the block this header corresponds to. Height uint64 // The nonce that is used by miners in order to produce valid blocks. // // Note: Before the upgrade from HeaderVersion0 to HeaderVersion1, miners would make // use of ExtraData in the BlockRewardMetadata to get extra nonces. However, this is // no longer needed since HeaderVersion1 upgraded the nonce to 64 bits from 32 bits. Nonce uint64 // An extra nonce that can be used to provice *even more* entropy for miners, in the // event that ASICs become powerful enough to have birthday problems in the future. ExtraNonce uint64 }
MsgBitCloutHeader definition.
Note that all of these fields must be encoded as *full* big-endian ints/uints rather than varints. This is because these fields are hashed to produce a block and allowing them to be varints will heavily incentivize miners to keep them short, which corrupts their actual utility.
Additionally note that it's particularly important that headers be space-efficient, since light clients will need to download an entire history of them in order to be able to validate anything.
func DecodeHeader ¶
func DecodeHeader(rr io.Reader) (*MsgBitCloutHeader, error)
func DecodeHeaderVersion0 ¶
func DecodeHeaderVersion0(rr io.Reader) (*MsgBitCloutHeader, error)
func DecodeHeaderVersion1 ¶
func DecodeHeaderVersion1(rr io.Reader) (*MsgBitCloutHeader, error)
func (*MsgBitCloutHeader) EncodeHeaderVersion0 ¶
func (msg *MsgBitCloutHeader) EncodeHeaderVersion0(preSignature bool) ([]byte, error)
func (*MsgBitCloutHeader) EncodeHeaderVersion1 ¶
func (msg *MsgBitCloutHeader) EncodeHeaderVersion1(preSignature bool) ([]byte, error)
func (*MsgBitCloutHeader) FromBytes ¶
func (msg *MsgBitCloutHeader) FromBytes(data []byte) error
func (*MsgBitCloutHeader) GetMsgType ¶
func (msg *MsgBitCloutHeader) GetMsgType() MsgType
func (*MsgBitCloutHeader) Hash ¶
func (msg *MsgBitCloutHeader) Hash() (*BlockHash, error)
Hash is a helper function to compute a hash of the header. Note that the header hash is special in that we always hash it using the ProofOfWorkHash rather than Sha256DoubleHash.
func (*MsgBitCloutHeader) String ¶
func (msg *MsgBitCloutHeader) String() string
type MsgBitCloutHeaderBundle ¶
type MsgBitCloutHeaderBundle struct { Headers []*MsgBitCloutHeader TipHash *BlockHash TipHeight uint32 }
func (*MsgBitCloutHeaderBundle) FromBytes ¶
func (msg *MsgBitCloutHeaderBundle) FromBytes(data []byte) error
func (*MsgBitCloutHeaderBundle) GetMsgType ¶
func (msg *MsgBitCloutHeaderBundle) GetMsgType() MsgType
func (*MsgBitCloutHeaderBundle) String ¶
func (msg *MsgBitCloutHeaderBundle) String() string
type MsgBitCloutInv ¶
type MsgBitCloutInv struct { InvList []*InvVect // IsSyncResponse indicates that the inv was sent in response to a sync message. // This indicates that the node shouldn't relay it to peers because they likely // already have it. IsSyncResponse bool }
func (*MsgBitCloutInv) FromBytes ¶
func (msg *MsgBitCloutInv) FromBytes(data []byte) error
func (*MsgBitCloutInv) GetMsgType ¶
func (msg *MsgBitCloutInv) GetMsgType() MsgType
func (*MsgBitCloutInv) String ¶
func (msg *MsgBitCloutInv) String() string
type MsgBitCloutMempool ¶
type MsgBitCloutMempool struct { }
func (*MsgBitCloutMempool) FromBytes ¶
func (msg *MsgBitCloutMempool) FromBytes(data []byte) error
func (*MsgBitCloutMempool) GetMsgType ¶
func (msg *MsgBitCloutMempool) GetMsgType() MsgType
func (*MsgBitCloutMempool) String ¶
func (msg *MsgBitCloutMempool) String() string
type MsgBitCloutNewPeer ¶
type MsgBitCloutNewPeer struct { }
func (*MsgBitCloutNewPeer) FromBytes ¶
func (msg *MsgBitCloutNewPeer) FromBytes(data []byte) error
func (*MsgBitCloutNewPeer) GetMsgType ¶
func (msg *MsgBitCloutNewPeer) GetMsgType() MsgType
type MsgBitCloutPing ¶
type MsgBitCloutPing struct {
Nonce uint64
}
func (*MsgBitCloutPing) FromBytes ¶
func (msg *MsgBitCloutPing) FromBytes(data []byte) error
func (*MsgBitCloutPing) GetMsgType ¶
func (msg *MsgBitCloutPing) GetMsgType() MsgType
type MsgBitCloutPong ¶
type MsgBitCloutPong struct {
Nonce uint64
}
func (*MsgBitCloutPong) FromBytes ¶
func (msg *MsgBitCloutPong) FromBytes(data []byte) error
func (*MsgBitCloutPong) GetMsgType ¶
func (msg *MsgBitCloutPong) GetMsgType() MsgType
type MsgBitCloutQuit ¶
type MsgBitCloutQuit struct { }
func (*MsgBitCloutQuit) FromBytes ¶
func (msg *MsgBitCloutQuit) FromBytes(data []byte) error
func (*MsgBitCloutQuit) GetMsgType ¶
func (msg *MsgBitCloutQuit) GetMsgType() MsgType
type MsgBitCloutTransactionBundle ¶
type MsgBitCloutTransactionBundle struct {
Transactions []*MsgBitCloutTxn
}
func (*MsgBitCloutTransactionBundle) FromBytes ¶
func (msg *MsgBitCloutTransactionBundle) FromBytes(data []byte) error
func (*MsgBitCloutTransactionBundle) GetMsgType ¶
func (msg *MsgBitCloutTransactionBundle) GetMsgType() MsgType
func (*MsgBitCloutTransactionBundle) String ¶
func (msg *MsgBitCloutTransactionBundle) String() string
type MsgBitCloutTxn ¶
type MsgBitCloutTxn struct { TxInputs []*BitCloutInput TxOutputs []*BitCloutOutput // BitCloutTxnMetadata is an interface type that will give us information on how // we should handle the transaction, including what type of transaction this // is. TxnMeta BitCloutTxnMetadata // Transactions must generally explicitly include the key that is // spending the inputs to the transaction. The exception to this rule is that // BlockReward and BitcoinExchange transactions do not require the inclusion // of a public key since they have no inputs to spend. // // The public key should be a serialized compressed ECDSA public key on the // secp256k1 curve. PublicKey []byte // This is typically a JSON field that can be used to add extra information to // a transaction without causing a hard fork. It is useful in rare cases where we // realize that something needs to be added to a transaction but where we can't // afford a hard fork. ExtraData map[string][]byte // Transactions must generally be signed by the key that is spending the // inputs to the transaction. The exception to this rule is that // BLOCK_REWARD and CREATE_bitclout transactions do not require a signature // since they have no inputs. Signature *btcec.Signature // (!!) **DO_NOT_USE** (!!) // // Use txn.TxnMeta.GetTxnType() instead. // // We need this for JSON encoding/decoding. It isn't used for anything // else and it isn't actually serialized or de-serialized when sent // across the network using ToBytes/FromBytes because we prefer that // any use of the MsgBitCloutTxn in Go code rely on TxnMeta.GetTxnType() rather // than checking this value, which, in Go context, is redundant and // therefore error-prone (e.g. someone might change TxnMeta while // forgetting to set it). We make it a uint64 explicitly to prevent // people from using it in Go code. TxnTypeJSON uint64 }
func DbGetAllMempoolTxnsSortedByTimeAdded ¶
func DbGetAllMempoolTxnsSortedByTimeAdded(handle *badger.DB) (_mempoolTxns []*MsgBitCloutTxn, _error error)
func DbGetMempoolTxn ¶
func DbGetMempoolTxn(db *badger.DB, mempoolTx *MempoolTx) *MsgBitCloutTxn
func DbGetMempoolTxnWithTxn ¶
func DbGetMempoolTxnWithTxn(txn *badger.Txn, mempoolTx *MempoolTx) *MsgBitCloutTxn
func ExtractBitcoinExchangeTransactionsFromBitcoinBlock ¶
func ExtractBitcoinExchangeTransactionsFromBitcoinBlock( bitcoinBlock *wire.MsgBlock, burnAddress string, params *BitCloutParams) ( _txns []*MsgBitCloutTxn, _err error)
func (*MsgBitCloutTxn) Copy ¶
func (msg *MsgBitCloutTxn) Copy() (*MsgBitCloutTxn, error)
func (*MsgBitCloutTxn) FromBytes ¶
func (msg *MsgBitCloutTxn) FromBytes(data []byte) error
func (*MsgBitCloutTxn) GetMsgType ¶
func (msg *MsgBitCloutTxn) GetMsgType() MsgType
func (*MsgBitCloutTxn) Hash ¶
func (msg *MsgBitCloutTxn) Hash() *BlockHash
Hash is a helper function to compute a hash of the transaction aka a transaction ID.
func (*MsgBitCloutTxn) MarshalJSON ¶
func (msg *MsgBitCloutTxn) MarshalJSON() ([]byte, error)
MarshalJSON and UnmarshalJSON implement custom JSON marshaling/unmarshaling to support transaction metadata. The reason this needs to exist is because TxnMeta is an abstract interface and therefore when its decoded to JSON, the type information (i.e. which TxnType it is) cannot be inferred from the JSON unless we augment it a little bit. Note this format is not used to relay messages between nodes, only for replying to frontend/user-facing queries.
func (*MsgBitCloutTxn) Sign ¶
func (msg *MsgBitCloutTxn) Sign(privKey *btcec.PrivateKey) (*btcec.Signature, error)
func (*MsgBitCloutTxn) String ¶
func (msg *MsgBitCloutTxn) String() string
func (*MsgBitCloutTxn) ToBytes ¶
func (msg *MsgBitCloutTxn) ToBytes(preSignature bool) ([]byte, error)
func (*MsgBitCloutTxn) UnmarshalJSON ¶
func (msg *MsgBitCloutTxn) UnmarshalJSON(data []byte) error
UnmarshalJSON is covered by the comment on MarshalJSON.
type MsgBitCloutVerack ¶
type MsgBitCloutVerack struct { // A verack message must contain the nonce the peer received in the // initial version message. This ensures the peer that is communicating // with us actually controls the address she says she does similar to // "SYN Cookie" DDOS protection. Nonce uint64 }
VERACK messages have no payload.
func (*MsgBitCloutVerack) FromBytes ¶
func (msg *MsgBitCloutVerack) FromBytes(data []byte) error
func (*MsgBitCloutVerack) GetMsgType ¶
func (msg *MsgBitCloutVerack) GetMsgType() MsgType
type MsgBitCloutVersion ¶
type MsgBitCloutVersion struct { // What is the current version we're on? Version uint64 // What are the services offered by this node? Services ServiceFlag // The node's unix timestamp that we use to compute a // robust "network time" using NTP. TstampSecs int64 // Used to detect when a node connects to itself, which // we generally want to prevent. Nonce uint64 // Used as a "vanity plate" to identify different BitClout // clients. Mainly useful in analyzing the network at // a meta level, not in the protocol itself. UserAgent string // The height of the last block on the main chain for // this node. // // TODO: We need to update this to uint64 StartBlockHeight uint32 // MinFeeRateNanosPerKB is the minimum feerate that a peer will // accept from other peers when validating transactions. MinFeeRateNanosPerKB uint64 }
func (*MsgBitCloutVersion) FromBytes ¶
func (msg *MsgBitCloutVersion) FromBytes(data []byte) error
func (*MsgBitCloutVersion) GetMsgType ¶
func (msg *MsgBitCloutVersion) GetMsgType() MsgType
type MsgType ¶
type MsgType uint64
The MsgType is usually sent on the wire to indicate what type of struct is being sent in the payload part of the message.
const ( // ControlMessagesStart is used to indicate the ID value at which control // messages start. Anything with an ID value greater than or equal to this // is a control message. ControlMessagesStart = 1000000 MsgTypeUnset MsgType = 0 // // The first message a peer sends. Used to negotiate a version // between the two peers. MsgTypeVersion MsgType = 1 // // Sent after a peer has both sent its version message // and received its peer's version message and completed // the version negotiation. MsgTypeVerack MsgType = 2 MsgTypeHeader MsgType = 3 MsgTypeBlock MsgType = 4 MsgTypeTxn MsgType = 5 // MsgTypeGetHeaders is used to fetch headers from a peer. MsgTypeGetHeaders MsgType = 6 // MsgTypeHeaderBundle contains headers from a peer. MsgTypeHeaderBundle MsgType = 7 MsgTypePing MsgType = 8 MsgTypePong MsgType = 9 MsgTypeInv MsgType = 10 MsgTypeGetBlocks MsgType = 11 MsgTypeGetTransactions MsgType = 12 // MsgTypeTransactionBundle contains transactions from a peer. MsgTypeTransactionBundle MsgType = 13 MsgTypeMempool MsgType = 14 // MsgTypeAddr is used by peers to share addresses of nodes they're aware about // with other peers. MsgTypeAddr MsgType = 15 // MsgTypeGetAddr is used to solicit Addr messages from peers. MsgTypeGetAddr MsgType = 16 MsgTypeQuit MsgType = ControlMessagesStart MsgTypeNewPeer MsgType = ControlMessagesStart + 1 MsgTypeDonePeer MsgType = ControlMessagesStart + 2 MsgTypeBlockAccepted MsgType = ControlMessagesStart + 3 MsgTypeBitcoinManagerUpdate MsgType = ControlMessagesStart + 4 )
type MsgWithError ¶
type MsgWithError struct {
// contains filtered or unexported fields
}
type NFTBidEntry ¶
type NFTBidEntry struct { BidderPKID *PKID NFTPostHash *BlockHash SerialNumber uint64 BidAmountNanos uint64 // contains filtered or unexported fields }
This struct defines a single bid on an NFT.
func DBGetNFTBidEntries ¶
func DBGetNFTBidEntries(handle *badger.DB, nftPostHash *BlockHash, serialNumber uint64, ) (_nftBidEntries []*NFTBidEntry)
Get NFT bid Entries *from the DB*. Does not include mempool txns.
func DBGetNFTBidEntriesForPKID ¶
func DBGetNFTBidEntriesForPKID(handle *badger.DB, bidderPKID *PKID) (_nftBidEntries []*NFTBidEntry)
func DBGetNFTBidEntriesPaginated ¶
func DBGetNFTBidEntriesPaginated( handle *badger.DB, nftHash *BlockHash, serialNumber uint64, startEntry *NFTBidEntry, limit int, reverse bool, ) (_bidEntries []*NFTBidEntry)
func DBGetNFTBidEntryForNFTBidKey ¶
func DBGetNFTBidEntryForNFTBidKey(db *badger.DB, nftBidKey *NFTBidKey) *NFTBidEntry
func DBGetNFTBidEntryForNFTBidKeyWithTxn ¶
func DBGetNFTBidEntryForNFTBidKeyWithTxn(txn *badger.Txn, nftBidKey *NFTBidKey) *NFTBidEntry
type NFTBidMetadata ¶
func (*NFTBidMetadata) FromBytes ¶
func (txnData *NFTBidMetadata) FromBytes(dataa []byte) error
func (*NFTBidMetadata) GetTxnType ¶
func (txnData *NFTBidMetadata) GetTxnType() TxnType
func (*NFTBidMetadata) New ¶
func (txnData *NFTBidMetadata) New() BitCloutTxnMetadata
type NFTBidTxindexMetadata ¶
type NFTEntry ¶
type NFTEntry struct { LastOwnerPKID *PKID // This is needed to decrypt unlockable text. OwnerPKID *PKID NFTPostHash *BlockHash SerialNumber uint64 IsForSale bool MinBidAmountNanos uint64 UnlockableText []byte LastAcceptedBidAmountNanos uint64 // contains filtered or unexported fields }
This struct defines an individual NFT owned by a PKID. An NFT entry maps to a single postEntry, but a single postEntry can map to multiple NFT entries. Each NFT copy is defined by a serial number, which denotes it's place in the set (ie. #1 of 100).
func DBGetNFTEntriesForPKID ¶
DBGetNFTEntriesForPKID gets NFT Entries *from the DB*. Does not include mempool txns.
func DBGetNFTEntriesForPostHash ¶
func DBGetNFTEntriesForPostHash(handle *badger.DB, nftPostHash *BlockHash) (_nftEntries []*NFTEntry)
DBGetNFTEntriesForPostHash gets NFT Entries *from the DB*. Does not include mempool txns.
type NFTKey ¶
func MakeNFTKey ¶
type NetworkType ¶
type NetworkType uint64
const ( // The different network types. For now we have a mainnet and a testnet. // Also create an UNSET value to catch errors. NetworkType_UNSET NetworkType = 0 NetworkType_MAINNET NetworkType = 1 NetworkType_TESTNET NetworkType = 2 )
func (NetworkType) String ¶
func (nt NetworkType) String() string
type OperationType ¶
type OperationType uint
const ( // Every operation has a type that we document here. This information is // used when rolling back a txn to determine what kind of operations need // to be performed. For example, rolling back a BitcoinExchange may require // rolling back an AddUtxo operation. OperationTypeAddUtxo OperationType = 0 OperationTypeSpendUtxo OperationType = 1 OperationTypeBitcoinExchange OperationType = 2 OperationTypePrivateMessage OperationType = 3 OperationTypeSubmitPost OperationType = 4 OperationTypeUpdateProfile OperationType = 5 OperationTypeDeletePost OperationType = 7 OperationTypeUpdateBitcoinUSDExchangeRate OperationType = 8 OperationTypeFollow OperationType = 9 OperationTypeLike OperationType = 10 OperationTypeCreatorCoin OperationType = 11 OperationTypeSwapIdentity OperationType = 12 OperationTypeUpdateGlobalParams OperationType = 13 OperationTypeCreatorCoinTransfer OperationType = 14 OperationTypeCreateNFT OperationType = 15 OperationTypeUpdateNFT OperationType = 16 OperationTypeAcceptNFTBid OperationType = 17 OperationTypeNFTBid OperationType = 18 OperationTypeBitCloutDiamond OperationType = 19 )
func (OperationType) String ¶
func (op OperationType) String() string
type OrphanBlock ¶
type OrphanBlock struct { Block *MsgBitCloutBlock Hash *BlockHash }
type PKID ¶
type PKID [33]byte
A PKID is an ID associated with a public key. In the DB, various fields are indexed using the PKID rather than the user's public key directly in order to create one layer of indirection between the public key and the user's data. This makes it easy for the user to transfer certain data to a new public key.
func DBGetPKIDForUsername ¶
func DbGetPKIDsFollowingYou ¶
func DbGetPKIDsYouFollow ¶
func PublicKeyToPKID ¶
type PKIDEntry ¶
type PKIDEntry struct { PKID *PKID // We add the public key only so we can reuse this struct to store the reverse // mapping of pkid -> public key. PublicKey []byte // contains filtered or unexported fields }
type Peer ¶
type Peer struct { // Stats that should be accessed using the mutex below. StatsMtx deadlock.RWMutex ID uint64 // Ping-related fields. LastPingNonce uint64 LastPingTime time.Time LastPingMicros int64 Params *BitCloutParams MessageChan chan *ServerMessage // A hack to make it so that we can allow an API endpoint to manually // delete a peer. PeerManuallyRemovedFromConnectionManager bool // Basic state. PeerInfoMtx deadlock.Mutex // contains filtered or unexported fields }
Peer is an object that holds all of the state for a connection to another node. Any communication with other nodes happens via this object, which maintains a queue of messages to send to the other node.
func NewPeer ¶
func NewPeer(_conn net.Conn, _isOutbound bool, _netAddr *wire.NetAddress, _isPersistent bool, _stallTimeoutSeconds uint64, _ignoreUnminedBitcoinTxnsFromPeers bool, _blockCypherAPIKey string, _minFeeRateNanosPerKB uint64, params *BitCloutParams, messageChan chan *ServerMessage, _cmgr *ConnectionManager, _srv *Server) *Peer
NewPeer creates a new Peer object.
func (*Peer) AddBitCloutMessage ¶
func (pp *Peer) AddBitCloutMessage(bitcloutMessage BitCloutMessage, inbound bool)
func (*Peer) Disconnect ¶
func (pp *Peer) Disconnect()
Disconnect closes a peer's network connection.
func (*Peer) HandleGetBlocks ¶
func (pp *Peer) HandleGetBlocks(msg *MsgBitCloutGetBlocks)
func (*Peer) HandleGetTransactionsMsg ¶
func (pp *Peer) HandleGetTransactionsMsg(getTxnMsg *MsgBitCloutGetTransactions)
This call blocks on the Peer's queue.
func (*Peer) HandleInv ¶
func (pp *Peer) HandleInv(msg *MsgBitCloutInv)
func (*Peer) HandleTransactionBundleMessage ¶
func (pp *Peer) HandleTransactionBundleMessage(msg *MsgBitCloutTransactionBundle)
func (*Peer) HelpHandleInv ¶
func (pp *Peer) HelpHandleInv(msg *MsgBitCloutInv)
func (*Peer) IsOutbound ¶
func (*Peer) IsSyncCandidate ¶
func (*Peer) MaybeDequeueBitCloutMessage ¶
func (pp *Peer) MaybeDequeueBitCloutMessage() *BitCloutMessageMeta
func (*Peer) MinFeeRateNanosPerKB ¶
MinFeeRateNanosPerKB returns the minimum fee rate this peer requires in order to accept transactions into its mempool. We should generally not send a peer a transaction below this fee rate.
func (*Peer) NegotiateVersion ¶
func (*Peer) NewVersionMessage ¶
func (pp *Peer) NewVersionMessage(params *BitCloutParams) *MsgBitCloutVersion
func (*Peer) NumBlocksToSend ¶
NumBlocksToSend is the number of blocks the Peer has requested from us that we have yet to send them.
func (*Peer) QueueMessage ¶
func (pp *Peer) QueueMessage(bitcloutMessage BitCloutMessage)
func (*Peer) ReadBitCloutMessage ¶
func (pp *Peer) ReadBitCloutMessage() (BitCloutMessage, error)
func (*Peer) StartBitCloutMessageProcessor ¶
func (pp *Peer) StartBitCloutMessageProcessor()
func (*Peer) StartingBlockHeight ¶
StartingBlockHeight is the height of the peer's blockchain tip.
func (*Peer) WriteBitCloutMessage ¶
func (pp *Peer) WriteBitCloutMessage(msg BitCloutMessage) error
type PostEntry ¶
type PostEntry struct { // The hash of this post entry. Used as the ID for the entry. PostHash *BlockHash // The public key of the user who made the post. PosterPublicKey []byte // The parent post. This is used for comments. ParentStakeID []byte // The body of this post. Body []byte // The PostHash of the post this post reclouts RecloutedPostHash *BlockHash // Indicator if this PostEntry is a quoted reclout or not IsQuotedReclout bool // The amount the creator of the post gets when someone stakes // to the post. CreatorBasisPoints uint64 // The multiple of the payout when a user stakes to a post. // 2x multiple = 200% = 20,000bps StakeMultipleBasisPoints uint64 // The block height when the post was confirmed. ConfirmationBlockHeight uint32 // A timestamp used for ordering messages when displaying them to // users. The timestamp must be unique. Note that we use a nanosecond // timestamp because it makes it easier to deal with the uniqueness // constraint technically (e.g. If one second spacing is required // as would be the case with a standard Unix timestamp then any code // that generates these transactions will need to potentially wait // or else risk a timestamp collision. This complexity is avoided // by just using a nanosecond timestamp). Note that the timestamp is // an unsigned int as opposed to a signed int, which means times // before the zero time are not represented which doesn't matter // for our purposes. Restricting the timestamp in this way makes // lexicographic sorting based on bytes easier in our database which // is one of the reasons we do it. TimestampNanos uint64 // Users can "delete" posts, but right now we just implement this as // setting a flag on the post to hide it rather than actually deleting // it. This simplifies the implementation and makes it easier to "undelete" // posts in certain situations. IsHidden bool // Every post has a StakeEntry that keeps track of all the stakes that // have been applied to this post. StakeEntry *StakeEntry // Counter of users that have liked this post. LikeCount uint64 // Counter of users that have reclouted this post. RecloutCount uint64 // Counter of quote reclouts for this post. QuoteRecloutCount uint64 // Counter of diamonds that the post has received. DiamondCount uint64 // How many comments this post has CommentCount uint64 // Indicator if a post is pinned or not. IsPinned bool // NFT info. IsNFT bool NumNFTCopies uint64 NumNFTCopiesForSale uint64 HasUnlockable bool NFTRoyaltyToCreatorBasisPoints uint64 NFTRoyaltyToCoinBasisPoints uint64 // ExtraData map to hold arbitrary attributes of a post. Holds non-consensus related information about a post. PostExtraData map[string][]byte // contains filtered or unexported fields }
type PostEntryReaderState ¶
type PostEntryReaderState struct { // This is true if the reader has liked the associated post. LikedByReader bool // The number of diamonds that the reader has given this post. DiamondLevelBestowed int64 // This is true if the reader has reclouted the associated post. RecloutedByReader bool // This is the post hash hex of the reclout RecloutPostHashHex string }
This struct holds info on a readers interactions (e.g. likes) with a post. It is added to a post entry response in the frontend server api.
type PrivateMessageMetadata ¶
type PrivateMessageMetadata struct { // The public key of the recipient of the message. RecipientPublicKey []byte // The content of the message. It is encrypted with the recipient's // public key using ECIES. EncryptedText []byte // A timestamp used for ordering messages when displaying them to // users. The timestamp must be unique. Note that we use a nanosecond // timestamp because it makes it easier to deal with the uniqueness // constraint technically (e.g. If one second spacing is required // as would be the case with a standard Unix timestamp then any code // that generates these transactions will need to potentially wait // or else risk a timestamp collision. This complexity is avoided // by just using a nanosecond timestamp). Note that the timestamp is // an unsigned int as opposed to a signed int, which means times // before the zero time are not represented which doesn't matter // for our purposes. Restricting the timestamp in this way makes // lexicographic sorting based on bytes easier in our database which // is one of the reasons we do it. TimestampNanos uint64 }
func (*PrivateMessageMetadata) FromBytes ¶
func (txnData *PrivateMessageMetadata) FromBytes(data []byte) error
func (*PrivateMessageMetadata) GetTxnType ¶
func (txnData *PrivateMessageMetadata) GetTxnType() TxnType
func (*PrivateMessageMetadata) New ¶
func (txnData *PrivateMessageMetadata) New() BitCloutTxnMetadata
type PrivateMessageTxindexMetadata ¶
type PrivateMessageTxindexMetadata struct {
TimestampNanos uint64
}
type ProfileEntry ¶
type ProfileEntry struct { // PublicKey is the key used by the user to sign for things and generally // verify her identity. PublicKey []byte // Username is a unique human-readable identifier associated with a profile. Username []byte // Some text describing the profile. Description []byte // The profile pic string encoded as a link e.g. // data:image/png;base64,<data in base64> ProfilePic []byte // Users can "delete" profiles, but right now we just implement this as // setting a flag on the post to hide it rather than actually deleting // it. This simplifies the implementation and makes it easier to "undelete" // profiles in certain situations. IsHidden bool // CoinEntry tracks the information required to buy/sell coins on a user's // profile. We "embed" it here for convenience so we can access the fields // directly on the ProfileEntry object. Embedding also makes it so that we // don't need to initialize it explicitly. CoinEntry // TODO(DELETEME): This field is deprecated. It was relevant back when // we wanted to allow people to stake to profiles, which isn't something // we want to support going forward. // // The multiple of the payout when a user stakes to this profile. If // unset, a sane default is set when the first person stakes to this // profile. // 2x multiple = 200% = 20,000bps StakeMultipleBasisPoints uint64 // TODO(DELETEME): This field is deprecated. It was relevant back when // we wanted to allow people to stake to profiles, which isn't something // we want to support going forward. // // Every provile has a StakeEntry that keeps track of all the stakes that // have been applied to it. StakeEntry *StakeEntry // contains filtered or unexported fields }
func DBGetPaginatedProfilesByBitCloutLocked ¶
func DBGetPaginatedProfilesByBitCloutLocked( db *badger.DB, startBitCloutLockedNanos uint64, startProfilePubKeyy []byte, numToFetch int, fetchProfileEntries bool) ( _profilePublicKeys [][]byte, _profileEntries []*ProfileEntry, _err error)
DBGetPaginatedProfilesByBitCloutLocked returns up to 'numToFetch' profiles from the db.
func DBGetProfileEntryForPKID ¶
func DBGetProfileEntryForPKID(db *badger.DB, pkid *PKID) *ProfileEntry
func DBGetProfileEntryForPKIDWithTxn ¶
func DBGetProfileEntryForPKIDWithTxn( txn *badger.Txn, pkid *PKID) *ProfileEntry
func DBGetProfileEntryForUsername ¶
func DBGetProfileEntryForUsername(db *badger.DB, username []byte) *ProfileEntry
func DBGetProfileEntryForUsernameWithTxn ¶
func DBGetProfileEntryForUsernameWithTxn( txn *badger.Txn, username []byte) *ProfileEntry
func DBGetProfilesByUsernamePrefixAndBitCloutLocked ¶
func DBGetProfilesByUsernamePrefixAndBitCloutLocked( db *badger.DB, usernamePrefix string, utxoView *UtxoView) ( _profileEntries []*ProfileEntry, _err error)
func (*ProfileEntry) IsDeleted ¶
func (pe *ProfileEntry) IsDeleted() bool
type RecloutEntry ¶
type RecloutEntry struct { ReclouterPubKey []byte // BlockHash of the reclout RecloutPostHash *BlockHash // Post Hash of post that was reclouted RecloutedPostHash *BlockHash // contains filtered or unexported fields }
RecloutEntry stores the content of a Reclout transaction.
func DbGetReclouterPubKeyRecloutedPostHashToRecloutEntryWithTxn ¶
func DbGetReclouterPubKeyRecloutedPostHashToRecloutEntryWithTxn( txn *badger.Txn, userPubKey []byte, recloutedPostHash BlockHash) *RecloutEntry
func DbReclouterPubKeyRecloutedPostHashToRecloutEntry ¶
func DbReclouterPubKeyRecloutedPostHashToRecloutEntry( db *badger.DB, userPubKey []byte, recloutedPostHash BlockHash) *RecloutEntry
type RecloutKey ¶
type RecloutKey struct { ReclouterPubKey PkMapKey // Post Hash of post that was reclouted RecloutedPostHash BlockHash }
func MakeRecloutKey ¶
func MakeRecloutKey(userPk []byte, RecloutedPostHash BlockHash) RecloutKey
type RuleError ¶
type RuleError string
RuleError is an error type that specifies an error occurred during block processing that is related to a consensus rule. By checking the type of the error the caller can determine that the error was due to a consensus rule and determine which consensus rule caused the issue.
const ( RuleErrorDuplicateBlock RuleError = "RuleErrorDuplicateBlock" RuleErrorDuplicateOrphan RuleError = "RuleErrorDuplicateOrphan" RuleErrorMinDifficulty RuleError = "RuleErrorMinDifficulty" RuleErrorBlockTooBig RuleError = "RuleErrorBlockTooBig" RuleErrorNoTxns RuleError = "RuleErrorNoTxns" RuleErrorFirstTxnMustBeBlockReward RuleError = "RuleErrorFirstTxnMustBeBlockReward" RuleErrorMoreThanOneBlockReward RuleError = "RuleErrorMoreThanOneBlockReward" RuleErrorPreviousBlockInvalid RuleError = "RuleErrorPreviousBlockInvalid" RuleErrorPreviousBlockHeaderInvalid RuleError = "RuleErrorPreviousBlockHeaderInvalid" RuleErrorTxnMustHaveAtLeastOneInput RuleError = "RuleErrorTxnMustHaveAtLeastOneInput" RuleErrorTxnMustHaveAtLeastOneOutput RuleError = "RuleErrorTxnMustHaveAtLeastOneOutput" RuleErrorOutputExceedsMax RuleError = "RuleErrorOutputExceedsMax" RuleErrorOutputOverflowsTotal RuleError = "RuleErrorOutputOverflowsTotal" RuleErrorTotalOutputExceedsMax RuleError = "RuleErrorTotalOutputExceedsMax" RuleErrorDuplicateInputs RuleError = "RuleErrorDuplicateInputs" RuleErrorInvalidTxnMerkleRoot RuleError = "RuleErrorInvalidTxnMerkleRoot" RuleErrorDuplicateTxn RuleError = "RuleErrorDuplicateTxn" RuleErrorInputSpendsNonexistentUtxo RuleError = "RuleErrorInputSpendsNonexistentUtxo" RuleErrorInputSpendsPreviouslySpentOutput RuleError = "RuleErrorInputSpendsPreviouslySpentOutput" RuleErrorInputSpendsImmatureBlockReward RuleError = "RuleErrorInputSpendsImmatureBlockReward" RuleErrorInputSpendsOutputWithInvalidAmount RuleError = "RuleErrorInputSpendsOutputWithInvalidAmount" RuleErrorTxnOutputWithInvalidAmount RuleError = "RuleErrorTxnOutputWithInvalidAmount" RuleErrorTxnOutputExceedsInput RuleError = "RuleErrorTxnOutputExceedsInput" RuleErrorTxnFeeBelowNetworkMinimum RuleError = "RuleErrorTxnFeeBelowNetworkMinimum" RuleErrorOverflowDetectedInFeeRateCalculation RuleError = "RuleErrorOverflowDetectedInFeeRateCalculation" RuleErrorBlockRewardOutputWithInvalidAmount RuleError = "RuleErrorBlockRewardOutputWithInvalidAmount" RuleErrorBlockRewardOverflow RuleError = "RuleErrorBlockRewardOverflow" RuleErrorBlockRewardExceedsMaxAllowed RuleError = "RuleErrorBlockRewardExceedsMaxAllowed" RuleErrorProfileUsernameExists RuleError = "RuleErrorProfileUsernameExists" RuleErrorPubKeyLen RuleError = "RuleErrorPubKeyLen" RuleErrorMaxProfilePicSize RuleError = "RuleErrorMaxProfilePicSize" RuleErrorProfileCreatorPercentageSize RuleError = "RuleErrorProfileCreatorPercentageSize" RuleErrorProfileStakeMultipleSize RuleError = "RuleErrorProfileStakeMultipleSize" RuleErrorInvalidUsername RuleError = "RuleErrorInvalidUsername" RuleErrorEncryptedDataLen RuleError = "RuleErrorEncryptedDataLen" RuleErrorInputOverflows RuleError = "RuleErrorInputOverflows" RuleErrorInsufficientRefund RuleError = "RuleErrorInsufficientRefund" RuleErrorMissingSignature RuleError = "RuleErrorMissingSignature" RuleErrorSigHash RuleError = "RuleErrorSigHash" RuleErrorParsePublicKey RuleError = "RuleErrorParsePublicKey" RuleErrorSigCheckFailed RuleError = "RuleErrorSigCheckFailed" RuleErrorOutputPublicKeyNotRecognized RuleError = "RuleErrorOutputPublicKeyNotRecognized" RuleErrorInputsWithDifferingSpendKeys RuleError = "RuleErrorInputsWithDifferingSpendKeys" RuleErrorInvalidTransactionSignature RuleError = "RuleErrorInvalidTransactionSignature" RuleErrorMissingBlockProducerSignature RuleError = "RuleErrorMissingBlockProducerSignature" RuleErrorInvalidBlockProducerPublicKey RuleError = "RuleErrorInvalidBlockProducerPublicKey" RuleErrorBlockProducerPublicKeyNotInWhitelist RuleError = "RuleErrorBlockProducerPublicKeyNotInWhitelist" RuleErrorForbiddenBlockProducerPublicKey RuleError = "RuleErrorForbiddenBlockProducerPublicKey" RuleErrorInvalidBlockProducerSIgnature RuleError = "RuleErrorInvalidBlockProducerSIgnature" RuleErrorInvalidBlockHeader RuleError = "RuleErrorInvalidBlockHeader" RuleErrorOrphanBlock RuleError = "RuleErrorOrphanBlock" RuleErrorInputWithPublicKeyDifferentFromTxnPublicKey RuleError = "RuleErrorInputWithPublicKeyDifferentFromTxnPublicKey" RuleErrorBlockRewardTxnNotAllowedToHaveInputs RuleError = "RuleErrorBlockRewardTxnNotAllowedToHaveInputs" RuleErrorBlockRewardTxnNotAllowedToHaveSignature RuleError = "RuleErrorBlockRewardTxnNotAllowedToHaveSignature" RuleErrorDeflationBombForbidsMintingAnyMoreBitClout RuleError = "RuleErrorDeflationBombForbidsMintingAnyMoreBitClout" RuleErrorBitcoinExchangeShouldNotHaveInputs RuleError = "RuleErrorBitcoinExchangeShouldNotHaveInputs" RuleErrorBitcoinExchangeShouldNotHaveOutputs RuleError = "RuleErrorBitcoinExchangeShouldNotHaveOutputs" RuleErrorBitcoinExchangeShouldNotHavePublicKey RuleError = "RuleErrorBitcoinExchangeShouldNotHavePublicKey" RuleErrorBitcoinExchangeShouldNotHaveSignature RuleError = "RuleErrorBitcoinExchangeShouldNotHaveSignature" RuleErrorBitcoinExchangeHasBadBitcoinTxHash RuleError = "RuleErrorBitcoinExchangeHasBadBitcoinTxHash" RuleErrorBitcoinExchangeDoubleSpendingBitcoinTransaction RuleError = "RuleErrorBitcoinExchangeDoubleSpendingBitcoinTransaction" RuleErrorBitcoinExchangeBlockHashNotFoundInMainBitcoinChain RuleError = "RuleErrorBitcoinExchangeBlockHashNotFoundInMainBitcoinChain" RuleErrorBitcoinExchangeHasBadMerkleRoot RuleError = "RuleErrorBitcoinExchangeHasBadMerkleRoot" RuleErrorBitcoinExchangeInvalidMerkleProof RuleError = "RuleErrorBitcoinExchangeInvalidMerkleProof" RuleErrorBitcoinExchangeValidPublicKeyNotFoundInInputs RuleError = "RuleErrorBitcoinExchangeValidPublicKeyNotFoundInInputs" RuleErrorBitcoinExchangeProblemComputingBurnOutput RuleError = "RuleErrorBitcoinExchangeProblemComputingBurnOutput" RuleErrorBitcoinExchangeFeeOverflow RuleError = "RuleErrorBitcoinExchangeFeeOverflow" RuleErrorBitcoinExchangeTotalOutputLessThanOrEqualZero RuleError = "RuleErrorBitcoinExchangeTotalOutputLessThanOrEqualZero" RuleErrorTxnSanity RuleError = "RuleErrorTxnSanity" RuleErrorTxnTooBig RuleError = "RuleErrorTxnTooBig" RuleErrorPrivateMessageEncryptedTextLengthExceedsMax RuleError = "RuleErrorPrivateMessageEncryptedTextLengthExceedsMax" RuleErrorPrivateMessageRecipientPubKeyLen RuleError = "RuleErrorPrivateMessageRecipientPubKeyLen" RuleErrorPrivateMessageTstampIsZero RuleError = "RuleErrorPrivateMessageTstampIsZero" RuleErrorTransactionMissingPublicKey RuleError = "RuleErrorTransactionMissingPublicKey" RuleErrorPrivateMessageExistsWithSenderPublicKeyTstampTuple RuleError = "RuleErrorPrivateMessageExistsWithSenderPublicKeyTstampTuple" RuleErrorPrivateMessageExistsWithRecipientPublicKeyTstampTuple RuleError = "RuleErrorPrivateMessageExistsWithRecipientPublicKeyTstampTuple" RuleErrorPrivateMessageParsePubKeyError RuleError = "RuleErrorPrivateMessageParsePubKeyError" RuleErrorPrivateMessageSenderPublicKeyEqualsRecipientPublicKey RuleError = "RuleErrorPrivateMessageSenderPublicKeyEqualsRecipientPublicKey" RuleErrorBurnAddressCannotBurnBitcoin RuleError = "RuleErrorBurnAddressCannotBurnBitcoin" RuleErrorFollowPubKeyLen RuleError = "RuleErrorFollowFollowedPubKeyLen" RuleErrorFollowParsePubKeyError RuleError = "RuleErrorFollowParsePubKeyError" RuleErrorFollowEntryAlreadyExists RuleError = "RuleErrorFollowEntryAlreadyExists" RuleErrorFollowingNonexistentProfile RuleError = "RuleErrorFollowingNonexistentProfile" RuleErrorCannotUnfollowNonexistentFollowEntry RuleError = "RuleErrorCannotUnfollowNonexistentFollowEntry" RuleErrorProfilePublicKeyNotEqualToPKIDPublicKey RuleError = "RuleErrorProfilePublicKeyNotEqualToPKIDPublicKey" RuleErrorLikeEntryAlreadyExists RuleError = "RuleErrorLikeEntryAlreadyExists" RuleErrorCannotLikeNonexistentPost RuleError = "RuleErrorCannotLikeNonexistentPost" RuleErrorCannotUnlikeWithoutAnExistingLike RuleError = "RuleErrorCannotUnlikeWithoutAnExistingLike" RuleErrorProfileUsernameTooShort RuleError = "RuleErrorProfileUsernameTooShort" RuleErrorProfileDescriptionTooShort RuleError = "RuleErrorProfileDescriptionTooShort" RuleErrorProfileUsernameTooLong RuleError = "RuleErrorProfileUsernameTooLong" RuleErrorProfileDescriptionTooLong RuleError = "RuleErrorProfileDescriptionTooLong" RuleErrorProfileProfilePicTooShort RuleError = "RuleErrorProfileProfilePicTooShort" RuleErrorProfileUpdateRequiresNonZeroInput RuleError = "RuleErrorProfileUpdateRequiresNonZeroInput" RuleErrorCreateProfileTxnOutputExceedsInput RuleError = "RuleErrorCreateProfileTxnOutputExceedsInput" RuleErrorProfilePublicKeySize RuleError = "RuleErrorProfilePublicKeySize" RuleErrorProfileBadPublicKey RuleError = "RuleErrorProfileBadPublicKey" RuleErrorProfilePubKeyNotAuthorized RuleError = "RuleErrorProfilePubKeyNotAuthorized" RuleErrorProfileModificationNotAuthorized RuleError = "RuleErrorProfileModificationNotAuthorized" RuleErrorProfileUsernameCannotContainZeros RuleError = "RuleErrorProfileUsernameCannotContainZeros" RuleSubmitPostNilParentPostHash RuleError = "RuleSubmitPostNilParentPostHash" RuleSubmitPostTitleLength RuleError = "RuleSubmitPostTitleLength" RuleSubmitPostBodyLength RuleError = "RuleSubmitPostBodyLength" RuleSubmitPostSubLength RuleError = "RuleSubmitPostSubLength" RuleErrorSubmitPostStakeMultipleSize RuleError = "RuleErrorSubmitPostStakeMultipleSize" RuleErrorSubmitPostCreatorPercentageSize RuleError = "RuleErrorSubmitPostCreatorPercentageSize" RuleErrorSubmitPostTimestampIsZero RuleError = "RuleErrorSubmitPostTimestampIsZero" RuleErrorPostAlreadyExists RuleError = "RuleErrorPostAlreadyExists" RuleErrorSubmitPostInvalidCommentStakeID RuleError = "RuleErrorSubmitPostInvalidCommentStakeID" RuleErrorSubmitPostRequiresNonZeroInput RuleError = "RuleErrorSubmitPostRequiresNonZeroInput" RuleErrorSubmitPostInvalidPostHashToModify RuleError = "RuleErrorSubmitPostInvalidPostHashToModify" RuleErrorSubmitPostModifyingNonexistentPost RuleError = "RuleErrorSubmitPostModifyingNonexistentPost" RuleErrorSubmitPostPostModificationNotAuthorized RuleError = "RuleErrorSubmitPostPostModificationNotAuthorized" RuleErrorSubmitPostInvalidParentStakeIDLength RuleError = "RuleErrorSubmitPostInvalidParentStakeIDLength" RuleErrorSubmitPostParentNotFound RuleError = "RuleErrorSubmitPostParentNotFound" RuleErrorSubmitPostRecloutPostNotFound RuleError = "RuleErrorSubmitPostRecloutPostNotFound" RuleErrorSubmitPostRecloutOfReclout RuleError = "RuleErrorSubmitPostRecloutOfReclout" RuleErrorSubmitPostUpdateRecloutHash RuleError = "RuleErrorSubmitPostUpdateRecloutHash" RuleErrorSubmitPostUpdateIsQuotedReclout RuleError = "RuleErrorSubmitPostUpdateIsQuotedReclout" RuleErrorSubmitPostCannotUpdateNFT RuleError = "RuleErrorSubmitPostCannotUpdateNFT" RuleErrorInvalidStakeID RuleError = "RuleErrorInvalidStakeID" RuleErrorInvalidStakeIDSize RuleError = "RuleErrorInvalidStakeIDSize" RuleErrorStakingToNonexistentPost RuleError = "RuleErrorStakingToNonexistentPost" RuleErrorStakingToNonexistentProfile RuleError = "RuleErrorStakingToNonexistentProfile" RuleErrorNotImplemented RuleError = "RuleErrorNotImplemented" RuleErrorStakingZeroNanosNotAllowed RuleError = "RuleErrorStakingZeroNanosNotAllowed" RuleErrorAddStakeTxnMustHaveExactlyOneOutput RuleError = "RuleErrorAddStakeTxnMustHaveExactlyOneOutput" RuleErrorExistingStakeExceedsMaxAllowed RuleError = "RuleErrorExistingStakeExceedsMaxAllowed" RuleErrorAddStakeRequiresNonZeroInput RuleError = "RuleErrorAddStakeRequiresNonZeroInput" RuleErrorProfileForPostDoesNotExist RuleError = "RuleErrorProfileForPostDoesNotExist" // Global Params RuleErrorExchangeRateTooLow RuleError = "RuleErrorExchangeRateTooLow" RuleErrorExchangeRateTooHigh RuleError = "RuleErrorExchangeRateTooHigh" RuleErrorMinNetworkFeeTooLow RuleError = "RuleErrorMinNetworkFeeTooLow" RuleErrorMinNetworkFeeTooHigh RuleError = "RuleErrorMinNetworkFeeTooHigh" RuleErrorCreateProfileFeeTooLow RuleError = "RuleErrorCreateProfileFeeTooLow" RuleErrorCreateProfileTooHigh RuleError = "RuleErrorCreateProfileTooHigh" RuleErrorCreateNFTFeeTooLow RuleError = "RuleErrorCreateNFTFeeTooLow" RuleErrorCreateNFTFeeTooHigh RuleError = "RuleErrorCreateNFTFeeTooHigh" RuleErrorMaxCopiesPerNFTTooLow RuleError = "RuleErrorMaxCopiesPerNFTTooLow" RuleErrorMaxCopiesPerNFTTooHigh RuleError = "RuleErrorMaxCopiesPerNFTTooHigh" RuleErrorForbiddenPubKeyLength RuleError = "RuleErrorForbiddenPubKeyLength" RuleErrorUserNotAuthorizedToUpdateExchangeRate RuleError = "RuleErrorUserNotAuthorizedToUpdateExchangeRate" RuleErrorUserNotAuthorizedToUpdateGlobalParams RuleError = "RuleErrorUserNotAuthorizedToUpdateGlobalParams" RuleErrorUserOutputMustBeNonzero RuleError = "RuleErrorUserOutputMustBeNonzero" // BitClout Diamonds RuleErrorBasicTransferHasDiamondPostHashWithoutDiamondLevel RuleError = "RuleErrorBasicTransferHasDiamondPostHashWithoutDiamondLevel" RuleErrorBasicTransferHasInvalidDiamondLevel RuleError = "RuleErrorBasicTransferHasInvalidDiamondLevel" RuleErrorBasicTransferDiamondInvalidLengthForPostHashBytes RuleError = "RuleErrorBasicTransferInvalidLengthForPostHashBytes" RuleErrorBasicTransferDiamondPostEntryDoesNotExist RuleError = "RuleErrorBasicTransferDiamondPostEntryDoesNotExist" RuleErrorBasicTransferInsufficientCreatorCoinsForDiamondLevel RuleError = "RuleErrorBasicTransferInsufficientCreatorCoinsForDiamondLevel" RuleErrorBasicTransferDiamondCannotTransferToSelf RuleError = "RuleErrorBasicTransferDiamondCannotTransferToSelf" RuleErrorBasicTransferInsufficientBitCloutForDiamondLevel RuleError = "RuleErrorBasicTransferInsufficientBitCloutForDiamondLevel" RuleErrorCreatorCoinTransferRequiresNonZeroInput RuleError = "RuleErrorCreatorCoinTransferRequiresNonZeroInput" RuleErrorCreatorCoinTransferInvalidProfilePubKeySize RuleError = "RuleErrorCreatorCoinTransferInvalidProfilePubKeySize" RuleErrorCreatorCoinTransferInvalidReceiverPubKeySize RuleError = "RuleErrorCreatorCoinTransferInvalidReceiverPubKeySize" RuleErrorCreatorCoinTransferOnNonexistentProfile RuleError = "RuleErrorCreatorCoinTransferOnNonexistentProfile" RuleErrorCreatorCoinTransferBalanceEntryDoesNotExist RuleError = "RuleErrorCreatorCoinTransferBalanceEntryDoesNotExist" RuleErrorCreatorCoinTransferMustBeGreaterThanMinThreshold RuleError = "RuleErrorCreatorCoinTransferMustBeGreaterThanMinThreshold" RuleErrorCreatorCoinTransferInsufficientCoins RuleError = "RuleErrorCreatorCoinTransferInsufficientCoins" RuleErrorCreatorCoinTransferCannotTransferToSelf RuleError = "RuleErrorCreatorCoinTransferCannotTransferToSelf" RuleErrorCreatorCoinTransferHasDiamondPostHashWithoutDiamondLevel RuleError = "RuleErrorCreatorCoinTransferHasDiamondPostHashWithoutDiamondLevel" RuleErrorCreatorCoinTransferCantSendDiamondsForOtherProfiles RuleError = "RuleErrorCreatorCoinTransferCantSendDiamondsForOtherProfiles" RuleErrorCreatorCoinTransferCantDiamondYourself RuleError = "RuleErrorCreatorCoinTransferCantDiamondYourself" RuleErrorCreatorCoinTransferInvalidLengthForPostHashBytes RuleError = "RuleErrorCreatorCoinTransferInvalidLengthForPostHashBytes" RuleErrorCreatorCoinTransferInsufficientCreatorCoinsForDiamondLevel RuleError = "RuleErrorCreatorCoinTransferInsufficientCreatorCoinsForDiamondLevel" RuleErrorCreatorCoinTransferHasInvalidDiamondLevel RuleError = "RuleErrorCreatorCoinTransferHasInvalidDiamondLevel" RuleErrorCreatorCoinTransferHasDiamondsAfterBitCloutBlockHeight RuleError = "RuleErrorCreatorCoinTransferHasDiamondsAfterBitCloutBlockHeight" RuleErrorCreatorCoinTransferPostAlreadyHasSufficientDiamonds RuleError = "RuleErrorCreatorCoinTransferPostAlreadyHasSufficientDiamonds" RuleErrorCreatorCoinTransferDiamondsCantHaveNegativeNanos RuleError = "RuleErrorCreatorCoinTransferDiamondsCantHaveNegativeNanos" RuleErrorCreatorCoinTransferDiamondPostEntryDoesNotExist RuleError = "RuleErrorCreatorCoinTransferDiamondPostEntryDoesNotExist" RuleErrorCreatorCoinRequiresNonZeroInput RuleError = "RuleErrorCreatorCoinRequiresNonZeroInput" RuleErrorCreatorCoinInvalidPubKeySize RuleError = "RuleErrorCreatorCoinInvalidPubKeySize" RuleErrorCreatorCoinOperationOnNonexistentProfile RuleError = "RuleErrorCreatorCoinOperationOnNonexistentProfile" RuleErrorCreatorCoinBuyMustTradeNonZeroBitClout RuleError = "RuleErrorCreatorCoinBuyMustTradeNonZeroBitClout" RuleErrorCreatorCoinTxnOutputWithInvalidBuyAmount RuleError = "RuleErrorCreatorCoinTxnOutputWithInvalidBuyAmount" RuleErrorCreatorCoinTxnOutputExceedsInput RuleError = "RuleErrorCreatorCoinTxnOutputExceedsInput" RuleErrorCreatorCoinLessThanMinimumSetByUser RuleError = "RuleErrorCreatorCoinLessThanMinimumSetByUser" RuleErrorCreatorCoinBuyMustTradeNonZeroBitCloutAfterFees RuleError = "RuleErrorCreatorCoinBuyMustTradeNonZeroBitCloutAfterFees" RuleErrorCreatorCoinBuyMustTradeNonZeroBitCloutAfterFounderReward RuleError = "RuleErrorCreatorCoinBuyMustTradeNonZeroBitCloutAfterFounderReward" RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanos RuleError = "RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanos" RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanosForCreator RuleError = "RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanosForCreator" RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanosForBuyer RuleError = "RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanosForBuyer" RuleErrorCreatorCoinBuyZeroLockedNanosAndNonZeroHolders RuleError = "RuleErrorCreatorCoinBuyZeroLockedNanosAndNonZeroHolders" RuleErrorCreatorCoinSellMustHaveAtLeastOneInput RuleError = "RuleErrorCreatorCoinSellMustHaveAtLeastOneInput" RuleErrorCreatorCoinSellMustTradeNonZeroCreatorCoin RuleError = "RuleErrorCreatorCoinSellMustTradeNonZeroCreatorCoin" RuleErrorCreatorCoinSellerBalanceEntryDoesNotExist RuleError = "RuleErrorCreatorCoinSellerBalanceEntryDoesNotExist" RuleErrorCreatorCoinSellInsufficientCoins RuleError = "RuleErrorCreatorCoinSellInsufficientCoins" RuleErrorCreatorCoinSellNotAllowedWhenZeroBitCloutLocked RuleError = "RuleErrorCreatorCoinSellNotAllowedWhenZeroBitCloutLocked" RuleErrorBitCloutReceivedIsLessThanMinimumSetBySeller RuleError = "RuleErrorBitCloutReceivedIsLessThanMinimumSetBySeller" // NFTs RuleErrorTooManyNFTCopies RuleError = "RuleErrorTooManyNFTCopies" RuleErrorCreateNFTRequiresNonZeroInput RuleError = "RuleErrorCreateNFTRequiresNonZeroInput" RuleErrorUpdateNFTRequiresNonZeroInput RuleError = "RuleErrorUpdateNFTRequiresNonZeroInput" RuleErrorCreateNFTOnNonexistentPost RuleError = "RuleErrorCreateNFTOnNonexistentPost" RuleErrorCreateNFTOnVanillaReclout RuleError = "RuleErrorCreateNFTOnVanillaReclout" RuleErrorCreateNFTWithInsufficientFunds RuleError = "RuleErrorCreateNFTWithInsufficientFunds" RuleErrorCreateNFTOnPostThatAlreadyIsNFT RuleError = "RuleErrorCreateNFTOnPostThatAlreadyIsNFT" RuleErrorCreateNFTMustBeCalledByPoster RuleError = "RuleErrorCreateNFTMustBeCalledByPoster" RuleErrorNFTMustHaveNonZeroCopies RuleError = "RuleErrorNFTMustHaveNonZeroCopies" RuleErrorCannotUpdateNonExistentNFT RuleError = "RuleErrorCannotUpdateNonExistentNFT" RuleErrorUpdateNFTByNonOwner RuleError = "RuleErrorUpdateNFTByNonOwner" RuleErrorAcceptNFTBidByNonOwner RuleError = "RuleErrorAcceptNFTBidByNonOwner" RuleErrorCantCreateNFTWithoutProfileEntry RuleError = "RuleErrorCantCreateNFTWithoutProfileEntry" RuleErrorNFTRoyaltyHasTooManyBasisPoints RuleError = "RuleErrorNFTRoyaltyHasTooManyBasisPoints" RuleErrorNFTRoyaltyOverflow RuleError = "RuleErrorNFTRoyaltyOverflow" RuleErrorNFTUpdateMustUpdateIsForSaleStatus RuleError = "RuleErrorNFTUpdateMustUpdateIsForSaleStatus" // NFT Bids RuleErrorNFTBidRequiresNonZeroInput RuleError = "RuleErrorNFTBidRequiresNonZeroInput" RuleErrorAcceptNFTBidRequiresNonZeroInput RuleError = "RuleErrorAcceptNFTBidRequiresNonZeroInput" RuleErrorNFTBidOnNonExistentPost RuleError = "RuleErrorNFTBidOnNonExistentPost" RuleErrorNFTBidOnPostThatIsNotAnNFT RuleError = "RuleErrorNFTBidOnPostThatIsNotAnNFT" RuleErrorNFTBidOnInvalidSerialNumber RuleError = "RuleErrorNFTBidOnInvalidSerialNumber" RuleErrorNFTBidOnNonExistentNFTEntry RuleError = "RuleErrorNFTBidOnNonExistentNFTEntry" RuleErrorNFTBidOnNFTThatIsNotForSale RuleError = "RuleErrorNFTBidOnNFTThatIsNotForSale" RuleErrorNFTOwnerCannotBidOnOwnedNFT RuleError = "RuleErrorNFTOwnerCannotBidOnOwnedNFT" RuleErrorCantAcceptNonExistentBid RuleError = "RuleErrorCantAcceptNonExistentBid" RuleErrorAcceptedNFTBidAmountDoesNotMatch RuleError = "RuleErrorAcceptedNFTBidAmountDoesNotMatch" RuleErrorPostEntryNotFoundForAcceptedNFTBid RuleError = "RuleErrorPostEntryNotFoundForAcceptedNFTBid" RuleErrorUnlockableNFTMustProvideUnlockableText RuleError = "RuleErrorUnlockableNFTMustProvideUnlockableText" RuleErrorUnlockableTextLengthExceedsMax RuleError = "RuleErrorUnlockableTextLengthExceedsMax" RuleErrorAcceptedNFTBidMustSpecifyBidderInputs RuleError = "RuleErrorAcceptedNFTBidMustSpecifyBidderInputs" RuleErrorBidderInputForAcceptedNFTBidNoLongerExists RuleError = "RuleErrorBidderInputForAcceptedNFTBidNoLongerExists" RuleErrorAcceptNFTBidderInputsInsufficientForBidAmount RuleError = "RuleErrorAcceptNFTBidderInputsInsufficientForBidAmount" RuleErrorInsufficientFundsForNFTBid RuleError = "RuleErrorInsufficientFundsForNFTBid" RuleErrorNFTBidLessThanMinBidAmountNanos RuleError = "RuleErrorNFTBidLessThanMinBidAmountNanos" RuleErrorSwapIdentityIsParamUpdaterOnly RuleError = "RuleErrorSwapIdentityIsParamUpdaterOnly" RuleErrorFromPublicKeyIsRequired RuleError = "RuleErrorFromPublicKeyIsRequired" RuleErrorInvalidFromPublicKey RuleError = "RuleErrorInvalidFromPublicKey" RuleErrorToPublicKeyIsRequired RuleError = "RuleErrorToPublicKeyIsRequired" RuleErrorInvalidToPublicKey RuleError = "RuleErrorInvalidToPublicKey" RuleErrorOldFromPublicKeyHasDeletedPKID RuleError = "RuleErrorOldFromPublicKeyHasDeletedPKID" RuleErrorOldToPublicKeyHasDeletedPKID RuleError = "RuleErrorOldToPublicKeyHasDeletedPKID" HeaderErrorDuplicateHeader RuleError = "HeaderErrorDuplicateHeader" HeaderErrorNilPrevHash RuleError = "HeaderErrorNilPrevHash" HeaderErrorInvalidParent RuleError = "HeaderErrorInvalidParent" HeaderErrorBlockTooFarInTheFuture RuleError = "HeaderErrorBlockTooFarInTheFuture" HeaderErrorTimestampTooEarly RuleError = "HeaderErrorTimestampTooEarly" HeaderErrorBlockDifficultyAboveTarget RuleError = "HeaderErrorBlockDifficultyAboveTarget" HeaderErrorHeightInvalid RuleError = "HeaderErrorHeightInvalid" HeaderErrorDifficultyBitsNotConsistentWithTargetDifficultyComputedFromParent RuleError = "HeaderErrorDifficultyBitsNotConsistentWithTargetDifficultyComputedFromParent" TxErrorTooLarge RuleError = "TxErrorTooLarge" TxErrorDuplicate RuleError = "TxErrorDuplicate" TxErrorDuplicateBitcoinExchangeTxn RuleError = "TxErrorDuplicateBitcoinExchangeTxn" TxErrorDoubleSpend RuleError = "TxErrorDoubleSpend" TxErrorIndividualBlockReward RuleError = "TxErrorIndividualBlockReward" TxErrorInsufficientFeeMinFee RuleError = "TxErrorInsufficientFeeMinFee" TxErrorInsufficientFeeRateLimit RuleError = "TxErrorInsufficientFeeRateLimit" TxErrorInsufficientFeePriorityQueue RuleError = "TxErrorInsufficientFeePriorityQueue" TxErrorUnconnectedTxnNotAllowed RuleError = "TxErrorUnconnectedTxnNotAllowed" TxErrorCannotProcessBitcoinExchangeUntilBitcoinManagerIsCurrent RuleError = "TxErrorCannotProcessBitcoinExchangeUntilBitcoinManagerIsCurrent" )
type Server ¶
type Server struct { // During initial block download, we request headers and blocks from a single // peer. Note: These fields should only be accessed from the messageHandler thread. // // TODO: This could be much faster if we were to download blocks in parallel // rather than from a single peer but it won't be a problem until later, at which // point we can make the optimization. SyncPeer *Peer // contains filtered or unexported fields }
Server is the core of the BitClout node. It effectively runs a single-threaded main loop that processes transactions from other peers and responds to them accordingly. Probably the best place to start looking is the messageHandler function.
func NewServer ¶
func NewServer( _params *BitCloutParams, _listeners []net.Listener, _bitcloutAddrMgr *addrmgr.AddrManager, _connectIps []string, _db *badger.DB, _targetOutboundPeers uint32, _maxInboundPeers uint32, _minerPublicKeys []string, _numMiningThreads uint64, _limitOneInboundConnectionPerIP bool, _rateLimitFeerateNanosPerKB uint64, _minFeeRateNanosPerKB uint64, _stallTimeoutSeconds uint64, _bitcoinDataDir string, _maxBlockTemplatesToCache uint64, _minBlockUpdateIntervalSeconds uint64, _blockCypherAPIKey string, _runReadOnlyUtxoViewUpdater bool, _dataDir string, _mempoolDumpDir string, _disableNetworking bool, _readOnlyMode bool, _ignoreInboundPeerInvMessages bool, _bitcoinConnectPeer string, _ignoreUnminedBitcoinTxnsFromPeers bool, statsd *statsd.Client, _blockProducerSeed string, _trustedBlockProducerPublicKeys []string, _trustedBlockProducerStartHeight uint64, ) (*Server, error)
NewServer initializes all of the internal data structures. Right now this basically looks as follows:
- ConnectionManager starts and keeps track of peers.
- When messages are received from peers, they get forwarded on a channel to the Server to handle them. In that sense the ConnectionManager is basically just acting as a router.
- When the Server receives a message from a peer, it can do any of the following:
- Take no action.
- Use the Blockchain data structure to validate the transaction or update the. Blockchain data structure.
- Send a new message. This can be a message directed back to that actually sent this message or it can be a message to another peer for whatever reason. When a message is sent in this way it can also have a deadline on it that the peer needs to respond by or else it will be disconnected.
- Disconnect the peer. In this case the ConnectionManager gets notified about the disconnection and may opt to replace the now-disconnected peer with a new peer. This happens for example when an outbound peer is disconnected in order to maintain TargetOutboundPeers.
- The server could also receive a control message that a peer has been disconnected. This can be useful to the server if, for example, it was expecting a response from a particular peer, which could be the case in initial block download where a single sync peer is used.
TODO: Refactor all these arguments into a config object or something.
func (*Server) BroadcastTransaction ¶
func (srv *Server) BroadcastTransaction(txn *MsgBitCloutTxn) ([]*MempoolTx, error)
func (*Server) ExpireRequests ¶
func (srv *Server) ExpireRequests()
ExpireRequests checks to see if any requests have expired and removes them if so.
func (*Server) GetBitcoinManager ¶
func (srv *Server) GetBitcoinManager() *BitcoinManager
TODO: The hallmark of a messy non-law-of-demeter-following interface...
func (*Server) GetBlockProducer ¶
func (srv *Server) GetBlockProducer() *BitCloutBlockProducer
TODO: The hallmark of a messy non-law-of-demeter-following interface...
func (*Server) GetBlockchain ¶
func (srv *Server) GetBlockchain() *Blockchain
TODO: The hallmark of a messy non-law-of-demeter-following interface...
func (*Server) GetBlocks ¶
GetBlocks computes what blocks we need to fetch and asks for them from the corresponding peer. It is typically called after we have exited SyncStateSyncingHeaders.
func (*Server) GetConnectionManager ¶
func (srv *Server) GetConnectionManager() *ConnectionManager
TODO: The hallmark of a messy non-law-of-demeter-following interface...
func (*Server) GetMempool ¶
func (srv *Server) GetMempool() *BitCloutMempool
TODO: The hallmark of a messy non-law-of-demeter-following interface...
func (*Server) GetMiner ¶
func (srv *Server) GetMiner() *BitCloutMiner
TODO: The hallmark of a messy non-law-of-demeter-following interface...
func (*Server) GetStatsdClient ¶
func (*Server) HasProcessedFirstTransactionBundle ¶
func (*Server) ProcessSingleTxnWithChainLock ¶
func (srv *Server) ProcessSingleTxnWithChainLock( pp *Peer, txn *MsgBitCloutTxn) ([]*MempoolTx, error)
func (*Server) ResetRequestQueues ¶
func (srv *Server) ResetRequestQueues()
ResetRequestQueues resets all the request queues.
func (*Server) Start ¶
func (srv *Server) Start()
Start actually kicks off all of the management processes. Among other things, it causes the ConnectionManager to actually start connecting to peers and receiving messages. If requested, it also starts the miner.
func (*Server) StartStatsdReporter ¶
func (srv *Server) StartStatsdReporter()
func (*Server) VerifyAndBroadcastTransaction ¶
func (srv *Server) VerifyAndBroadcastTransaction(txn *MsgBitCloutTxn) error
type ServerMessage ¶
type ServerMessage struct { Peer *Peer Msg BitCloutMessage ReplyChan chan *ServerReply }
ServerMessage is the core data structure processed by the Server in its main loop.
type ServerReply ¶
type ServerReply struct { }
ServerReply is used to signal to outside programs that a particuler ServerMessage they may have been waiting on has been processed.
type ServiceFlag ¶
type ServiceFlag uint64
const ( // SFFullNode is a flag used to indicate a peer is a full node. SFFullNode ServiceFlag = 1 << iota )
type SingleAddr ¶
type SingleAddr struct { // Last time the address was seen. Encoded as number UNIX seconds on the wire. Timestamp time.Time // Bitfield which identifies the services supported by the address. Services ServiceFlag // IP address of the peer. Must be 4 or 16 bytes for IPV4 or IPV6 respectively. IP net.IP // Port the peer is using. Port uint16 }
SingleAddr is similar to the wire.NetAddress definition from the btcd guys.
func (*SingleAddr) String ¶
func (addr *SingleAddr) String() string
func (*SingleAddr) StringWithPort ¶
func (addr *SingleAddr) StringWithPort(includePort bool) string
type SingleStake ¶
type SingleStake struct { // Just save the data from the initial stake for posterity. InitialStakeNanos uint64 BlockHeight uint64 InitialStakeMultipleBasisPoints uint64 // The amount distributed to previous users can be computed by // adding the creator percentage and the burn fee and then // subtracting that total percentage off of the InitialStakeNanos. // Example: // - InitialStakeNanos = 100 // - CreatorPercentage = 15% // - BurnFeePercentage = 10% // - Amount to pay to previous users = 100 - 15 - 10 = 75 InitialCreatorPercentageBasisPoints uint64 // These fields are what we actually use to pay out the user who staked. // // The initial RemainingAmountOwedNanos is computed by simply multiplying // the InitialStakeNanos by the InitialStakeMultipleBasisPoints. RemainingStakeOwedNanos uint64 PublicKey []byte }
type StakeEntry ¶
type StakeEntry struct { StakeList []*SingleStake // Computed for profiles to cache how much has been staked to // their posts in total. When a post is staked to, this value // gets incremented on the profile. It gets reverted on the // profile when the post stake is reverted. TotalPostStake uint64 }
func NewStakeEntry ¶
func NewStakeEntry() *StakeEntry
func StakeEntryCopy ¶
func StakeEntryCopy(stakeEntry *StakeEntry) *StakeEntry
type StakeEntryStats ¶
type StakeEntryStats struct { TotalStakeNanos uint64 TotalStakeOwedNanos uint64 TotalCreatorEarningsNanos uint64 TotalFeesBurnedNanos uint64 TotalPostStakeNanos uint64 }
func GetStakeEntryStats ¶
func GetStakeEntryStats(stakeEntry *StakeEntry, params *BitCloutParams) *StakeEntryStats
type StakeIDType ¶
type StakeIDType uint8
const ( StakeIDTypePost StakeIDType = 0 StakeIDTypeProfile StakeIDType = 1 )
func (StakeIDType) String ¶
func (ss StakeIDType) String() string
type SubmitPostMetadata ¶
type SubmitPostMetadata struct { // When set, this transaction is treated as modifying an existing // post rather than creating a new post. PostHashToModify []byte // When a ParentStakeID is set, the post is actually a comment on // another entity (either a post or a profile depending on the // type of StakeID provided). ParentStakeID []byte Body []byte // The amount the creator of the post gets when someone stakes // to the post. CreatorBasisPoints uint64 // The multiple of the payout when a user stakes to a post. // 2x multiple = 200% = 20,000bps StakeMultipleBasisPoints uint64 // A timestamp used for ordering messages when displaying them to // users. The timestamp must be unique. Note that we use a nanosecond // timestamp because it makes it easier to deal with the uniqueness // constraint technically (e.g. If one second spacing is required // as would be the case with a standard Unix timestamp then any code // that generates these transactions will need to potentially wait // or else risk a timestamp collision. This complexity is avoided // by just using a nanosecond timestamp). Note that the timestamp is // an unsigned int as opposed to a signed int, which means times // before the zero time are not represented which doesn't matter // for our purposes. Restricting the timestamp in this way makes // lexicographic sorting based on bytes easier in our database which // is one of the reasons we do it. TimestampNanos uint64 // When set to true, indicates that the post should be deleted. This // value is only considered when PostHashToModify is set to a valid // pre-existing post. IsHidden bool }
func (*SubmitPostMetadata) FromBytes ¶
func (txnData *SubmitPostMetadata) FromBytes(data []byte) error
func (*SubmitPostMetadata) GetTxnType ¶
func (txnData *SubmitPostMetadata) GetTxnType() TxnType
func (*SubmitPostMetadata) New ¶
func (txnData *SubmitPostMetadata) New() BitCloutTxnMetadata
type SummaryStats ¶
type SummaryStats struct { // Number of transactions of this type in the mempool. Count uint32 // Number of bytes for transactions of this type in the mempool. TotalBytes uint64 }
Summary stats for a set of transactions of a specific type in the mempool.
type SwapIdentityMetadataa ¶
type SwapIdentityMetadataa struct { // The public key that we are swapping *from*. Doesn't matter which public // key is *from* and which public key is *to* because it's just a swap. FromPublicKey []byte // The public key that we are swapping *to*. Doesn't matter which public // key is *from* and which public key is *to* because it's just a swap. ToPublicKey []byte }
func (*SwapIdentityMetadataa) FromBytes ¶
func (txnData *SwapIdentityMetadataa) FromBytes(dataa []byte) error
func (*SwapIdentityMetadataa) GetTxnType ¶
func (txnData *SwapIdentityMetadataa) GetTxnType() TxnType
func (*SwapIdentityMetadataa) New ¶
func (txnData *SwapIdentityMetadataa) New() BitCloutTxnMetadata
type SwapIdentityOperationType ¶
type SwapIdentityOperationType uint8
type SwitchPeerMsg ¶
type SyncState ¶
type SyncState uint8
const ( // SyncStateSyncingHeaders indicates that our header chain is not current. // This is the state a node will start in when it hasn't downloaded // anything from its peers. Because we always download headers and // validate them before we download blocks, SyncingHeaders implies that // the block tip is also not current yet. SyncStateSyncingHeaders SyncState = iota // SyncStateSyncingBlocks indicates that our header chain is current but // that the block chain we have is not current yet. In particular, it // means, among other things, that the tip of the block chain is still // older than max tip age. SyncStateSyncingBlocks // SyncStateNeedBlocksss indicates that our header chain is current and our // block chain is current but that there are headers in our main chain for // which we have not yet processed blocks. SyncStateNeedBlocksss // SyncStateFullyCurrent indicates that our header chain is current and that // we've fetched all the blocks corresponding to this chain. SyncStateFullyCurrent )
type TXIndex ¶
type TXIndex struct { // TXIndexLock protects the transaction index. TXIndexLock deadlock.RWMutex // The txindex has it s own separate Blockchain object. This allows us to // capture more metadata when collecting transactions without interfering // with the goings-on of the main chain. TXIndexChain *Blockchain // Core objects from Server CoreChain *Blockchain BitcoinManager *BitcoinManager // Core params object Params *BitCloutParams // contains filtered or unexported fields }
func NewTXIndex ¶
func NewTXIndex(coreChain *Blockchain, bitcoinManager *BitcoinManager, params *BitCloutParams, dataDirectory string) (*TXIndex, error)
func (*TXIndex) GetTxindexUpdateBlockNodes ¶
func (txi *TXIndex) GetTxindexUpdateBlockNodes() ( _txindexTipNode *BlockNode, _blockTipNode *BlockNode, _commonAncestor *BlockNode, _detachBlocks []*BlockNode, _attachBlocks []*BlockNode)
GetTxindexUpdateBlockNodes ...
func (*TXIndex) Update ¶
Update syncs the transaction index with the blockchain. Specifically, it reads in all the blocks that have come in since the last time this function was called and adds the new transactions to the txindex. It also handles reorgs properly.
TODO(DELETEME, cleanup): This code is error-prone. Moving the transaction indexing code to block_view.go may be a clean way to refactor this.
type TransactionMetadata ¶
type TransactionMetadata struct { BlockHashHex string TxnIndexInBlock uint64 TxnType string // All transactions have a public key who executed the transaction and some // public keys that are affected by the transaction. Notifications are created // for the affected public keys. _getPublicKeysForTxn uses this to set entries in the // database. TransactorPublicKeyBase58Check string AffectedPublicKeys []*AffectedPublicKey // We store these outputs so we don't have to load the full transaction from disk // when looking up output amounts TxnOutputs []*BitCloutOutput BasicTransferTxindexMetadata *BasicTransferTxindexMetadata `json:",omitempty"` BitcoinExchangeTxindexMetadata *BitcoinExchangeTxindexMetadata `json:",omitempty"` CreatorCoinTxindexMetadata *CreatorCoinTxindexMetadata `json:",omitempty"` CreatorCoinTransferTxindexMetadata *CreatorCoinTransferTxindexMetadata `json:",omitempty"` UpdateProfileTxindexMetadata *UpdateProfileTxindexMetadata `json:",omitempty"` SubmitPostTxindexMetadata *SubmitPostTxindexMetadata `json:",omitempty"` LikeTxindexMetadata *LikeTxindexMetadata `json:",omitempty"` FollowTxindexMetadata *FollowTxindexMetadata `json:",omitempty"` PrivateMessageTxindexMetadata *PrivateMessageTxindexMetadata `json:",omitempty"` SwapIdentityTxindexMetadata *SwapIdentityTxindexMetadata `json:",omitempty"` NFTBidTxindexMetadata *NFTBidTxindexMetadata `json:",omitempty"` AcceptNFTBidTxindexMetadata *AcceptNFTBidTxindexMetadata `json:",omitempty"` }
func ComputeTransactionMetadata ¶
func ComputeTransactionMetadata(txn *MsgBitCloutTxn, utxoView *UtxoView, blockHash *BlockHash, totalNanosPurchasedBefore uint64, usdCentsPerBitcoinBefore uint64, totalInput uint64, totalOutput uint64, fees uint64, txnIndexInBlock uint64, utxoOps []*UtxoOperation) (*TransactionMetadata, error)
func ConnectTxnAndComputeTransactionMetadata ¶
func ConnectTxnAndComputeTransactionMetadata( txn *MsgBitCloutTxn, utxoView *UtxoView, blockHash *BlockHash, blockHeight uint32, txnIndexInBlock uint64) (*TransactionMetadata, error)
func DbGetTxindexTransactionRefByTxID ¶
func DbGetTxindexTransactionRefByTxID(handle *badger.DB, txID *BlockHash) *TransactionMetadata
func DbGetTxindexTransactionRefByTxIDWithTxn ¶
func DbGetTxindexTransactionRefByTxIDWithTxn(txn *badger.Txn, txID *BlockHash) *TransactionMetadata
type TxnType ¶
type TxnType uint64
TxnType specifies the type for a transaction message.
const ( TxnTypeUnset TxnType = 0 TxnTypeBlockReward TxnType = 1 TxnTypeBasicTransfer TxnType = 2 TxnTypeBitcoinExchange TxnType = 3 TxnTypePrivateMessage TxnType = 4 TxnTypeSubmitPost TxnType = 5 TxnTypeUpdateProfile TxnType = 6 TxnTypeUpdateBitcoinUSDExchangeRate TxnType = 8 TxnTypeFollow TxnType = 9 TxnTypeLike TxnType = 10 TxnTypeCreatorCoin TxnType = 11 TxnTypeSwapIdentity TxnType = 12 TxnTypeUpdateGlobalParams TxnType = 13 TxnTypeCreatorCoinTransfer TxnType = 14 TxnTypeCreateNFT TxnType = 15 TxnTypeUpdateNFT TxnType = 16 TxnTypeAcceptNFTBid TxnType = 17 TxnTypeNFTBid TxnType = 18 )
type UnconnectedTx ¶
type UnconnectedTx struct {
// contains filtered or unexported fields
}
UnconnectedTx is a transaction that has dependencies that we haven't added yet.
type UpdateBitcoinUSDExchangeRateMetadataa ¶
type UpdateBitcoinUSDExchangeRateMetadataa struct { // The new exchange rate to set. USDCentsPerBitcoin uint64 }
func (*UpdateBitcoinUSDExchangeRateMetadataa) FromBytes ¶
func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) FromBytes(dataa []byte) error
func (*UpdateBitcoinUSDExchangeRateMetadataa) GetTxnType ¶
func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) GetTxnType() TxnType
func (*UpdateBitcoinUSDExchangeRateMetadataa) New ¶
func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) New() BitCloutTxnMetadata
type UpdateGlobalParamsMetadata ¶
type UpdateGlobalParamsMetadata struct { }
================================================================== UpdateGlobalParamsMetadata ==================================================================
func (*UpdateGlobalParamsMetadata) FromBytes ¶
func (txnData *UpdateGlobalParamsMetadata) FromBytes(data []byte) error
func (*UpdateGlobalParamsMetadata) GetTxnType ¶
func (txnData *UpdateGlobalParamsMetadata) GetTxnType() TxnType
func (*UpdateGlobalParamsMetadata) New ¶
func (txnData *UpdateGlobalParamsMetadata) New() BitCloutTxnMetadata
type UpdateNFTMetadata ¶
type UpdateNFTMetadata struct { NFTPostHash *BlockHash SerialNumber uint64 IsForSale bool MinBidAmountNanos uint64 }
func (*UpdateNFTMetadata) FromBytes ¶
func (txnData *UpdateNFTMetadata) FromBytes(dataa []byte) error
func (*UpdateNFTMetadata) GetTxnType ¶
func (txnData *UpdateNFTMetadata) GetTxnType() TxnType
func (*UpdateNFTMetadata) New ¶
func (txnData *UpdateNFTMetadata) New() BitCloutTxnMetadata
type UpdateProfileMetadata ¶
type UpdateProfileMetadata struct { // The public key of the profile to update. When left unset, the public // key in the transaction is used. ProfilePublicKey []byte NewUsername []byte NewDescription []byte NewProfilePic []byte // This is the percentage of each "net buy" that a creator earns when // someone purchases her coin. For example, if this were set to 25%, // then every time their coin reaches a new high, they would get 25% // of the coins as they're being minted. More concretely, if someone // put in enough BitClout to buy 10 coins, the creator would get 2.5 // and this person would get 7.5. However, if they sold 5 coins and // someone subsequently bought those same coins, the creator wouldn't // get any coins because no "net new" coins have been created. NewCreatorBasisPoints uint64 // The multiple of the payout when a user stakes to this profile. If // unset, a sane default is set when the first person stakes to this // profile. // 2x multiple = 200% = 20,000bps // // TODO: This field is deprecated; delete it. NewStakeMultipleBasisPoints uint64 // Profile is hidden from the UI when this field is true. IsHidden bool }
func (*UpdateProfileMetadata) FromBytes ¶
func (txnData *UpdateProfileMetadata) FromBytes(data []byte) error
func (*UpdateProfileMetadata) GetTxnType ¶
func (txnData *UpdateProfileMetadata) GetTxnType() TxnType
func (*UpdateProfileMetadata) New ¶
func (txnData *UpdateProfileMetadata) New() BitCloutTxnMetadata
type UsernameMapKey ¶
type UsernameMapKey [MaxUsernameLengthBytes]byte
Have to define these because Go doesn't let you use raw byte slices as map keys. This needs to be in-sync with BitCloutMainnetParams.MaxUsernameLengthBytes
func MakeUsernameMapKey ¶
func MakeUsernameMapKey(nonLowercaseUsername []byte) UsernameMapKey
type UtxoEntry ¶
type UtxoEntry struct { AmountNanos uint64 PublicKey []byte BlockHeight uint32 UtxoType UtxoType // A back-reference to the utxo key associated with this entry. UtxoKey *UtxoKey // contains filtered or unexported fields }
UtxoEntry identifies the data associated with a UTXO.
func DbGetUtxosForPubKey ¶
DbGetUtxosForPubKey finds the UtxoEntry's corresponding to the public key passed in. It also attaches the UtxoKeys to the UtxoEntry's it returns for easy access.
type UtxoKey ¶
type UtxoKey struct { // The 32-byte transaction id where the unspent output occurs. TxID BlockHash // The index within the txn where the unspent output occurs. Index uint32 }
UtxoKey is a 32-byte txid with a 4-byte uint32 index identifying the particular output in the transaction where this utxo occurs. When fetching from the db the txid and index are concatenated to form the key, with the index serialized as big-endian.
type UtxoOperation ¶
type UtxoOperation struct { Type OperationType // Only set for OperationTypeSpendUtxo // // When we SPEND a UTXO entry we delete it from the utxo set but we still // store its info in case we want to reverse // it in the future. This information is not needed for ADD since // reversing an ADD just means deleting an entry from the end of our list. // // SPEND works by swapping the UTXO we want to spend with the UTXO at // the end of the list and then deleting from the end of the list. Obviously // this is more efficient than deleting the element in-place and then shifting // over everything after it. In order to be able to undo this operation, // however, we need to store the original index of the item we are // spending/deleting. Reversing the operation then amounts to adding a utxo entry // at the end of the list and swapping with this index. Given this, the entry // we store here has its position set to the position it was at right before the // SPEND operation was performed. Entry *UtxoEntry // Only set for OperationTypeSpendUtxo // // Store the UtxoKey as well. This isn't necessary but it helps // with error-checking during a roll-back so we just keep it. // // TODO: We can probably delete this at some point and save some space. UTXOs // are probably our biggest disk hog so getting rid of this should materially // improve disk usage. Key *UtxoKey // Used to revert BitcoinExchange transaction. PrevNanosPurchased uint64 // Used to revert UpdateBitcoinUSDExchangeRate transaction. PrevUSDCentsPerBitcoin uint64 // Save the previous post entry when making an update to a post. PrevPostEntry *PostEntry PrevParentPostEntry *PostEntry PrevGrandparentPostEntry *PostEntry PrevRecloutedPostEntry *PostEntry // Save the previous profile entry when making an update. PrevProfileEntry *ProfileEntry // Save the previous like entry and like count when making an update. PrevLikeEntry *LikeEntry PrevLikeCount uint64 // For disconnecting diamonds. PrevDiamondEntry *DiamondEntry // For disconnecting NFTs. PrevNFTEntry *NFTEntry PrevNFTBidEntry *NFTBidEntry DeletedNFTBidEntries []*NFTBidEntry NFTPaymentUtxoKeys []*UtxoKey NFTSpentUtxoEntries []*UtxoEntry PrevAcceptedNFTBidEntries *[]*NFTBidEntry // Save the previous reclout entry and reclout count when making an update. PrevRecloutEntry *RecloutEntry PrevRecloutCount uint64 // Save the state of a creator coin prior to updating it due to a // buy/sell/add transaction. PrevCoinEntry *CoinEntry // Save the creator coin balance of both the transactor and the creator. // We modify the transactor's balances when they buys/sell a creator coin // and we modify the creator's balance when we pay them a founder reward. PrevTransactorBalanceEntry *BalanceEntry PrevCreatorBalanceEntry *BalanceEntry // We use this to revert founder's reward UTXOs created by creator coin buys. FounderRewardUtxoKey *UtxoKey // Save balance entries for the sender and receiver when creator coins are transferred. PrevSenderBalanceEntry *BalanceEntry PrevReceiverBalanceEntry *BalanceEntry // Save the global params when making an update. PrevGlobalParamsEntry *GlobalParamsEntry PrevForbiddenPubKeyEntry *ForbiddenPubKeyEntry }
type UtxoType ¶
type UtxoType uint8
const ( // UTXOs can come from different sources. We document all of those sources // in the UTXOEntry using these types. UtxoTypeOutput UtxoType = 0 UtxoTypeBlockReward UtxoType = 1 UtxoTypeBitcoinBurn UtxoType = 2 // TODO(DELETEME): Remove the StakeReward txn type UtxoTypeStakeReward UtxoType = 3 UtxoTypeCreatorCoinSale UtxoType = 4 UtxoTypeCreatorCoinFounderReward UtxoType = 5 UtxoTypeNFTSeller UtxoType = 6 UtxoTypeNFTBidderChange UtxoType = 7 UtxoTypeNFTCreatorRoyalty UtxoType = 8 )
type UtxoView ¶
type UtxoView struct { // Utxo data NumUtxoEntries uint64 UtxoKeyToUtxoEntry map[UtxoKey]*UtxoEntry PublicKeyToBitcloutBalanceNanos map[PkMapKey]uint64 // BitcoinExchange data NanosPurchased uint64 USDCentsPerBitcoin uint64 GlobalParamsEntry *GlobalParamsEntry BitcoinBurnTxIDs map[BlockHash]bool // Forbidden block signature pubkeys ForbiddenPubKeyToForbiddenPubKeyEntry map[PkMapKey]*ForbiddenPubKeyEntry // Messages data MessageKeyToMessageEntry map[MessageKey]*MessageEntry // Follow data FollowKeyToFollowEntry map[FollowKey]*FollowEntry // NFT data NFTKeyToNFTEntry map[NFTKey]*NFTEntry NFTBidKeyToNFTBidEntry map[NFTBidKey]*NFTBidEntry NFTKeyToAcceptedNFTBidHistory map[NFTKey]*[]*NFTBidEntry // Diamond data DiamondKeyToDiamondEntry map[DiamondKey]*DiamondEntry // Like data LikeKeyToLikeEntry map[LikeKey]*LikeEntry // Reclout data RecloutKeyToRecloutEntry map[RecloutKey]*RecloutEntry // Post data PostHashToPostEntry map[BlockHash]*PostEntry // Profile data PublicKeyToPKIDEntry map[PkMapKey]*PKIDEntry // The PKIDEntry is only used here to store the public key. PKIDToPublicKey map[PKID]*PKIDEntry ProfilePKIDToProfileEntry map[PKID]*ProfileEntry ProfileUsernameToProfileEntry map[UsernameMapKey]*ProfileEntry // Coin balance entries HODLerPKIDCreatorPKIDToBalanceEntry map[BalanceEntryMapKey]*BalanceEntry // The hash of the tip the view is currently referencing. Mainly used // for error-checking when doing a bulk operation on the view. TipHash *BlockHash BitcoinManager *BitcoinManager Handle *badger.DB Params *BitCloutParams }
func NewUtxoView ¶
func NewUtxoView( _handle *badger.DB, _params *BitCloutParams, _bitcoinManager *BitcoinManager) (*UtxoView, error)
func (*UtxoView) ConnectBlock ¶
func (bav *UtxoView) ConnectBlock( bitcloutBlock *MsgBitCloutBlock, txHashes []*BlockHash, verifySignatures bool) ( [][]*UtxoOperation, error)
func (*UtxoView) ConnectTransaction ¶
func (*UtxoView) CopyUtxoView ¶
func (*UtxoView) DisconnectBlock ¶
func (bav *UtxoView) DisconnectBlock( bitcloutBlock *MsgBitCloutBlock, txHashes []*BlockHash, utxoOps [][]*UtxoOperation) error
func (*UtxoView) DisconnectTransaction ¶
func (bav *UtxoView) DisconnectTransaction(currentTxn *MsgBitCloutTxn, txnHash *BlockHash, utxoOpsForTxn []*UtxoOperation, blockHeight uint32) error
func (*UtxoView) FlushToDbWithTxn ¶
func (*UtxoView) GetAcceptNFTBidHistoryForNFTKey ¶
func (bav *UtxoView) GetAcceptNFTBidHistoryForNFTKey(nftKey *NFTKey) *[]*NFTBidEntry
func (*UtxoView) GetAllNFTBidEntries ¶
func (bav *UtxoView) GetAllNFTBidEntries(nftPostHash *BlockHash, serialNumber uint64) []*NFTBidEntry
func (*UtxoView) GetAllPosts ¶
func (bav *UtxoView) GetAllPosts() (_corePosts []*PostEntry, _commentsByPostHash map[BlockHash][]*PostEntry, _err error)
Just fetch all the posts from the db and join them with all the posts in the mempool. Then sort them by their timestamp. This can be called on an empty view or a view that already has a lot of transactions applied to it.
func (*UtxoView) GetAllProfiles ¶
func (bav *UtxoView) GetAllProfiles(readerPK []byte) ( _profiles map[PkMapKey]*ProfileEntry, _corePostsByProfilePublicKey map[PkMapKey][]*PostEntry, _commentsByProfilePublicKey map[PkMapKey][]*PostEntry, _postEntryReaderStates map[BlockHash]*PostEntryReaderState, _err error)
Just fetch all the profiles from the db and join them with all the profiles in the mempool. Then sort them by their BitClout. This can be called on an empty view or a view that already has a lot of transactions applied to it.
func (*UtxoView) GetBalanceEntryForHODLerPubKeyAndCreatorPubKey ¶
func (*UtxoView) GetBitcloutBalanceNanosForPublicKey ¶
func (*UtxoView) GetCommentEntriesForParentStakeID ¶
func (*UtxoView) GetCurrentUSDCentsPerBitcoin ¶
The blockchain used to store the USD to BTC exchange rate in bav.USDCentsPerBitcoin, which was set by a UPDATE_BITCOIN_USD_EXCHANGE_RATE txn, but has since moved to the GlobalParamsEntry, which is set by a UPDATE_GLOBAL_PARAMS txn.
func (*UtxoView) GetDBHighAndLowBidEntriesForNFT ¶
func (bav *UtxoView) GetDBHighAndLowBidEntriesForNFT( nftHash *BlockHash, serialNumber uint64, ) (_highBidEntry *NFTBidEntry, _lowBidEntry *NFTBidEntry)
This function gets the highest and lowest bids for a specific NFT that have not been deleted in the view.
func (*UtxoView) GetDBHighAndLowBidsForNFT ¶
func (*UtxoView) GetDiamondEntriesForSenderToReceiver ¶
func (bav *UtxoView) GetDiamondEntriesForSenderToReceiver(receiverPublicKey []byte, senderPublicKey []byte, ) (_diamondEntries []*DiamondEntry, _err error)
func (*UtxoView) GetDiamondEntryForDiamondKey ¶
func (bav *UtxoView) GetDiamondEntryForDiamondKey(diamondKey *DiamondKey) *DiamondEntry
func (*UtxoView) GetDiamondEntryMapForPublicKey ¶
func (*UtxoView) GetDiamondSendersForPostHash ¶
func (*UtxoView) GetFollowEntriesForPublicKey ¶
func (bav *UtxoView) GetFollowEntriesForPublicKey(publicKey []byte, getEntriesFollowingPublicKey bool) ( _followEntries []*FollowEntry, _err error)
getEntriesFollowingPublicKey == true => Returns FollowEntries for people that follow publicKey getEntriesFollowingPublicKey == false => Returns FollowEntries for people that publicKey follows
func (*UtxoView) GetFollowEntryForFollowerPublicKeyCreatorPublicKey ¶
func (bav *UtxoView) GetFollowEntryForFollowerPublicKeyCreatorPublicKey(followerPublicKey []byte, creatorPublicKey []byte) *FollowEntry
func (*UtxoView) GetHighAndLowBidsForNFTCollection ¶
func (*UtxoView) GetHighAndLowBidsForNFTSerialNumber ¶
func (*UtxoView) GetLikedByReader ¶
func (*UtxoView) GetLikesForPostHash ¶
func (*UtxoView) GetLimitedMessagesForUser ¶
func (bav *UtxoView) GetLimitedMessagesForUser(publicKey []byte) ( _messageEntries []*MessageEntry, _err error)
func (*UtxoView) GetMessagesForUser ¶
func (bav *UtxoView) GetMessagesForUser(publicKey []byte) ( _messageEntries []*MessageEntry, _err error)
func (*UtxoView) GetNFTBidEntriesForPKID ¶
func (bav *UtxoView) GetNFTBidEntriesForPKID(bidderPKID *PKID) (_nftBidEntries []*NFTBidEntry)
func (*UtxoView) GetNFTBidEntryForNFTBidKey ¶
func (bav *UtxoView) GetNFTBidEntryForNFTBidKey(nftBidKey *NFTBidKey) *NFTBidEntry
func (*UtxoView) GetNFTEntriesForPKID ¶
func (*UtxoView) GetNFTEntriesForPostHash ¶
func (*UtxoView) GetNFTEntryForNFTKey ¶
func (*UtxoView) GetPKIDForPublicKey ¶
func (*UtxoView) GetParentPostEntriesForPostEntry ¶
func (bav *UtxoView) GetParentPostEntriesForPostEntry(postEntry *PostEntry, maxDepth uint32, rootFirst bool, ) (_parentPostEntries []*PostEntry, _truncatedTree bool)
Accepts a postEntry and returns as many parent posts as it can find up to maxDepth. This function never returns an error, only an empty list if it hits a non-post parentStakeID. If "rootFirst" is passed, the root of the tree will be returned first, not the 1st parent. _truncatedTree is a flag that is true when the root post was not reached before the maxDepth was hit.
func (*UtxoView) GetPostEntryForPostHash ¶
func (*UtxoView) GetPostEntryReaderState ¶
func (bav *UtxoView) GetPostEntryReaderState( readerPK []byte, postEntry *PostEntry) *PostEntryReaderState
func (*UtxoView) GetPostsPaginatedForPublicKeyOrderedByTimestamp ¶
func (*UtxoView) GetProfileEntryForPKID ¶
func (bav *UtxoView) GetProfileEntryForPKID(pkid *PKID) *ProfileEntry
func (*UtxoView) GetProfileEntryForPublicKey ¶
func (bav *UtxoView) GetProfileEntryForPublicKey(publicKey []byte) *ProfileEntry
func (*UtxoView) GetProfileEntryForUsername ¶
func (bav *UtxoView) GetProfileEntryForUsername(nonLowercaseUsername []byte) *ProfileEntry
func (*UtxoView) GetPublicKeyForPKID ¶
func (*UtxoView) GetQuoteRecloutsForPostHash ¶
func (*UtxoView) GetRecloutPostEntryStateForReader ¶
func (*UtxoView) GetRecloutsForPostHash ¶
func (*UtxoView) GetSpendableBitcloutBalanceNanosForPublicKey ¶
func (*UtxoView) GetUnspentUtxoEntrysForPublicKey ¶
GetUnspentUtxoEntrysForPublicKey returns the UtxoEntrys corresponding to the passed-in public key that are currently unspent. It does this while factoring in any transactions that have already been connected to it. This is useful, as an example, when one whats to see what UtxoEntrys are available for spending after factoring in (i.e. connecting) all of the transactions currently in the mempool that are related to this public key.
At a high level, this function allows one to get the utxos that are the union of: - utxos in the db - utxos in the view from previously-connected transactions
func (*UtxoView) GetUtxoEntryForUtxoKey ¶
func (*UtxoView) HelpConnectCreatorCoinBuy ¶
func (bav *UtxoView) HelpConnectCreatorCoinBuy( txn *MsgBitCloutTxn, txHash *BlockHash, blockHeight uint32, verifySignatures bool) ( _totalInput uint64, _totalOutput uint64, _creatorCoinReturnedNanos uint64, _founderRewardNanos uint64, _utxoOps []*UtxoOperation, _err error)
TODO: A lot of duplicate code between buy and sell. Consider factoring out the common code.
func (*UtxoView) HelpConnectCreatorCoinSell ¶
func (bav *UtxoView) HelpConnectCreatorCoinSell( txn *MsgBitCloutTxn, txHash *BlockHash, blockHeight uint32, verifySignatures bool) ( _totalInput uint64, _totalOutput uint64, _bitCloutReturnedNanos uint64, _utxoOps []*UtxoOperation, _err error)
TODO: A lot of duplicate code between buy and sell. Consider factoring out the common code.