More work on diff xmit, not finished yet
This commit is contained in:
@@ -205,17 +205,10 @@ bool IdPlayerPool::valid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IdPlayerPool::make_patch(const IdPlayerPool &auth, StreamBuffer *sb) const {
|
||||
void IdPlayerPool::diff(const IdPlayerPool &auth, StreamBuffer *sb) const {
|
||||
assert(valid());
|
||||
assert(auth.valid());
|
||||
|
||||
// The fifo capacity cannot be 255, so we use this as special
|
||||
// to indicate that no changes are present.
|
||||
if (exactly_equal(auth)) {
|
||||
sb->write_uint8(255);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write the fifo capacity and nranges
|
||||
sb->write_uint8(auth.fifo_capacity_);
|
||||
sb->write_uint8(auth.ranges_.size());
|
||||
@@ -238,15 +231,11 @@ bool IdPlayerPool::make_patch(const IdPlayerPool &auth, StreamBuffer *sb) const
|
||||
sb->write_uint8(slot);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void IdPlayerPool::apply_patch(StreamBuffer *sb) {
|
||||
void IdPlayerPool::patch(StreamBuffer *sb) {
|
||||
// read the header byte
|
||||
int fifo_cap = sb->read_uint8();
|
||||
if (fifo_cap == 255) {
|
||||
return;
|
||||
}
|
||||
fifo_capacity_ = fifo_cap;
|
||||
int nranges = sb->read_uint8();
|
||||
std::deque<int64_t> old = std::move(ranges_);
|
||||
@@ -441,8 +430,8 @@ LuaDefine(unittests_idalloc, "c") {
|
||||
|
||||
// Check case: no differences.
|
||||
sb.clear();
|
||||
LuaAssert(L, !ppds.make_patch(pp, &sb));
|
||||
ppds.apply_patch(&sb);
|
||||
ppds.diff(pp, &sb);
|
||||
ppds.patch(&sb);
|
||||
LuaAssert(L, ppds.exactly_equal(pp));
|
||||
|
||||
// Add some values to master pool
|
||||
@@ -451,8 +440,8 @@ LuaDefine(unittests_idalloc, "c") {
|
||||
|
||||
// transmit and compare.
|
||||
sb.clear();
|
||||
LuaAssert(L, ppds.make_patch(pp, &sb));
|
||||
ppds.apply_patch(&sb);
|
||||
ppds.diff(pp, &sb);
|
||||
ppds.patch(&sb);
|
||||
LuaAssert(L, ppds.exactly_equal(pp));
|
||||
|
||||
// Pop a value from master pool
|
||||
@@ -461,8 +450,8 @@ LuaDefine(unittests_idalloc, "c") {
|
||||
|
||||
// transmit and compare.
|
||||
sb.clear();
|
||||
LuaAssert(L, ppds.make_patch(pp, &sb));
|
||||
ppds.apply_patch(&sb);
|
||||
ppds.diff(pp, &sb);
|
||||
ppds.patch(&sb);
|
||||
LuaAssert(L, ppds.exactly_equal(pp));
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user