an implementation of ripplejoin