Advertisement
Prasanga

Untitled

Feb 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. //
  2. // Created by prasanga on 2/19/18.
  3. //
  4.  
  5. #ifndef MINIP_BLOCK_H
  6. #define MINIP_BLOCK_H
  7.  
  8. #include <vector>
  9. #include <iostream>
  10. #include <sstream>
  11. #include <iterator>
  12.  
  13. using namespace std;
  14. namespace bitenger_blockchain{
  15. class Block{
  16. private:
  17. std::string _sender;
  18. std::string _receiver;
  19. std::string _prevHash;
  20. std::string _data;
  21.  
  22. public:
  23. long long _size;
  24. std::string _genesisHash;
  25. std::string _currentHash;
  26.  
  27. Block(){
  28. _size = sizeof(*this);
  29. }
  30.  
  31. bool verify(){
  32.  
  33. };
  34. bool checkRecipient(const std::string id){
  35. return (id==this->_receiver);
  36. }
  37. std::string getData(std::string privateKey){
  38. if(checkRecipient(privateKey))
  39. return this->_data;
  40. return "";
  41. }
  42. std::string sendData(){
  43. return _genesisHash+" "+_currentHash+" "+_sender+" "+_receiver+" "+_prevHash+" "+_data;
  44. }
  45. void receiveData(string dat){
  46. std::stringstream ss(dat);
  47. std::istream_iterator<std::string> begin(ss);
  48. std::istream_iterator<std::string> end;
  49. std::vector<std::string> vstrings(begin, end);
  50. cout<<vstrings.size()<<endl;
  51. }
  52. };
  53. struct Node{
  54. Block data;
  55. Node *nextNode;
  56. };
  57. std::vector<struct Node> blockChain;
  58. }
  59. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement