Try   HackMD

Regen Blockchain Exercise #3

import github.com/google/uuid // msgServer is the server-side (blockchain node) implementation of // a blockchain transaction handler. type msgServer struct{ // store has access to the blockchain state, which is a key/value store // (which will be merkelized) persisted on disk. store *Store } // CreateBlogPost takes the request from the tx, and stores a new blog post // in state. func (s *msgServer) CreateBlogPost(req CreateBlogPostRequest) (CreateBlogPostResponse, error) { // Create a new blog post struct using the inputs from the tx. blogId := uuid.New() blogPost := BlogPost{Id: blogId, Title: req.Title} // Persist the blog post to the store. // Set the key/value in store. err := s.store.Set([]byte(uuid), proto.Marshal(&blogPost)) if err != nil { return CreateBlogPostResponse{}, err } return CreateBlogPostResponse{Id: blogId}, nil } type CreateBlogPostRequest struct { Title string } type CreateBlogPostResponse struct { Id string } type BlogPost struct { proto.Message Id string Title string }