Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nosequeldeebee committed Feb 9, 2018
1 parent 059ed31 commit 788919a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions networking/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net"
"os"
"strconv"
"sync"
"time"

"github.com/davecgh/go-spew/spew"
Expand All @@ -30,6 +31,7 @@ var Blockchain []Block

// bcServer handles incoming concurrent Blocks
var bcServer chan []Block
var mutex = &sync.Mutex{}

func main() {
err := godotenv.Load()
Expand Down Expand Up @@ -97,10 +99,12 @@ func handleConn(conn net.Conn) {
go func() {
for {
time.Sleep(30 * time.Second)
mutex.Lock()
output, err := json.Marshal(Blockchain)
if err != nil {
log.Fatal(err)
}
mutex.Unlock()
io.WriteString(conn, string(output))
}
}()
Expand Down

0 comments on commit 788919a

Please sign in to comment.