... merge the two and submit shares to the pool.
what is a share here? Arbitary data with hash less then target?
How does the pool check if the share is for valid block ?
Not sure how a regular pool could do this, but P2Pool is quite well explained in the Wiki: