Documentation ¶
Index ¶
- Constants
- Variables
- func AddBig(x float32, y float64) *big.Float
- func CheckNFT(nv []int, nft string) bool
- func CreateMiniBlock(b *pb.RpcBlock, db database.Database, bc *Blockchain) ([32]byte, error, float64)
- func GetBlockDB(height int) ([]byte, []byte)
- func Hash(previousHash []byte, timestamp int64, nonce uint64) [32]byte
- func LastWallet(db database.Database) ([]byte, []byte)
- func MatchBlockHeight(i uint64, j uint64) error
- func MatchDomainToP2PBytes(ov []byte, nv []byte) error
- func StakedInfo(txhash [32]byte, b *MiniBlock, z *NFTStaking) *pb.StakeNFT
- func StringTo32Byte(e string) [32]byte
- func SubBig(x float32, y float64) *big.Float
- func UpdateWalletList(b *MiniBlock, db database.Database, ...) map[string]*pb.UTXOWalletBalanceRespose
- func VerifyAddressPrefix(str string) string
- type AmountRespose
- type Blockchain
- func (bc *Blockchain) AddWallet(wallet string) bool
- func (bc *Blockchain) CheckNFTRewards() []*Transaction
- func (bc *Blockchain) ClearStake(ls []*int64)
- func (bc *Blockchain) ClearTransactionPool()
- func (bc *Blockchain) ConverOldNFTToNew(m []byte, nft *pb.StakeNFT) (*pb.StakeNFT, error)
- func (mbc *Blockchain) ConvertBlockToDomainBlock() *pb.BlockInfo
- func (bc *Blockchain) ConvertBlockToDomainGroupBlock(b *pb.BlockInfo) []*pb.BlockInfo
- func (bc *Blockchain) ConvertGroupToSecureDomainInfo(bks []*pb.BlockInfo) *pb.P2PBlockWithTrustedDataResponseMessage
- func (bc *Blockchain) GetNFT() *Nft
- func (bc *Blockchain) GetStakedNFT() []*pb.StakeNFT
- func (bc *Blockchain) LastMiniBlockRPC() error
- func (bc *Blockchain) MatchDomainBlockToP2PBlock(bk *pb.P2PBlockWithTrustedDataRequestMessage, domainIP net.Addr) error
- func (bc *Blockchain) P2PBlockUngroup(bk *pb.P2PBlockWithTrustedDataRequestMessage) *pb.BlockInfo
- func (bc *Blockchain) ProofOfWork() uint64
- func (bc *Blockchain) StakeNFTMet(sender string, seed string, value string, nft string, stakeunlock string) bool
- func (bc *Blockchain) StakedNFT(b *MiniBlock, pool []*NFTStaking) []*Transaction
- func (bc *Blockchain) TransactionPool() []*Transaction
- func (bc *Blockchain) ValidChain(chain []*MiniBlock) bool
- func (bc *Blockchain) ValidProof(nonce uint64, previousHash [32]byte, transactions []*Transaction, ...) bool
- func (bc *Blockchain) VerifyNFT(wx string) []byte
- func (bc *Blockchain) VerifyTransactionSignature(senderPublickey *ecdsa.PublicKey, s *utils.Signature, tx *Transaction) error
- func (bc *Blockchain) WalletToDB(db database.Database, nb *MiniBlock) error
- type DomainBlock
- type GenesisConsensus
- func (gc *GenesisConsensus) GensisCompile() []byte
- func (gc *GenesisConsensus) MarshalJSON() ([]byte, error)
- func (gc *GenesisConsensus) VerifyGenesis() (string, bool)
- func (gc *GenesisConsensus) VerifyMerkleRoot()
- func (gc *GenesisConsensus) VerifyMessage()
- func (gc *GenesisConsensus) VerifyNonce()
- func (gc *GenesisConsensus) VerifyPreviousHash()
- func (gc *GenesisConsensus) VerifyTimestamp()
- func (gc *GenesisConsensus) VerifyTransaction()
- type JsonMiniBlock
- type LastRPCBlock
- type MBlock
- type MiniBlock
- func (b *MiniBlock) BlockToDB(db database.Database) error
- func (b *MiniBlock) Hash() [32]byte
- func (b *MiniBlock) MarshalJSON() ([]byte, error)
- func (b *MiniBlock) Nonce() uint64
- func (b *MiniBlock) PreviousHash() [32]byte
- func (b *MiniBlock) Transactions() []*Transaction
- func (b *MiniBlock) UnmarshalJSON(data []byte) error
- type NFTStaking
- type Nft
- type TransactionRequest
- type TxVerify
- type Txtransaction
- type WalletCreated
Constants ¶
View Source
const ( BLOCKCHAIN_PORT_RANGE_START = 5000 BLOCKCHAIN_PORT_RANGE_END = 5003 NEIGHBOR_IP_RANGE_START = 0 NEIGHBOR_IP_RANGE_END = 0 BLOCKCHAIN_NEIGHBOR_SYNC_TIME_SEC = 5 )
View Source
const ( MINING_DIFFICULTY = 2 MINING_SENDER = "METCHAIN_Blockchain" MINING_REWARD = 0.3 MINING_REWARD_MEGA = 3 MINING_REWARD_MET = 15 MINING_TIMER_SEC = 10 STAKING_SENDER = "Coinbase" )
Variables ¶
View Source
var MBlockkey = database.MakeBucket([]byte("block"))
View Source
var Utxokey = database.MakeBucket([]byte("utxo_tx"))
Functions ¶
func CreateMiniBlock ¶
func GetBlockDB ¶
func MatchBlockHeight ¶
func MatchDomainToP2PBytes ¶
func StakedInfo ¶
func StakedInfo(txhash [32]byte, b *MiniBlock, z *NFTStaking) *pb.StakeNFT
func StringTo32Byte ¶
func UpdateWalletList ¶
func UpdateWalletList(b *MiniBlock, db database.Database, wallets map[string]*pb.UTXOWalletBalanceRespose) map[string]*pb.UTXOWalletBalanceRespose
func VerifyAddressPrefix ¶
Types ¶
type AmountRespose ¶
type AmountRespose struct {
Amount float32 `json:"amount"`
}
func (*AmountRespose) MarshalJSON ¶
func (ar *AmountRespose) MarshalJSON() ([]byte, error)
type Blockchain ¶
type Blockchain struct { Txpool []*Transaction Unstake []*int64 //Add on 10/4/2023 Update for recording the wallets created. Not to be changed Wallets []*WalletCreated MiniBlock []string MetBlock []string MegaBlock []string MiniBlockCount int MetBlockCount int MegaBlockCount int NFTPool []*NFTStaking NFTStake []*pb.StakeNFT //added for localnodes Port uint16 //added for mining Mux sync.Mutex MuxNeighbors sync.Mutex LastRPCBlock *LastRPCBlock *domain.Metchain }
func Start ¶
func Start(db database.Database) *Blockchain
func (*Blockchain) AddWallet ¶
func (bc *Blockchain) AddWallet(wallet string) bool
func (*Blockchain) CheckNFTRewards ¶
func (bc *Blockchain) CheckNFTRewards() []*Transaction
func (*Blockchain) ClearStake ¶
func (bc *Blockchain) ClearStake(ls []*int64)
func (*Blockchain) ClearTransactionPool ¶
func (bc *Blockchain) ClearTransactionPool()
func (*Blockchain) ConverOldNFTToNew ¶
func (*Blockchain) ConvertBlockToDomainBlock ¶
func (mbc *Blockchain) ConvertBlockToDomainBlock() *pb.BlockInfo
func (*Blockchain) ConvertBlockToDomainGroupBlock ¶
func (bc *Blockchain) ConvertBlockToDomainGroupBlock(b *pb.BlockInfo) []*pb.BlockInfo
func (*Blockchain) ConvertGroupToSecureDomainInfo ¶
func (bc *Blockchain) ConvertGroupToSecureDomainInfo(bks []*pb.BlockInfo) *pb.P2PBlockWithTrustedDataResponseMessage
func (*Blockchain) GetNFT ¶
func (bc *Blockchain) GetNFT() *Nft
func (*Blockchain) GetStakedNFT ¶
func (bc *Blockchain) GetStakedNFT() []*pb.StakeNFT
func (*Blockchain) LastMiniBlockRPC ¶
func (bc *Blockchain) LastMiniBlockRPC() error
func (*Blockchain) MatchDomainBlockToP2PBlock ¶
func (bc *Blockchain) MatchDomainBlockToP2PBlock(bk *pb.P2PBlockWithTrustedDataRequestMessage, domainIP net.Addr) error
func (*Blockchain) P2PBlockUngroup ¶
func (bc *Blockchain) P2PBlockUngroup(bk *pb.P2PBlockWithTrustedDataRequestMessage) *pb.BlockInfo
func (*Blockchain) ProofOfWork ¶
func (bc *Blockchain) ProofOfWork() uint64
func (*Blockchain) StakeNFTMet ¶
func (*Blockchain) StakedNFT ¶
func (bc *Blockchain) StakedNFT(b *MiniBlock, pool []*NFTStaking) []*Transaction
func (*Blockchain) TransactionPool ¶
func (bc *Blockchain) TransactionPool() []*Transaction
func (*Blockchain) ValidChain ¶
func (bc *Blockchain) ValidChain(chain []*MiniBlock) bool
func (*Blockchain) ValidProof ¶
func (*Blockchain) VerifyNFT ¶
func (bc *Blockchain) VerifyNFT(wx string) []byte
func (*Blockchain) VerifyTransactionSignature ¶
func (bc *Blockchain) VerifyTransactionSignature(senderPublickey *ecdsa.PublicKey, s *utils.Signature, tx *Transaction) error
for verification if the transaction is legit
func (*Blockchain) WalletToDB ¶
func (bc *Blockchain) WalletToDB(db database.Database, nb *MiniBlock) error
type DomainBlock ¶
type GenesisConsensus ¶
type GenesisConsensus struct { Timestamp int64 Nonce int PreviousHash [32]byte //As per the Hash size Merkleroot []byte Height int64 Transaction *mconfig.Txtransaction }
func GenesisGenrate ¶
func GenesisGenrate() *GenesisConsensus
func (*GenesisConsensus) GensisCompile ¶
func (gc *GenesisConsensus) GensisCompile() []byte
func (*GenesisConsensus) MarshalJSON ¶
func (gc *GenesisConsensus) MarshalJSON() ([]byte, error)
func (*GenesisConsensus) VerifyGenesis ¶
func (gc *GenesisConsensus) VerifyGenesis() (string, bool)
func (*GenesisConsensus) VerifyMerkleRoot ¶
func (gc *GenesisConsensus) VerifyMerkleRoot()
func (*GenesisConsensus) VerifyMessage ¶
func (gc *GenesisConsensus) VerifyMessage()
func (*GenesisConsensus) VerifyNonce ¶
func (gc *GenesisConsensus) VerifyNonce()
func (*GenesisConsensus) VerifyPreviousHash ¶
func (gc *GenesisConsensus) VerifyPreviousHash()
func (*GenesisConsensus) VerifyTimestamp ¶
func (gc *GenesisConsensus) VerifyTimestamp()
func (*GenesisConsensus) VerifyTransaction ¶
func (gc *GenesisConsensus) VerifyTransaction()
type JsonMiniBlock ¶
type JsonMiniBlock struct {
// contains filtered or unexported fields
}
type LastRPCBlock ¶
type LastRPCBlock struct { Height uint64 Timestamp int64 Nonce uint64 PreviousHash [32]byte //As per the Hash size Megablock [32]byte Metblock [32]byte Transactions []*Transaction CurrentHash [32]byte Bits uint64 }
func (*LastRPCBlock) BlockToRPCLastBlock ¶
func (lb *LastRPCBlock) BlockToRPCLastBlock(nb *MiniBlock) *LastRPCBlock
type MBlock ¶
type MBlock struct { Height uint64 Timestamp int64 Nonce uint64 PreviousHash [32]byte //As per the Hash size Megablock [32]byte Metblock [32]byte Transactions []*Transaction CurrentHash [32]byte Bits uint64 }
func (*MBlock) DomainblockToRPCBlock ¶
func (*MBlock) UnmarshalJSON ¶
type MiniBlock ¶
type MiniBlock struct {
// contains filtered or unexported fields
}
func (*MiniBlock) MarshalJSON ¶
func (*MiniBlock) PreviousHash ¶
func (*MiniBlock) Transactions ¶
func (b *MiniBlock) Transactions() []*Transaction
func (*MiniBlock) UnmarshalJSON ¶
type NFTStaking ¶
type TransactionRequest ¶
type TxVerify ¶
type TxVerify struct {
// contains filtered or unexported fields
}
func (*TxVerify) VerifySignature ¶
type Txtransaction ¶
func (*Txtransaction) MarshalJSON ¶
func (tx *Txtransaction) MarshalJSON() ([]byte, error)
type WalletCreated ¶
func (*WalletCreated) MarshalJSON ¶
func (wc *WalletCreated) MarshalJSON() ([]byte, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.