You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
592 B

6 years ago
6 years ago
6 years ago
6 years ago
  1. package blockchainlib
  2. import (
  3. "fmt"
  4. p2plib "../p2plib"
  5. )
  6. func (bc *Blockchain) CreateMsgHandlerCases() map[string]func(p2plib.Peer, p2plib.Msg) {
  7. configuredMsgCases := make(map[string]func(p2plib.Peer, p2plib.Msg))
  8. configuredMsgCases["Block"] = func(peer p2plib.Peer, msg p2plib.Msg) {
  9. //TODO check if the block is signed by an autorized emitter
  10. //block = msg.Data converted to Block
  11. var block Block
  12. if !bc.BlockExists(block) {
  13. bc.AddBlock(block)
  14. p2plib.PropagateData(peer, "block in string format")
  15. }
  16. }
  17. fmt.Println(configuredMsgCases)
  18. return configuredMsgCases
  19. }