func fetchBlockFromDB(blockNumber uint64) (*protos.Block, error) { blockBytes, err := db.GetDBHandle().GetFromBlockchainCF(encodeBlockNumberDBKey(blockNumber)) if err != nil { return nil, err } if blockBytes == nil { return nil, nil } return protos.UnmarshallBlock(blockBytes) }
func blockDetailPrinter(blockBytes []byte) { block, _ := protos.UnmarshallBlock(blockBytes) txs := block.GetTransactions() fmt.Printf("Number of transactions = [%d]\n", len(txs)) for _, tx := range txs { if len(tx.Payload) >= MaxValueSize { cIDBytes := tx.ChaincodeID cID := &protos.ChaincodeID{} proto.Unmarshal(cIDBytes, cID) fmt.Printf("TxDetails: payloadSize=[%d], tx.Type=[%s], cID.Name=[%s], cID.Path=[%s]\n", len(tx.Payload), tx.Type, cID.Name, cID.Path) } } }