Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Person
- {
- bytes32 firstName;
- bytes32 lastName;
- }
- function addPerson(bytes32 _firstName, bytes32 _lastname) returns (bool success)
- {
- Person memory newPerson;
- newPerson.firstName = _firstName;
- newPerson.lastName = _lastname;
- people.push(newPerson);
- return true;
- }
- function getPeople() constant returns (bytes32[], bytes32[])
- {
- uint leng = people.length;
- bytes32[] memory first_names = new bytes32[](leng);
- bytes32[] memory last_names = new bytes32[](leng);
- for (uint i = 0; i < people.length; i++ )
- {
- Person memory currentPerson;
- currentPerson = people[i];
- first_names[i] = (currentPerson.firstName);
- last_names[i] = (currentPerson.lastName);
- }
- return (first_names,last_names);
- }
- public RemoteCall<Tuple2<List<byte[]>, List<byte[]>>> getPeople() {
- final Function function = new Function("getPeople",
- Arrays.<Type>asList(),
- Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Bytes32>>() {}, new TypeReference<DynamicArray<Bytes32>>() {}));
- return new RemoteCall<Tuple2<List<byte[]>, List<byte[]>>>(
- new Callable<Tuple2<List<byte[]>, List<byte[]>>>() {
- @Override
- public Tuple2<List<byte[]>, List<byte[]>> call() throws Exception {
- List<Type> results = executeCallMultipleValueReturn(function);;
- return new Tuple2<List<byte[]>, List<byte[]>>(
- (List<byte[]>) results.get(0).getValue(),
- (List<byte[]>) results.get(1).getValue());
- }
- });
- }
Add Comment
Please, Sign In to add comment