mirror of
https://github.com/hackku21/loc-chain-app.git
synced 2024-10-27 20:34:05 +00:00
share transactions
This commit is contained in:
parent
b978f11640
commit
c985867ee2
@ -5,6 +5,9 @@ import 'package:flutter_udid/flutter_udid.dart';
|
|||||||
import 'package:loc_chain_app/util/transaction_manager.dart';
|
import 'package:loc_chain_app/util/transaction_manager.dart';
|
||||||
import 'package:nearby_connections/nearby_connections.dart';
|
import 'package:nearby_connections/nearby_connections.dart';
|
||||||
|
|
||||||
|
import 'package:loc_chain_app/util/keyfile_manager.dart';
|
||||||
|
import 'package:loc_chain_app/util/transaction_manager.dart';
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
HomePage({Key? key, required this.title}) : super(key: key);
|
HomePage({Key? key, required this.title}) : super(key: key);
|
||||||
final String title;
|
final String title;
|
||||||
@ -27,6 +30,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
static late String userName;
|
static late String userName;
|
||||||
final Strategy strategy = Strategy.P2P_STAR;
|
final Strategy strategy = Strategy.P2P_STAR;
|
||||||
Map<String, ConnectionInfo> endpointMap = Map();
|
Map<String, ConnectionInfo> endpointMap = Map();
|
||||||
|
static Map<String, Transaction> transactionMap = Map();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -63,24 +67,25 @@ class _HomePageState extends State<HomePage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String genPayload(ConnectionInfo value) {
|
Future<String> genPayload(ConnectionInfo value) async {
|
||||||
print("Sender ID: $userName");
|
print("Sender ID: $userName");
|
||||||
print("Receiver ID: ${value.endpointName}");
|
print("Receiver ID: ${value.endpointName}");
|
||||||
|
|
||||||
var dateTime = DateTime.now();
|
var dateTime = DateTime.now();
|
||||||
|
|
||||||
print('Milliseconds since Epoch: ${dateTime.millisecondsSinceEpoch}');
|
print('Milliseconds since Epoch: ${dateTime.millisecondsSinceEpoch}');
|
||||||
|
|
||||||
String payload = userName +
|
String p2p = await Transaction.generateHash(value.endpointName) +
|
||||||
":" +
|
":" +
|
||||||
value.endpointName +
|
value.endpointName +
|
||||||
":" +
|
":" +
|
||||||
dateTime.millisecondsSinceEpoch.toString();
|
dateTime.millisecondsSinceEpoch.toString();
|
||||||
return payload;
|
return p2p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendPayload() {
|
void sendPayload() async {
|
||||||
endpointMap.forEach((key, value) {
|
endpointMap.forEach((key, value) async {
|
||||||
String a = genPayload(value);
|
String a = await genPayload(value);
|
||||||
|
|
||||||
showSnackbar("Sending $a to ${value.endpointName}, id: $key");
|
showSnackbar("Sending $a to ${value.endpointName}, id: $key");
|
||||||
Nearby().sendBytesPayload(key, Uint8List.fromList(a.codeUnits));
|
Nearby().sendBytesPayload(key, Uint8List.fromList(a.codeUnits));
|
||||||
|
Loading…
Reference in New Issue
Block a user