+ // Create a new scanner for parsing incoming bytes into transaction tokens
+ scanner := bufio.NewScanner(ui.HLClient.Connection)
+ scanner.Split(transactionScanner)
+
+ // Scan for new transactions and handle them as they come in.
+ for scanner.Scan() {
+ // Make a new []byte slice and copy the scanner bytes to it. This is critical to avoid a data race as the
+ // scanner re-uses the buffer for subsequent scans.
+ buf := make([]byte, len(scanner.Bytes()))
+ copy(buf, scanner.Bytes())
+
+ t, _, err := ReadTransaction(buf)