Skip to content

Commit

Permalink
fix(swingset): more Far/Data on the network vat
Browse files Browse the repository at this point in the history
  • Loading branch information
warner committed Mar 3, 2021
1 parent 71c3eff commit ce82afc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 8 additions & 7 deletions packages/SwingSet/src/vats/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import makeStore from '@agoric/store';
import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { makePromiseKit } from '@agoric/promise-kit';
import { assert, details as X } from '@agoric/assert';
import { toBytes } from './bytes';
Expand Down Expand Up @@ -51,7 +52,7 @@ export const makeConnection = (
/**
* @type {Connection}
*/
const connection = harden({
const connection = Far('Connection', {
getLocalAddress() {
return localAddr;
},
Expand Down Expand Up @@ -138,7 +139,7 @@ export function crossoverConnection(

function makeHalfConnection(l, r) {
let closed;
conns[l] = harden({
conns[l] = Far('Connection', {
getLocalAddress() {
return addrs[l];
},
Expand Down Expand Up @@ -271,7 +272,7 @@ export function makeNetworkProtocol(protocolHandler) {
/**
* @type {Port}
*/
const port = harden({
const port = Far('Port', {
getLocalAddress() {
// Works even after revoke().
return localAddr;
Expand Down Expand Up @@ -372,7 +373,7 @@ export function makeNetworkProtocol(protocolHandler) {
/**
* @type {ProtocolImpl}
*/
const protocolImpl = harden({
const protocolImpl = Far('ProtocolImpl', {
bind,
async inbound(listenAddr, remoteAddr) {
let lastFailure = Error(`No listeners for ${listenAddr}`);
Expand Down Expand Up @@ -400,7 +401,7 @@ export function makeNetworkProtocol(protocolHandler) {
// We have a legitimate inbound attempt.
let consummated;
const current = currentConnections.get(port);
const inboundAttempt = harden({
const inboundAttempt = Far('InboundAttempt', {
getLocalAddress() {
// Return address metadata.
return localAddr;
Expand Down Expand Up @@ -500,7 +501,7 @@ export function makeEchoConnectionHandler() {
/**
* @type {Connection}
*/
return harden({
return Far('ConnectionHandler', {
async onReceive(_connection, bytes, _connectionHandler) {
if (closed) {
throw closed;
Expand Down Expand Up @@ -529,7 +530,7 @@ export function makeLoopbackProtocolHandler() {

let nonce = 0;

return harden({
return Far('ProtocolHandler', {
// eslint-disable-next-line no-empty-function
async onCreate(_impl, _protocolHandler) {
// TODO
Expand Down
5 changes: 3 additions & 2 deletions packages/SwingSet/src/vats/network/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check

import { E as defaultE } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import makeStore from '@agoric/store';
import { assert, details as X } from '@agoric/assert';
import { makeNetworkProtocol, ENDPOINT_SEPARATOR } from './network';
Expand All @@ -26,7 +27,7 @@ export default function makeRouter() {
* @type {Store<string, any>}
*/
const prefixToRoute = makeStore('prefix');
return harden({
return Far('Router', {
getRoutes(addr) {
const parts = addr.split(ENDPOINT_SEPARATOR);
/**
Expand Down Expand Up @@ -116,7 +117,7 @@ export function makeRouterProtocol(E = defaultE) {
return E(route[1]).bind(localAddr);
}

return harden({
return Far('RouterProtocol', {
bind,
registerProtocolHandler,
unregisterProtocolHandler,
Expand Down

0 comments on commit ce82afc

Please sign in to comment.